james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [1/7] james-project git commit: JAMES-1950 Adding TimeMetrics for all Matcher
Date Tue, 14 Mar 2017 09:01:41 GMT
Repository: james-project
Updated Branches:
  refs/heads/master fc434bc85 -> be7d02c49


JAMES-1950 Adding TimeMetrics for all Matcher


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

Branch: refs/heads/master
Commit: f7e65142e4eb0273d5a3bb670d81f9f1511da2da
Parents: 9f94c0a
Author: benwa <btellier@linagora.com>
Authored: Mon Mar 13 16:10:38 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Mar 14 15:59:22 2017 +0700

----------------------------------------------------------------------
 .../impl/camel/CamelMailetProcessor.java              |  3 ++-
 .../mailetcontainer/impl/camel/MatcherSplitter.java   | 14 ++++++++++++--
 .../impl/camel/CamelCompositeProcessorTest.java       |  3 ++-
 3 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f7e65142/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessor.java
b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessor.java
index 1593fc4..7f879c4 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessor.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessor.java
@@ -153,7 +153,8 @@ public class CamelMailetProcessor extends AbstractStateMailetProcessor
implement
 
             RouteDefinition processorDef = from(getEndpoint()).routeId(state).setExchangePattern(ExchangePattern.InOnly)
             // store the logger in properties
-                    .setProperty(MatcherSplitter.LOGGER_PROPERTY, constant(getLogger()));
+                    .setProperty(MatcherSplitter.LOGGER_PROPERTY, constant(getLogger()))
+                    .setProperty(MatcherSplitter.METRIC_FACTORY, constant(metricFactory));
 
             for (MatcherMailetPair pair : pairs) {
                 Matcher matcher = pair.getMatcher();

http://git-wip-us.apache.org/repos/asf/james-project/blob/f7e65142/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java
b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java
index 1e4520e..1deac8a 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/camel/MatcherSplitter.java
@@ -33,6 +33,8 @@ import org.apache.camel.Property;
 import org.apache.james.core.MailImpl;
 import org.apache.james.mailetcontainer.impl.ProcessorUtil;
 import org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor.MailetProcessorListener;
+import org.apache.james.metrics.api.MetricFactory;
+import org.apache.james.metrics.api.TimeMetric;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Matcher;
@@ -57,6 +59,8 @@ public class MatcherSplitter {
 
     public final static String MAILETCONTAINER_PROPERTY = "container";
 
+    public final static String METRIC_FACTORY = "metricFactory";
+
     /**
      * Generate a List of MailMessage instances for the give @Body. This is done
      * by using the given Matcher to see if we need more then one instance of
@@ -70,11 +74,17 @@ public class MatcherSplitter {
      * @throws MessagingException
      */
     @Handler
-    public List<Mail> split(@Property(MATCHER_PROPERTY) Matcher matcher, @Property(ON_MATCH_EXCEPTION_PROPERTY)
String onMatchException, @Property(LOGGER_PROPERTY) Logger logger, @Property(MAILETCONTAINER_PROPERTY)
CamelMailetProcessor container, @Body Mail mail) throws MessagingException {
+    public List<Mail> split(@Property(MATCHER_PROPERTY) Matcher matcher,
+                            @Property(ON_MATCH_EXCEPTION_PROPERTY) String onMatchException,
+                            @Property(LOGGER_PROPERTY) Logger logger,
+                            @Property(MAILETCONTAINER_PROPERTY) CamelMailetProcessor container,
+                            @Property(METRIC_FACTORY) MetricFactory metricFactory,
+                            @Body Mail mail) throws MessagingException {
         Collection<MailAddress> matchedRcpts = null;
         Collection<MailAddress> origRcpts = new ArrayList<MailAddress>(mail.getRecipients());
         long start = System.currentTimeMillis();
         MessagingException ex = null;
+        TimeMetric timeMetric = metricFactory.timer(matcher.getClass().getSimpleName());
 
         try {
             List<Mail> mails = new ArrayList<Mail>();
@@ -151,7 +161,7 @@ public class MatcherSplitter {
 
             return mails;
         } finally {
-
+            timeMetric.stopAndPublish();
             long complete = System.currentTimeMillis() - start;
             List<MailetProcessorListener> listeners = container.getListeners();
             for (MailetProcessorListener listener : listeners) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/f7e65142/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java
b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java
index 5e8afcd..7e2bf43 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java
@@ -25,13 +25,14 @@ import org.apache.james.mailetcontainer.api.mock.MockMailetLoader;
 import org.apache.james.mailetcontainer.api.mock.MockMatcherLoader;
 import org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessor;
 import org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessorTest;
+import org.apache.james.metrics.api.NoopMetricFactory;
 import org.slf4j.LoggerFactory;
 
 public class CamelCompositeProcessorTest extends AbstractStateCompositeProcessorTest {
 
     @Override
     protected AbstractStateCompositeProcessor createProcessor(HierarchicalConfiguration config)
throws Exception {
-        CamelCompositeProcessor processor = new CamelCompositeProcessor();
+        CamelCompositeProcessor processor = new CamelCompositeProcessor(new NoopMetricFactory());
         try {
             processor.setLog(LoggerFactory.getLogger("MockLog"));
             processor.setCamelContext(new DefaultCamelContext());


---------------------------------------------------------------------
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