james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [05/14] james-project git commit: JAMES-2540 renaming MetricFactory.withMetrics to runPublishingTimerMetric
Date Mon, 17 Sep 2018 06:33:15 GMT
JAMES-2540 renaming MetricFactory.withMetrics to runPublishingTimerMetric


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/60fcc28a
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/60fcc28a
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/60fcc28a

Branch: refs/heads/master
Commit: 60fcc28ada39cd311280431f6dcc3449883492fc
Parents: 0303205
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Tue Sep 11 16:06:04 2018 +0200
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Sep 14 11:05:43 2018 +0700

----------------------------------------------------------------------
 .../org/apache/james/mailbox/tika/TikaTextExtractor.java     | 2 +-
 .../java/org/apache/james/metrics/api/MetricFactory.java     | 6 +++---
 .../java/org/apache/james/jmap/methods/GetFilterMethod.java  | 2 +-
 .../org/apache/james/jmap/methods/GetMailboxesMethod.java    | 2 +-
 .../org/apache/james/jmap/methods/GetMessageListMethod.java  | 2 +-
 .../org/apache/james/jmap/methods/GetMessagesMethod.java     | 2 +-
 .../apache/james/jmap/methods/GetVacationResponseMethod.java | 2 +-
 .../java/org/apache/james/jmap/methods/SendMDNProcessor.java | 2 +-
 .../java/org/apache/james/jmap/methods/SetFilterMethod.java  | 2 +-
 .../org/apache/james/jmap/methods/SetMailboxesMethod.java    | 2 +-
 .../james/jmap/methods/SetMessagesDestructionProcessor.java  | 2 +-
 .../org/apache/james/jmap/methods/SetMessagesMethod.java     | 2 +-
 .../apache/james/jmap/methods/SetVacationResponseMethod.java | 2 +-
 .../org/apache/james/queue/rabbitmq/RabbitMQMailQueue.java   | 4 ++--
 .../org/apache/james/spamassassin/SpamAssassinInvoker.java   | 8 ++++----
 15 files changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/mailbox/tika/src/main/java/org/apache/james/mailbox/tika/TikaTextExtractor.java
----------------------------------------------------------------------
diff --git a/mailbox/tika/src/main/java/org/apache/james/mailbox/tika/TikaTextExtractor.java
b/mailbox/tika/src/main/java/org/apache/james/mailbox/tika/TikaTextExtractor.java
index c4ff6cf..6520797 100644
--- a/mailbox/tika/src/main/java/org/apache/james/mailbox/tika/TikaTextExtractor.java
+++ b/mailbox/tika/src/main/java/org/apache/james/mailbox/tika/TikaTextExtractor.java
@@ -77,7 +77,7 @@ public class TikaTextExtractor implements TextExtractor {
 
     @Override
     public ParsedContent extractContent(InputStream inputStream, String contentType) throws
Exception {
-        return metricFactory.withMetric("tikaTextExtraction", Throwing.supplier(
+        return metricFactory.runPublishingTimerMetric("tikaTextExtraction", Throwing.supplier(
             () -> performContentExtraction(inputStream, contentType))
             .sneakyThrow());
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
----------------------------------------------------------------------
diff --git a/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
b/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
index ca63d43..a472b53 100644
--- a/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
+++ b/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
@@ -27,7 +27,7 @@ public interface MetricFactory {
 
     TimeMetric timer(String name);
 
-    default <T> T withMetric(String name, Supplier<T> operation) {
+    default <T> T runPublishingTimerMetric(String name, Supplier<T> operation)
{
         TimeMetric timer = timer(name);
         try {
             return operation.get();
@@ -36,8 +36,8 @@ public interface MetricFactory {
         }
     }
 
-    default void withMetric(String name, Runnable runnable) {
-        withMetric(name, () -> {
+    default void runPublishingTimerMetric(String name, Runnable runnable) {
+        runPublishingTimerMetric(name, () -> {
             runnable.run();
             return null;
         });

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetFilterMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetFilterMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetFilterMethod.java
index 2dac51e..275417e 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetFilterMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetFilterMethod.java
@@ -73,7 +73,7 @@ public class GetFilterMethod implements Method {
 
         GetFilterRequest filterRequest = (GetFilterRequest) request;
 
-        return metricFactory.withMetric(JMAP_PREFIX + METHOD_NAME.getName(),
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + METHOD_NAME.getName(),
             MDCBuilder.create()
                 .addContext(MDCBuilder.ACTION, "GET_FILTER")
                 .wrapArround(() -> process(clientId, mailboxSession, filterRequest)));

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java
index 62c827d..9b33064 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java
@@ -80,7 +80,7 @@ public class GetMailboxesMethod implements Method {
     public Stream<JmapResponse> process(JmapRequest request, ClientId clientId, MailboxSession
mailboxSession) {
         Preconditions.checkArgument(request instanceof GetMailboxesRequest);
         GetMailboxesRequest mailboxesRequest = (GetMailboxesRequest) request;
-        return metricFactory.withMetric(JMAP_PREFIX + METHOD_NAME.getName(),
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + METHOD_NAME.getName(),
             MDCBuilder.create()
                 .addContext(MDCBuilder.ACTION, "GET_MAILBOXES")
                 .addContext("accountId", mailboxesRequest.getAccountId())

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
index a720a02..4743ce3 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
@@ -94,7 +94,7 @@ public class GetMessageListMethod implements Method {
 
         GetMessageListRequest messageListRequest = (GetMessageListRequest) request;
 
-        return metricFactory.withMetric(JMAP_PREFIX + METHOD_NAME.getName(), MDCBuilder.create()
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + METHOD_NAME.getName(),
MDCBuilder.create()
             .addContext(MDCBuilder.ACTION, "GET_MESSAGE_LIST")
             .addContext("accountId", messageListRequest.getAccountId())
             .addContext("limit", messageListRequest.getLimit())

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java
index ae4c0e3..d180934 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java
@@ -102,7 +102,7 @@ public class GetMessagesMethod implements Method {
         GetMessagesRequest getMessagesRequest = (GetMessagesRequest) request;
         MessageProperties outputProperties = getMessagesRequest.getProperties().toOutputProperties();
 
-        return metricFactory.withMetric(JMAP_PREFIX + METHOD_NAME.getName(),
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + METHOD_NAME.getName(),
             MDCBuilder.create()
                 .addContext(MDCBuilder.ACTION, "GET_MESSAGES")
                 .addContext("accountId", getMessagesRequest.getAccountId())

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
index 129ac6d..e242c7d 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
@@ -70,7 +70,7 @@ public class GetVacationResponseMethod implements Method {
         Preconditions.checkNotNull(mailboxSession);
         Preconditions.checkArgument(request instanceof GetVacationRequest);
 
-        return metricFactory.withMetric(JMAP_PREFIX + METHOD_NAME.getName(),
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + METHOD_NAME.getName(),
             MDCBuilder.create()
                 .addContext(MDCBuilder.ACTION, "VACATION")
                 .wrapArround(

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SendMDNProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SendMDNProcessor.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SendMDNProcessor.java
index b736721..b828900 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SendMDNProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SendMDNProcessor.java
@@ -84,7 +84,7 @@ public class SendMDNProcessor implements SetMessagesProcessor {
 
     @Override
     public SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession)
{
-        return metricFactory.withMetric(JMAP_PREFIX + "SendMDN",
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + "SendMDN",
             () -> handleMDNCreation(request, mailboxSession));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetFilterMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetFilterMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetFilterMethod.java
index e6184ec..72397ca 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetFilterMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetFilterMethod.java
@@ -111,7 +111,7 @@ public class SetFilterMethod implements Method {
 
         SetFilterRequest setFilterRequest = (SetFilterRequest) request;
 
-        return metricFactory.withMetric(JMAP_PREFIX + METHOD_NAME.getName(),
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + METHOD_NAME.getName(),
             MDCBuilder.create()
                 .addContext(MDCBuilder.ACTION, "SET_FILTER")
                 .addContext("update", setFilterRequest.getSingleton())

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesMethod.java
index 4a4011f..def34f3 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesMethod.java
@@ -67,7 +67,7 @@ public class SetMailboxesMethod implements Method {
 
         SetMailboxesRequest setMailboxesRequest = (SetMailboxesRequest) request;
 
-        return metricFactory.withMetric(JMAP_PREFIX + METHOD_NAME.getName(),
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + METHOD_NAME.getName(),
             MDCBuilder.create()
                 .addContext(MDCBuilder.ACTION, "SET_MAILBOXES")
                 .addContext("create", setMailboxesRequest.getCreate())

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesDestructionProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesDestructionProcessor.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesDestructionProcessor.java
index a7bfa64..6cad424 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesDestructionProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesDestructionProcessor.java
@@ -56,7 +56,7 @@ public class SetMessagesDestructionProcessor implements SetMessagesProcessor
{
 
     @Override
     public SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession)
{
-        return metricFactory.withMetric(JMAP_PREFIX + "SetMessageDestructionProcessor",
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + "SetMessageDestructionProcessor",
             () -> delete(request.getDestroy(), mailboxSession)
                 .reduce(SetMessagesResponse.builder(),
                     SetMessagesResponse.Builder::accumulator,

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesMethod.java
index 49e191e..19175e7 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesMethod.java
@@ -63,7 +63,7 @@ public class SetMessagesMethod implements Method {
         Preconditions.checkArgument(request instanceof SetMessagesRequest);
         SetMessagesRequest setMessagesRequest = (SetMessagesRequest) request;
 
-        return metricFactory.withMetric(JMAP_PREFIX + METHOD_NAME.getName(),
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + METHOD_NAME.getName(),
             MDCBuilder.create()
                 .addContext(MDCBuilder.ACTION, "SET_MESSAGES")
                 .addContext("accountId", setMessagesRequest.getAccountId())

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java
index c669e8c..d10cc3f 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java
@@ -76,7 +76,7 @@ public class SetVacationResponseMethod implements Method {
         Preconditions.checkArgument(request instanceof SetVacationRequest);
         SetVacationRequest setVacationRequest = (SetVacationRequest) request;
 
-        return metricFactory.withMetric(JMAP_PREFIX + METHOD_NAME.getName(),
+        return metricFactory.runPublishingTimerMetric(JMAP_PREFIX + METHOD_NAME.getName(),
             MDCBuilder.create()
                 .addContext(MDCBuilder.ACTION, "SET_VACATION")
                 .addContext("update", setVacationRequest.getUpdate())

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueue.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueue.java
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueue.java
index 74f6ef7..fd564bb 100644
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueue.java
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueue.java
@@ -106,13 +106,13 @@ public class RabbitMQMailQueue implements MailQueue {
 
     @Override
     public void enQueue(Mail mail) throws MailQueueException {
-        metricFactory.withMetric(ENQUEUED_TIMER_METRIC_NAME_PREFIX + name.asString(),
+        metricFactory.runPublishingTimerMetric(ENQUEUED_TIMER_METRIC_NAME_PREFIX + name.asString(),
             Throwing.runnable(() -> enqueuer.enQueue(mail)).sneakyThrow());
     }
 
     @Override
     public MailQueueItem deQueue() throws MailQueueException {
-        return metricFactory.withMetric(DEQUEUED_TIMER_METRIC_NAME_PREFIX + name.asString(),
+        return metricFactory.runPublishingTimerMetric(DEQUEUED_TIMER_METRIC_NAME_PREFIX +
name.asString(),
             Throwing.supplier(dequeuer::deQueue).sneakyThrow());
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/60fcc28a/third-party/spamassassin/src/main/java/org/apache/james/spamassassin/SpamAssassinInvoker.java
----------------------------------------------------------------------
diff --git a/third-party/spamassassin/src/main/java/org/apache/james/spamassassin/SpamAssassinInvoker.java
b/third-party/spamassassin/src/main/java/org/apache/james/spamassassin/SpamAssassinInvoker.java
index 2a9fd8a..1a97bf8 100644
--- a/third-party/spamassassin/src/main/java/org/apache/james/spamassassin/SpamAssassinInvoker.java
+++ b/third-party/spamassassin/src/main/java/org/apache/james/spamassassin/SpamAssassinInvoker.java
@@ -93,7 +93,7 @@ public class SpamAssassinInvoker {
      *             if an error on scanning is detected
      */
     public SpamAssassinResult scanMail(MimeMessage message, String user) throws MessagingException
{
-        return metricFactory.withMetric(
+        return metricFactory.runPublishingTimerMetric(
             "spamAssassin-check",
             Throwing.supplier(
                 () -> scanMailWithAdditionalHeaders(message,
@@ -102,7 +102,7 @@ public class SpamAssassinInvoker {
     }
 
     public SpamAssassinResult scanMail(MimeMessage message) throws MessagingException {
-        return metricFactory.withMetric(
+        return metricFactory.runPublishingTimerMetric(
             "spamAssassin-check",
             Throwing.supplier(
                 () -> scanMailWithoutAdditionalHeaders(message))
@@ -188,7 +188,7 @@ public class SpamAssassinInvoker {
      *             if an error occured during learning.
      */
     public boolean learnAsSpam(InputStream message, String user) throws MessagingException
{
-        return metricFactory.withMetric(
+        return metricFactory.runPublishingTimerMetric(
             "spamAssassin-spam-report",
             Throwing.supplier(
                 () -> reportMessageAs(message, user, MessageClass.SPAM))
@@ -204,7 +204,7 @@ public class SpamAssassinInvoker {
      *             if an error occured during learning.
      */
     public boolean learnAsHam(InputStream message, String user) throws MessagingException
{
-        return metricFactory.withMetric(
+        return metricFactory.runPublishingTimerMetric(
             "spamAssassin-ham-report",
             Throwing.supplier(
                 () -> reportMessageAs(message, user, MessageClass.HAM))


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message