james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1685965 - in /james/mailbox/trunk/cassandra/src: main/java/org/apache/james/mailbox/cassandra/mail/utils/FunctionRunnerWithRetry.java test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java
Date Wed, 17 Jun 2015 09:11:12 GMT
Author: btellier
Date: Wed Jun 17 09:11:12 2015
New Revision: 1685965

URL: http://svn.apache.org/r1685965
Log:
MAILBOX-209 generalise FunctionRunnerWithRetry - patch contributed by Matthieu Baechler

Modified:
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/utils/FunctionRunnerWithRetry.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/utils/FunctionRunnerWithRetry.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/utils/FunctionRunnerWithRetry.java?rev=1685965&r1=1685964&r2=1685965&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/utils/FunctionRunnerWithRetry.java
(original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/utils/FunctionRunnerWithRetry.java
Wed Jun 17 09:11:12 2015
@@ -26,11 +26,11 @@ import java.util.Optional;
 import java.util.function.BooleanSupplier;
 import java.util.stream.IntStream;
 
-public class FunctionRunnerWithRetry<Id> {
+public class FunctionRunnerWithRetry {
 
     @FunctionalInterface
-    public interface OptionalSupplier<Id> {
-        Optional<Id> getAsOptional();
+    public interface OptionalSupplier<T> {
+        Optional<T> getAsOptional();
     }
 
     private final int maxRetry;
@@ -47,7 +47,7 @@ public class FunctionRunnerWithRetry<Id>
             .orElseThrow(() -> new MailboxException("Can not execute Boolean Supplier."));
     }
 
-    public Id executeAndRetrieveObject(OptionalSupplier<Id> functionNotifyingSuccess)
throws MailboxException {
+    public <T> T executeAndRetrieveObject(OptionalSupplier<T> functionNotifyingSuccess)
throws MailboxException {
         return IntStream.range(0, maxRetry)
             .mapToObj((x) -> functionNotifyingSuccess.getAsOptional())
             .filter(Optional::isPresent)

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java?rev=1685965&r1=1685964&r2=1685965&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java
Wed Jun 17 09:11:12 2015
@@ -64,7 +64,7 @@ public final class CassandraClusterSingl
     private CassandraClusterSingleton() throws RuntimeException {
         try {
             EmbeddedCassandraServerHelper.startEmbeddedCassandra();
-            session = new FunctionRunnerWithRetry<Session>(MAX_RETRY)
+            session = new FunctionRunnerWithRetry(MAX_RETRY)
                 .executeAndRetrieveObject(CassandraClusterSingleton.this::tryInitializeSession);
             typesProvider = new CassandraTypesProvider(session);
         } catch(Exception exception) {



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