james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [6/8] james-project git commit: JAMES-2544 Mailqueue metrics registering belongs to the factory
Date Wed, 03 Oct 2018 09:45:10 GMT
JAMES-2544 Mailqueue metrics registering belongs to the factory


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

Branch: refs/heads/master
Commit: 15c7ebb718b4fc51e9ddec9e9f373b0329f8a17a
Parents: 95cf63f
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Fri Sep 28 15:38:41 2018 +0200
Committer: duc <dtran@linagora.com>
Committed: Wed Oct 3 12:06:02 2018 +0700

----------------------------------------------------------------------
 .../james/queue/rabbitmq/RabbitMQMailQueue.java     | 16 +---------------
 .../queue/rabbitmq/RabbitMQMailQueueFactory.java    | 12 ++++++++++--
 2 files changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/15c7ebb7/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 1832dc2..9190922 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
@@ -19,17 +19,8 @@
 
 package org.apache.james.queue.rabbitmq;
 
-import java.time.Clock;
 import java.util.concurrent.TimeUnit;
-import java.util.function.Function;
 
-import javax.inject.Inject;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.james.blob.api.BlobId;
-import org.apache.james.blob.api.Store;
-import org.apache.james.blob.mail.MimeMessagePartsId;
-import org.apache.james.metrics.api.GaugeRegistry;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.queue.api.ManageableMailQueue;
 import org.apache.james.queue.rabbitmq.view.api.DeleteCondition;
@@ -39,7 +30,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.github.fge.lambdas.Throwing;
-import com.google.common.annotations.VisibleForTesting;
 
 public class RabbitMQMailQueue implements ManageableMailQueue {
 
@@ -47,22 +37,18 @@ public class RabbitMQMailQueue implements ManageableMailQueue {
 
     private final MailQueueName name;
     private final MetricFactory metricFactory;
-    private final GaugeRegistry gaugeRegistry;
     private final Enqueuer enqueuer;
     private final Dequeuer dequeuer;
     private final MailQueueView mailQueueView;
 
     RabbitMQMailQueue(MetricFactory metricFactory, MailQueueName name,
-                      GaugeRegistry gaugeRegistry, Enqueuer enqueuer, Dequeuer dequeuer,
+                      Enqueuer enqueuer, Dequeuer dequeuer,
                       MailQueueView mailQueueView) {
         this.metricFactory = metricFactory;
         this.name = name;
-        this.gaugeRegistry = gaugeRegistry;
         this.enqueuer = enqueuer;
         this.dequeuer = dequeuer;
         this.mailQueueView = mailQueueView;
-
-        this.gaugeRegistry.register(QUEUE_SIZE_METRIC_NAME_PREFIX + name.asString(), this::getSize);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/15c7ebb7/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueFactory.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueFactory.java
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueFactory.java
index da5a144..5d12302 100644
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueFactory.java
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueFactory.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.queue.rabbitmq;
 
+import static org.apache.james.queue.api.MailQueue.QUEUE_SIZE_METRIC_NAME_PREFIX;
+
 import java.time.Clock;
 import java.util.Optional;
 import java.util.Set;
@@ -74,15 +76,21 @@ public class RabbitMQMailQueueFactory implements MailQueueFactory<RabbitMQMailQu
         RabbitMQMailQueue create(MailQueueName mailQueueName) {
             mailQueueView.initialize(mailQueueName);
 
-            return new RabbitMQMailQueue(
+            RabbitMQMailQueue rabbitMQMailQueue = new RabbitMQMailQueue(
                 metricFactory,
                 mailQueueName,
-                gaugeRegistry,
                 new Enqueuer(mailQueueName, rabbitClient, mimeMessageStore, mailReferenceSerializer,
                     metricFactory, mailQueueView, clock),
                 new Dequeuer(mailQueueName, rabbitClient, mailLoader, mailReferenceSerializer,
                     metricFactory, mailQueueView),
                 mailQueueView);
+
+            registerGaugeFor(rabbitMQMailQueue);
+            return rabbitMQMailQueue;
+        }
+
+        private void registerGaugeFor(RabbitMQMailQueue rabbitMQMailQueue) {
+            this.gaugeRegistry.register(QUEUE_SIZE_METRIC_NAME_PREFIX + rabbitMQMailQueue.getName(),
rabbitMQMailQueue::getSize);
         }
     }
 


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