You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2019/06/24 09:09:45 UTC

[james-project] branch master updated (41ddd3b -> f5bd2b3)

This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.


    from 41ddd3b  Merge remote-tracking branch 'mbaechler/JAMES-2800-missing-singleton'
     new fa54f12  JAMES-2801 use elastic Scheduler by default for retry and delay
     new ad257a2  Merge remote-tracking branch 'mbaechler/retry-should-not-use-parallel'
     new e42b089  JAMES-2804 close cassandra cluster after each @Nested test class
     new f5bd2b3  Merge remote-tracking branch 'mbaechler/close-cluster-after-tests'

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../rabbitmq/RabbitMQConnectionFactory.java        |  4 +--
 .../james/backend/rabbitmq/SimpleChannelPool.java  |  4 +--
 .../backend/rabbitmq/SimpleConnectionPool.java     |  4 +--
 .../cassandra/mail/CassandraModSeqProvider.java    |  4 ++-
 .../mailbox/events/delivery/EventDelivery.java     |  5 ++--
 .../james/mailbox/events/WaitDelayGenerator.java   |  3 +-
 .../modules/mailbox/ElasticSearchClientModule.java |  3 +-
 .../modules/mailbox/ResilientClusterProvider.java  |  3 +-
 ...aMailRepositoryWithFakeImplementationsTest.java | 33 ++++++++++++++--------
 9 files changed, 39 insertions(+), 24 deletions(-)


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


[james-project] 01/04: JAMES-2801 use elastic Scheduler by default for retry and delay

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit fa54f12fea2d7390419baa813f47ed6bcfa62f0f
Author: Matthieu Baechler <ma...@apache.org>
AuthorDate: Thu Jun 20 17:23:24 2019 +0200

    JAMES-2801 use elastic Scheduler by default for retry and delay
---
 .../org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java | 4 ++--
 .../java/org/apache/james/backend/rabbitmq/SimpleChannelPool.java    | 4 ++--
 .../java/org/apache/james/backend/rabbitmq/SimpleConnectionPool.java | 4 ++--
 .../apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java | 4 +++-
 .../java/org/apache/james/mailbox/events/delivery/EventDelivery.java | 5 +++--
 .../java/org/apache/james/mailbox/events/WaitDelayGenerator.java     | 3 ++-
 .../org/apache/james/modules/mailbox/ElasticSearchClientModule.java  | 3 ++-
 .../org/apache/james/modules/mailbox/ResilientClusterProvider.java   | 3 ++-
 8 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
index 4c67175..d733914 100644
--- a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
+++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
@@ -58,8 +58,8 @@ public class RabbitMQConnectionFactory {
     }
 
     Mono<Connection> connectionMono() {
+        Duration forever = Duration.ofMillis(Long.MAX_VALUE);
         return Mono.fromCallable(connectionFactory::newConnection)
-            .retryBackoff(configuration.getMaxRetries(), Duration.ofMillis(configuration.getMinDelayInMs()))
-            .publishOn(Schedulers.elastic());
+            .retryBackoff(configuration.getMaxRetries(), Duration.ofMillis(configuration.getMinDelayInMs()), forever, Schedulers.elastic());
     }
 }
diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/SimpleChannelPool.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/SimpleChannelPool.java
index 2a7da85..16a8a7f 100644
--- a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/SimpleChannelPool.java
+++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/SimpleChannelPool.java
@@ -85,9 +85,9 @@ public class SimpleChannelPool implements RabbitMQChannelPool {
     private Mono<Channel> getResilientChannel() {
         int numRetries = 100;
         Duration initialDelay = Duration.ofMillis(100);
+        Duration forever = Duration.ofMillis(Long.MAX_VALUE);
         return Mono.defer(this::getOpenChannel)
-            .publishOn(Schedulers.elastic())
-            .retryBackoff(numRetries, initialDelay);
+            .retryBackoff(numRetries, initialDelay, forever, Schedulers.elastic());
     }
 
     private Mono<Channel> getOpenChannel() {
diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/SimpleConnectionPool.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/SimpleConnectionPool.java
index 519c1fa..5f07719 100644
--- a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/SimpleConnectionPool.java
+++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/SimpleConnectionPool.java
@@ -55,9 +55,9 @@ public class SimpleConnectionPool implements AutoCloseable {
     public Mono<Connection> getResilientConnection() {
         int numRetries = 100;
         Duration initialDelay = Duration.ofMillis(100);
+        Duration forever = Duration.ofMillis(Long.MAX_VALUE);
         return Mono.defer(this::getOpenConnection)
-            .subscribeOn(Schedulers.elastic())
-            .retryBackoff(numRetries, initialDelay);
+            .retryBackoff(numRetries, initialDelay, forever, Schedulers.elastic());
     }
 
     private Mono<Connection> getOpenConnection() {
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
index c173392..02a7adc 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
@@ -51,6 +51,7 @@ import com.datastax.driver.core.Session;
 import com.google.common.base.MoreObjects;
 
 import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
 
 public class CassandraModSeqProvider implements ModSeqProvider {
 
@@ -186,9 +187,10 @@ public class CassandraModSeqProvider implements ModSeqProvider {
     }
 
     private Mono<ModSeq> handleRetries(CassandraId mailboxId) {
+        Duration forever = Duration.ofMillis(Long.MAX_VALUE);
         return tryFindThenUpdateOnce(mailboxId)
             .single()
-            .retryBackoff(maxModSeqRetries, Duration.ofMillis(2));
+            .retryBackoff(maxModSeqRetries, Duration.ofMillis(2), forever, Schedulers.elastic());
     }
 
     private Mono<ModSeq> tryFindThenUpdateOnce(CassandraId mailboxId) {
diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java
index e7fbcc1..7b2fb67 100644
--- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java
@@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory;
 
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
 
 public interface EventDelivery {
 
@@ -75,7 +76,7 @@ public interface EventDelivery {
             }
 
             private static final Logger LOGGER = LoggerFactory.getLogger(BackoffRetryer.class);
-            private static final Duration MAX_BACKOFF = Duration.ofMillis(Long.MAX_VALUE);
+            private static final Duration FOREVER = Duration.ofMillis(Long.MAX_VALUE);
 
             private final RetryBackoffConfiguration retryBackoff;
             private final MailboxListener mailboxListener;
@@ -88,7 +89,7 @@ public interface EventDelivery {
             @Override
             public Mono<Void> doRetry(Mono<Void> executionResult, Event event) {
                 return executionResult
-                    .retryBackoff(retryBackoff.getMaxRetries(), retryBackoff.getFirstBackoff(), MAX_BACKOFF, retryBackoff.getJitterFactor())
+                    .retryBackoff(retryBackoff.getMaxRetries(), retryBackoff.getFirstBackoff(), FOREVER, retryBackoff.getJitterFactor(), Schedulers.elastic())
                     .doOnError(throwable -> LOGGER.error("listener {} exceeded maximum retry({}) to handle event {}",
                         mailboxListener.getClass().getCanonicalName(),
                         retryBackoff.getMaxRetries(),
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/WaitDelayGenerator.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/WaitDelayGenerator.java
index 93a20df..ff0378b 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/WaitDelayGenerator.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/WaitDelayGenerator.java
@@ -26,6 +26,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 
 import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
 
 class WaitDelayGenerator {
 
@@ -56,7 +57,7 @@ class WaitDelayGenerator {
         }
 
         return countRetryMono
-            .delayElement(generateDelay(retryCount));
+            .delayElement(generateDelay(retryCount), Schedulers.elastic());
     }
 
     @VisibleForTesting
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchClientModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchClientModule.java
index 96350a1..e485fee 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchClientModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchClientModule.java
@@ -50,10 +50,11 @@ public class ElasticSearchClientModule extends AbstractModule {
     @Singleton
     protected RestHighLevelClient provideClient(ElasticSearchConfiguration configuration) {
         Duration waitDelay = Duration.ofMillis(configuration.getMinDelay());
+        Duration forever = Duration.ofMillis(Long.MAX_VALUE);
         return Mono.fromCallable(() -> connectToCluster(configuration))
             .doOnError(e -> LOGGER.warn("Error establishing ElasticSearch connection. Next retry scheduled in {}",
                 DurationFormatUtils.formatDurationWords(waitDelay.toMillis(), true, true), e))
-            .retryBackoff(configuration.getMaxRetries(), waitDelay, waitDelay)
+            .retryBackoff(configuration.getMaxRetries(), waitDelay, forever, Schedulers.elastic())
             .publishOn(Schedulers.elastic())
             .block();
     }
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
index 9ed14c2..5259233 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ResilientClusterProvider.java
@@ -49,9 +49,10 @@ public class ResilientClusterProvider implements Provider<Cluster> {
     @Inject
     private ResilientClusterProvider(ClusterConfiguration configuration) {
         Duration waitDelay = Duration.ofMillis(configuration.getMinDelay());
+        Duration forever = Duration.ofMillis(Long.MAX_VALUE);
         cluster = Mono.fromCallable(getClusterRetryCallable(configuration))
             .doOnError(e -> LOGGER.warn("Error establishing Cassandra connection. Next retry scheduled in {} ms", waitDelay, e))
-            .retryBackoff(configuration.getMaxRetry(), waitDelay, waitDelay)
+            .retryBackoff(configuration.getMaxRetry(), waitDelay, forever, Schedulers.elastic())
             .publishOn(Schedulers.elastic())
             .block();
     }


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


[james-project] 03/04: Merge remote-tracking branch 'mbaechler/retry-should-not-use-parallel'

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit ad257a251fa293497a6c94cb051226452a662575
Merge: 41ddd3b fa54f12
Author: Raphael Ouazana <ra...@linagora.com>
AuthorDate: Mon Jun 24 11:08:59 2019 +0200

    Merge remote-tracking branch 'mbaechler/retry-should-not-use-parallel'

 .../org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java | 4 ++--
 .../java/org/apache/james/backend/rabbitmq/SimpleChannelPool.java    | 4 ++--
 .../java/org/apache/james/backend/rabbitmq/SimpleConnectionPool.java | 4 ++--
 .../apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java | 4 +++-
 .../java/org/apache/james/mailbox/events/delivery/EventDelivery.java | 5 +++--
 .../java/org/apache/james/mailbox/events/WaitDelayGenerator.java     | 3 ++-
 .../org/apache/james/modules/mailbox/ElasticSearchClientModule.java  | 3 ++-
 .../org/apache/james/modules/mailbox/ResilientClusterProvider.java   | 3 ++-
 8 files changed, 18 insertions(+), 12 deletions(-)


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


[james-project] 04/04: Merge remote-tracking branch 'mbaechler/close-cluster-after-tests'

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit f5bd2b3356cc3f97c27c102787f25884af0c3912
Merge: ad257a2 e42b089
Author: Raphael Ouazana <ra...@linagora.com>
AuthorDate: Mon Jun 24 11:09:13 2019 +0200

    Merge remote-tracking branch 'mbaechler/close-cluster-after-tests'

 ...aMailRepositoryWithFakeImplementationsTest.java | 33 ++++++++++++++--------
 1 file changed, 21 insertions(+), 12 deletions(-)


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


[james-project] 02/04: JAMES-2804 close cassandra cluster after each @Nested test class

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit e42b089da53cc0e64c8635c19259555976cb7e0e
Author: Matthieu Baechler <ma...@apache.org>
AuthorDate: Fri Jun 21 17:10:59 2019 +0200

    JAMES-2804 close cassandra cluster after each @Nested test class
---
 ...aMailRepositoryWithFakeImplementationsTest.java | 33 ++++++++++++++--------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryWithFakeImplementationsTest.java b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryWithFakeImplementationsTest.java
index cc469d0..2ff4af2 100644
--- a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryWithFakeImplementationsTest.java
+++ b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryWithFakeImplementationsTest.java
@@ -48,33 +48,34 @@ import org.apache.mailet.Mail;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Session;
 import reactor.core.publisher.Mono;
 
-@ExtendWith(CassandraMailRepositoryWithFakeImplementationsTest.MailRepositoryCassandraClusterExtension.class)
+
 class CassandraMailRepositoryWithFakeImplementationsTest {
     private static final MailRepositoryUrl URL = MailRepositoryUrl.from("proto://url");
     private static final HashBlobId.Factory BLOB_ID_FACTORY = new HashBlobId.Factory();
 
-    static class MailRepositoryCassandraClusterExtension extends CassandraClusterExtension {
-        public MailRepositoryCassandraClusterExtension() {
-            super(CassandraModule.aggregateModules(
-                    CassandraMailRepositoryModule.MODULE,
-                    CassandraBlobModule.MODULE,
-                    CassandraSchemaVersionModule.MODULE));
-        }
-
-        @Override
-        public void afterAll(ExtensionContext extensionContext) {
-        }
+    static CassandraClusterExtension extension() {
+        return new CassandraClusterExtension(
+            CassandraModule.aggregateModules(
+                CassandraMailRepositoryModule.MODULE,
+                CassandraBlobModule.MODULE,
+                CassandraSchemaVersionModule.MODULE));
     }
 
     @Nested
+    @TestInstance(TestInstance.Lifecycle.PER_CLASS)
     class FailingStoreTest {
+        @RegisterExtension
+        CassandraClusterExtension extension = extension();
+
         CassandraMailRepository cassandraMailRepository;
         CassandraMailRepositoryKeysDAO keysDAO;
 
@@ -124,7 +125,11 @@ class CassandraMailRepositoryWithFakeImplementationsTest {
     }
 
     @Nested
+    @TestInstance(TestInstance.Lifecycle.PER_CLASS)
     class FailingMailDaoTest {
+        @RegisterExtension
+        CassandraClusterExtension extension = extension();
+
         CassandraMailRepository cassandraMailRepository;
         CassandraMailRepositoryKeysDAO keysDAO;
 
@@ -209,7 +214,11 @@ class CassandraMailRepositoryWithFakeImplementationsTest {
     }
 
     @Nested
+    @TestInstance(TestInstance.Lifecycle.PER_CLASS)
     class FailingKeysDaoTest {
+        @RegisterExtension
+        CassandraClusterExtension extension = extension();
+
         CassandraMailRepository cassandraMailRepository;
         CassandraMailRepositoryCountDAO countDAO;
 


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