james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [3/7] james-project git commit: JAMES-1950 Add metrics for the mailet pipeline
Date Tue, 14 Mar 2017 09:01:43 GMT
JAMES-1950 Add metrics for the mailet pipeline


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

Branch: refs/heads/master
Commit: ae2caed05ebd4b3a0a577ddc035d312559fd3077
Parents: fc434bc
Author: benwa <btellier@linagora.com>
Authored: Mon Mar 13 09:02:22 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Mar 14 15:59:22 2017 +0700

----------------------------------------------------------------------
 server/mailet/mailetcontainer-camel/pom.xml            |  4 ++++
 .../james/mailetcontainer/impl/JamesMailSpooler.java   | 13 +++++++++++++
 2 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ae2caed0/server/mailet/mailetcontainer-camel/pom.xml
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/pom.xml b/server/mailet/mailetcontainer-camel/pom.xml
index 1d9ff82..400d69b 100644
--- a/server/mailet/mailetcontainer-camel/pom.xml
+++ b/server/mailet/mailetcontainer-camel/pom.xml
@@ -69,6 +69,10 @@
             <groupId>org.apache.james</groupId>
             <artifactId>apache-mailet-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>metrics-api</artifactId>
+        </dependency>
         <!--
             <dependency>
             <groupId>org.apache.james</groupId>

http://git-wip-us.apache.org/repos/asf/james-project/blob/ae2caed0/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailSpooler.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailSpooler.java
b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailSpooler.java
index f2c3e47..2875a00 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailSpooler.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/JamesMailSpooler.java
@@ -35,6 +35,8 @@ import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.lifecycle.api.LogEnabled;
 import org.apache.james.mailetcontainer.api.MailProcessor;
 import org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean;
+import org.apache.james.metrics.api.MetricFactory;
+import org.apache.james.metrics.api.TimeMetric;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueue.MailQueueException;
 import org.apache.james.queue.api.MailQueue.MailQueueItem;
@@ -50,6 +52,7 @@ import org.slf4j.Logger;
  */
 public class JamesMailSpooler implements Runnable, Disposable, Configurable, LogEnabled,
MailSpoolerMBean {
 
+    public static final String SPOOL_PROCESSING = "spoolProcessing";
     private MailQueue queue;
 
     /**
@@ -69,6 +72,8 @@ public class JamesMailSpooler implements Runnable, Disposable, Configurable,
Log
      */
     private final AtomicBoolean active = new AtomicBoolean(false);
 
+    private final MetricFactory metricFactory;
+
     /**
      * Spool threads
      */
@@ -88,6 +93,11 @@ public class JamesMailSpooler implements Runnable, Disposable, Configurable,
Log
     private int numDequeueThreads;
 
     @Inject
+    public JamesMailSpooler(MetricFactory metricFactory) {
+        this.metricFactory = metricFactory;
+    }
+
+    @Inject
     public void setMailQueueFactory(MailQueueFactory queueFactory) {
         this.queueFactory = queueFactory;
     }
@@ -145,6 +155,7 @@ public class JamesMailSpooler implements Runnable, Disposable, Configurable,
Log
         while (active.get()) {
 
             final MailQueueItem queueItem;
+            TimeMetric timeMetric = metricFactory.timer(SPOOL_PROCESSING);
             try {
                 queueItem = queue.deQueue();
                 workerService.execute(new Runnable() {
@@ -195,6 +206,8 @@ public class JamesMailSpooler implements Runnable, Disposable, Configurable,
Log
                 }
             } catch (InterruptedException interrupted) {
                 //MailSpooler is stopping
+            } finally {
+                timeMetric.stopAndPublish();
             }
         }
         logger.info("Stop {} : {}", getClass().getName(), Thread.currentThread().getName());


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