JAMES-2082 Allow configuration of V1 to V2 migration low level parameters

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

Branch: refs/heads/master
Commit: 49cdfb50ea9a23611bff15a820c07340c1d3d829
Parents: eb55762
Author: benwa <btell...@linagora.com>
Authored: Fri Jul 7 10:12:27 2017 +0700
Committer: Antoine Duprat <adup...@linagora.com>
Committed: Mon Jul 10 14:23:57 2017 +0200

----------------------------------------------------------------------
 .../cassandra/CassandraConfiguration.java       | 74 ++++++++++++++++++--
 .../cassandra/CassandraConfigurationTest.java   | 57 +++++++++++++++
 .../destination/conf/cassandra.properties       |  5 +-
 .../destination/conf/cassandra.properties       |  5 +-
 .../mail/migration/V1ToV2Migration.java         | 11 ++-
 .../mail/migration/V1ToV2MigrationThread.java   |  9 ++-
 .../modules/mailbox/CassandraSessionModule.java |  9 +++
 .../mailbox/CassandraSessionModuleTest.java     |  3 +
 .../modules/mailbox/cassandra.properties        |  3 +
 src/site/xdoc/server/config-cassandra.xml       |  6 ++
 10 files changed, 166 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/CassandraConfiguration.java
----------------------------------------------------------------------
diff --git 
a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/CassandraConfiguration.java
 
b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/CassandraConfiguration.java
index 6ca8487..e125c1e 100644
--- 
a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/CassandraConfiguration.java
+++ 
b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/CassandraConfiguration.java
@@ -40,6 +40,9 @@ public class CassandraConfiguration {
     public static final int DEFAULT_FETCH_NEXT_PAGE_ADVANCE_IN_ROW = 100;
     public static final boolean DEFAULT_ON_THE_FLY_MIGRATION_V1_TO_V2 = false;
     public static final int DEFAULT_BLOB_PART_SIZE = 100 * 1024;
+    public static final int DEFAULT_MIGRATION_V1_TO_V2_QUEUE_LENGTH = 1000;
+    public static final int DEFAULT_MIGRATION_V1_TO_V2_THREAD_COUNT = 2;
+    public static final int DEFAULT_MIGRATION_V1_TO_V2_POLLING_DELAY = 10;
 
     public static class Builder {
         private Optional<Integer> messageReadChunkSize = Optional.empty();
@@ -53,6 +56,9 @@ public class CassandraConfiguration {
         private Optional<Integer> fetchNextPageInAdvanceRow = Optional.empty();
         private Optional<Integer> blobPartSize = Optional.empty();
         private Optional<Boolean> onTheFlyV1ToV2Migration = Optional.empty();
+        private Optional<Integer> v1ToV2QueueLength = Optional.empty();
+        private Optional<Integer> v1ToV2ThreadCount = Optional.empty();
+        private Optional<Integer> v1ToV2PollingDelay = Optional.empty();
 
         public Builder messageReadChunkSize(int value) {
             Preconditions.checkArgument(value > 0, "messageReadChunkSize needs 
to be strictly positive");
@@ -114,6 +120,24 @@ public class CassandraConfiguration {
             return this;
         }
 
+        public Builder v1ToV2QueueLength(int value) {
+            Preconditions.checkArgument(value > 0, "v1ToV2QueueLength needs to 
be strictly positive");
+            this.v1ToV2QueueLength = Optional.of(value);
+            return this;
+        }
+
+        public Builder v1ToV2ThreadCount(int value) {
+            Preconditions.checkArgument(value > 0, "v1ToV2ThreadCount needs to 
be strictly positive");
+            this.v1ToV2ThreadCount = Optional.of(value);
+            return this;
+        }
+
+        public Builder v1ToV2PollingDelay(int value) {
+            Preconditions.checkArgument(value > 0, "blobPartSize needs to be 
strictly positive");
+            this.v1ToV2PollingDelay = Optional.of(value);
+            return this;
+        }
+
         public Builder onTheFlyV1ToV2Migration(boolean value) {
             this.onTheFlyV1ToV2Migration = Optional.of(value);
             return this;
@@ -174,6 +198,21 @@ public class CassandraConfiguration {
             return this;
         }
 
+        public Builder v1ToV2QueueLength(Optional<Integer> value) {
+            value.ifPresent(this::v1ToV2QueueLength);
+            return this;
+        }
+
+        public Builder v1ToV2ThreadCount(Optional<Integer> value) {
+            value.ifPresent(this::v1ToV2ThreadCount);
+            return this;
+        }
+
+        public Builder v1ToV2PollingDelay(Optional<Integer> value) {
+            value.ifPresent(this::v1ToV2PollingDelay);
+            return this;
+        }
+
         public CassandraConfiguration build() {
             return new 
CassandraConfiguration(aclMaxRetry.orElse(DEFAULT_ACL_MAX_RETRY),
                 
messageReadChunkSize.orElse(DEFAULT_MESSAGE_CHUNK_SIZE_ON_READ),
@@ -185,7 +224,10 @@ public class CassandraConfiguration {
                 uidMaxRetry.orElse(DEFAULT_UID_MAX_RETRY),
                 
fetchNextPageInAdvanceRow.orElse(DEFAULT_FETCH_NEXT_PAGE_ADVANCE_IN_ROW),
                 blobPartSize.orElse(DEFAULT_BLOB_PART_SIZE),
-                
onTheFlyV1ToV2Migration.orElse(DEFAULT_ON_THE_FLY_MIGRATION_V1_TO_V2));
+                
onTheFlyV1ToV2Migration.orElse(DEFAULT_ON_THE_FLY_MIGRATION_V1_TO_V2),
+                
v1ToV2QueueLength.orElse(DEFAULT_MIGRATION_V1_TO_V2_QUEUE_LENGTH),
+                
v1ToV2ThreadCount.orElse(DEFAULT_MIGRATION_V1_TO_V2_THREAD_COUNT),
+                
v1ToV2PollingDelay.orElse(DEFAULT_MIGRATION_V1_TO_V2_POLLING_DELAY));
         }
     }
 
@@ -204,11 +246,14 @@ public class CassandraConfiguration {
     private final int fetchNextPageInAdvanceRow;
     private final int blobPartSize;
     private final boolean onTheFlyV1ToV2Migration;
+    private final int v1ToV2QueueLength;
+    private final int v1ToV2ThreadCount;
+    private final int v1ToV2PollingDelay;
 
     @VisibleForTesting
     CassandraConfiguration(int aclMaxRetry, int messageReadChunkSize, int 
expungeChunkSize, int flagsUpdateChunkSize,
                            int flagsUpdateMessageIdMaxRetry, int 
flagsUpdateMessageMaxRetry, int modSeqMaxRetry,
-                           int uidMaxRetry, int fetchNextPageInAdvanceRow, int 
blobPartSize, boolean onTheFlyV1ToV2Migration) {
+                           int uidMaxRetry, int fetchNextPageInAdvanceRow, int 
blobPartSize, boolean onTheFlyV1ToV2Migration, int v1ToV2QueueLength, int 
v1ToV2ThreadCount, int v1ToV2PollingDelay) {
         this.aclMaxRetry = aclMaxRetry;
         this.messageReadChunkSize = messageReadChunkSize;
         this.expungeChunkSize = expungeChunkSize;
@@ -220,6 +265,9 @@ public class CassandraConfiguration {
         this.flagsUpdateChunkSize = flagsUpdateChunkSize;
         this.blobPartSize = blobPartSize;
         this.onTheFlyV1ToV2Migration = onTheFlyV1ToV2Migration;
+        this.v1ToV2QueueLength = v1ToV2QueueLength;
+        this.v1ToV2ThreadCount = v1ToV2ThreadCount;
+        this.v1ToV2PollingDelay = v1ToV2PollingDelay;
     }
 
     public int getBlobPartSize() {
@@ -266,6 +314,18 @@ public class CassandraConfiguration {
         return fetchNextPageInAdvanceRow;
     }
 
+    public int getV1ToV2QueueLength() {
+        return v1ToV2QueueLength;
+    }
+
+    public int getV1ToV2ThreadCount() {
+        return v1ToV2ThreadCount;
+    }
+
+    public int getV1ToV2PollingDelay() {
+        return v1ToV2PollingDelay;
+    }
+
     @Override
     public final boolean equals(Object o) {
         if (o instanceof CassandraConfiguration) {
@@ -281,7 +341,10 @@ public class CassandraConfiguration {
                 && Objects.equals(this.flagsUpdateChunkSize, 
that.flagsUpdateChunkSize)
                 && Objects.equals(this.fetchNextPageInAdvanceRow, 
that.fetchNextPageInAdvanceRow)
                 && Objects.equals(this.blobPartSize, that.blobPartSize)
-                && Objects.equals(this.onTheFlyV1ToV2Migration, 
that.onTheFlyV1ToV2Migration);
+                && Objects.equals(this.onTheFlyV1ToV2Migration, 
that.onTheFlyV1ToV2Migration)
+                && Objects.equals(this.v1ToV2ThreadCount, 
that.v1ToV2ThreadCount)
+                && Objects.equals(this.v1ToV2QueueLength, 
that.v1ToV2QueueLength)
+                && Objects.equals(this.v1ToV2PollingDelay, 
that.v1ToV2PollingDelay);
         }
         return false;
     }
@@ -290,7 +353,7 @@ public class CassandraConfiguration {
     public final int hashCode() {
         return Objects.hash(aclMaxRetry, messageReadChunkSize, 
expungeChunkSize, flagsUpdateMessageIdMaxRetry,
             flagsUpdateMessageMaxRetry, modSeqMaxRetry, uidMaxRetry, 
fetchNextPageInAdvanceRow, flagsUpdateChunkSize,
-            blobPartSize, onTheFlyV1ToV2Migration);
+            blobPartSize, onTheFlyV1ToV2Migration, v1ToV2ThreadCount, 
v1ToV2QueueLength, v1ToV2PollingDelay);
     }
 
     @Override
@@ -307,6 +370,9 @@ public class CassandraConfiguration {
             .add("uidMaxRetry", uidMaxRetry)
             .add("blobPartSize", blobPartSize)
             .add("onTheFlyV1ToV2Migration", onTheFlyV1ToV2Migration)
+            .add("v1ToV2ThreadCount", v1ToV2ThreadCount)
+            .add("v1ToV2QueueLength", v1ToV2QueueLength)
+            .add("v1ToV2PollingDelay", v1ToV2PollingDelay)
             .toString();
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraConfigurationTest.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraConfigurationTest.java
index e0cc667..cd705f2 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraConfigurationTest.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/CassandraConfigurationTest.java
@@ -192,6 +192,54 @@ public class CassandraConfigurationTest {
     }
 
     @Test
+    public void v1toV2ThreadCountShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .v1ToV2ThreadCount(0);
+    }
+
+    @Test
+    public void v1toV2ThreadCountShouldThrowOnNegative() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .v1ToV2ThreadCount(-1);
+    }
+
+    @Test
+    public void v1toV2QueueLengthShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .v1ToV2QueueLength(0);
+    }
+
+    @Test
+    public void v1toV2QueueLengthShouldThrowOnNegative() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .v1ToV2QueueLength(-1);
+    }
+
+    @Test
+    public void v1toV2PollingDelayShouldThrowOnZero() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .v1ToV2PollingDelay(0);
+    }
+
+    @Test
+    public void v1toV2PollingDelayShouldThrowOnNegative() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        CassandraConfiguration.builder()
+            .v1ToV2PollingDelay(-1);
+    }
+
+    @Test
     public void builderShouldCreateTheRightObject() {
         int aclMaxRetry = 1;
         int modSeqMaxRetry = 2;
@@ -204,6 +252,9 @@ public class CassandraConfigurationTest {
         int expungeChunkSize = 9;
         int blobPartSize = 10;
         boolean onTheFlyV1ToV2Migration = true;
+        int v1ToV2ThreadCount = 11;
+        int v1ToV2QueueLength = 12;
+        int v1ToV2PollingDelay = 13;
 
         CassandraConfiguration configuration = CassandraConfiguration.builder()
             .aclMaxRetry(aclMaxRetry)
@@ -217,6 +268,9 @@ public class CassandraConfigurationTest {
             .expungeChunkSize(expungeChunkSize)
             .blobPartSize(blobPartSize)
             .onTheFlyV1ToV2Migration(onTheFlyV1ToV2Migration)
+            .v1ToV2ThreadCount(v1ToV2ThreadCount)
+            .v1ToV2QueueLength(v1ToV2QueueLength)
+            .v1ToV2PollingDelay(v1ToV2PollingDelay)
             .build();
 
         
softly.assertThat(configuration.getAclMaxRetry()).isEqualTo(aclMaxRetry);
@@ -230,6 +284,9 @@ public class CassandraConfigurationTest {
         
softly.assertThat(configuration.getExpungeChunkSize()).isEqualTo(expungeChunkSize);
         
softly.assertThat(configuration.getBlobPartSize()).isEqualTo(blobPartSize);
         
softly.assertThat(configuration.isOnTheFlyV1ToV2Migration()).isEqualTo(onTheFlyV1ToV2Migration);
+        
softly.assertThat(configuration.getV1ToV2ThreadCount()).isEqualTo(v1ToV2ThreadCount);
+        
softly.assertThat(configuration.getV1ToV2QueueLength()).isEqualTo(v1ToV2QueueLength);
+        
softly.assertThat(configuration.getV1ToV2PollingDelay()).isEqualTo(v1ToV2PollingDelay);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/dockerfiles/run/guice/cassandra-ldap/destination/conf/cassandra.properties
----------------------------------------------------------------------
diff --git 
a/dockerfiles/run/guice/cassandra-ldap/destination/conf/cassandra.properties 
b/dockerfiles/run/guice/cassandra-ldap/destination/conf/cassandra.properties
index 54c9900..87768f7 100644
--- a/dockerfiles/run/guice/cassandra-ldap/destination/conf/cassandra.properties
+++ b/dockerfiles/run/guice/cassandra-ldap/destination/conf/cassandra.properties
@@ -18,4 +18,7 @@ cassandra.retryConnection.minDelay=5000
 # chunk.size.message.read=100
 # chunk.size.expunge=100
 # mailbox.blob.part.size=102400
-# migration.v1.v2.on.the.fly=false
\ No newline at end of file
+# migration.v1.v2.on.the.fly=false
+# migration.v1.v2.thread.count=2
+# migration.v1.v2.queue.length=1000
+# migration.v1.v2.polling.delay.in.ms=10
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/dockerfiles/run/guice/cassandra/destination/conf/cassandra.properties
----------------------------------------------------------------------
diff --git 
a/dockerfiles/run/guice/cassandra/destination/conf/cassandra.properties 
b/dockerfiles/run/guice/cassandra/destination/conf/cassandra.properties
index 710674e..5ecf606 100644
--- a/dockerfiles/run/guice/cassandra/destination/conf/cassandra.properties
+++ b/dockerfiles/run/guice/cassandra/destination/conf/cassandra.properties
@@ -27,4 +27,7 @@ cassandra.retryConnection.minDelay=5000
 # chunk.size.message.read=100
 # chunk.size.expunge=100
 # mailbox.blob.part.size=102400
-# migration.v1.v2.on.the.fly=false
\ No newline at end of file
+# migration.v1.v2.on.the.fly=false
+# migration.v1.v2.thread.count=2
+# migration.v1.v2.queue.length=1000
+# migration.v1.v2.polling.delay.in.ms=10
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2Migration.java
----------------------------------------------------------------------
diff --git 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2Migration.java
 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2Migration.java
index 131addb..73e1562 100644
--- 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2Migration.java
+++ 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2Migration.java
@@ -43,9 +43,6 @@ import com.google.common.collect.EvictingQueue;
 import com.google.common.collect.ImmutableList;
 
 public class V1ToV2Migration {
-    private static final int MIGRATION_THREAD_COUNT = 2;
-    private static final int MIGRATION_QUEUE_LENGTH = 1000;
-
     private final CassandraMessageDAO messageDAOV1;
     private final AttachmentLoader attachmentLoader;
     private final CassandraConfiguration cassandraConfiguration;
@@ -58,10 +55,10 @@ public class V1ToV2Migration {
         this.messageDAOV1 = messageDAOV1;
         this.attachmentLoader = new AttachmentLoader(attachmentMapper);
         this.cassandraConfiguration = cassandraConfiguration;
-        this.migrationExecutor = 
Executors.newFixedThreadPool(MIGRATION_THREAD_COUNT);
-        this.messagesToBeMigrated = 
EvictingQueue.create(MIGRATION_QUEUE_LENGTH);
-        IntStream.range(0, MIGRATION_THREAD_COUNT)
-            .mapToObj(i -> new V1ToV2MigrationThread(messagesToBeMigrated, 
messageDAOV1, messageDAOV2, attachmentLoader))
+        this.migrationExecutor = 
Executors.newFixedThreadPool(cassandraConfiguration.getV1ToV2ThreadCount());
+        this.messagesToBeMigrated = 
EvictingQueue.create(cassandraConfiguration.getV1ToV2QueueLength());
+        IntStream.range(0, cassandraConfiguration.getV1ToV2ThreadCount())
+            .mapToObj(i -> new V1ToV2MigrationThread(messagesToBeMigrated, 
messageDAOV1, messageDAOV2, attachmentLoader, cassandraConfiguration))
             .forEach(migrationExecutor::execute);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2MigrationThread.java
----------------------------------------------------------------------
diff --git 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2MigrationThread.java
 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2MigrationThread.java
index acac3a3..b4a5b1b 100644
--- 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2MigrationThread.java
+++ 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/V1ToV2MigrationThread.java
@@ -24,6 +24,7 @@ import java.util.concurrent.CompletableFuture;
 import java.util.stream.Stream;
 
 import org.apache.commons.lang3.tuple.Pair;
+import org.apache.james.backends.cassandra.CassandraConfiguration;
 import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
 import org.apache.james.mailbox.cassandra.mail.AttachmentLoader;
 import org.apache.james.mailbox.cassandra.mail.CassandraMessageDAO;
@@ -42,19 +43,21 @@ import com.google.common.collect.EvictingQueue;
 public class V1ToV2MigrationThread implements Runnable {
 
     private static final Logger LOGGER = 
LoggerFactory.getLogger(V1ToV2MigrationThread.class);
-    public static final int POLL_INTERVAL_IN_MS = 10;
 
     private final EvictingQueue<Pair<MessageWithoutAttachment, 
Stream<MessageAttachmentRepresentation>>> messagesToBeMigrated;
     private final CassandraMessageDAO messageDAOV1;
     private final CassandraMessageDAOV2 messageDAOV2;
     private final AttachmentLoader attachmentLoader;
+    private final CassandraConfiguration cassandraConfiguration;
 
     public V1ToV2MigrationThread(EvictingQueue<Pair<MessageWithoutAttachment, 
Stream<MessageAttachmentRepresentation>>> messagesToBeMigrated,
-                                 CassandraMessageDAO messageDAOV1, 
CassandraMessageDAOV2 messageDAOV2, AttachmentLoader attachmentLoader) {
+                                 CassandraMessageDAO messageDAOV1, 
CassandraMessageDAOV2 messageDAOV2, AttachmentLoader attachmentLoader,
+                                 CassandraConfiguration 
cassandraConfiguration) {
         this.messagesToBeMigrated = messagesToBeMigrated;
         this.messageDAOV1 = messageDAOV1;
         this.messageDAOV2 = messageDAOV2;
         this.attachmentLoader = attachmentLoader;
+        this.cassandraConfiguration = cassandraConfiguration;
     }
 
     @Override
@@ -76,7 +79,7 @@ public class V1ToV2MigrationThread implements Runnable {
                 return poll.get();
             }
             try {
-                Thread.sleep(POLL_INTERVAL_IN_MS);
+                Thread.sleep(cassandraConfiguration.getV1ToV2PollingDelay());
             } catch (InterruptedException e) {
                 Throwables.propagate(e);
             }

http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
index 037b04b..62ba82f 100644
--- 
a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
+++ 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraSessionModule.java
@@ -88,6 +88,9 @@ public class CassandraSessionModule extends AbstractModule {
     private static final String CHUNK_SIZE_EXPUNGE = "chunk.size.expunge";
     private static final String BLOB_PART_SIZE = "mailbox.blob.part.size";
     private static final String MIGRATION_V1_V2_ON_THE_FLY = 
"migration.v1.v2.on.the.fly";
+    private static final String MIGRATION_V1_V2_THREAD_COUNT = 
"migration.v1.v2.thread.count";
+    private static final String MIGRATION_V1_V2_QUEUE_LENGTH = 
"migration.v1.v2.queue.length";
+    private static final String MIGRATION_V1_V2_POLLING_DELAY = 
"migration.v1.v2.polling.delay.in.ms";
 
     @Override
     protected void configure() {
@@ -283,6 +286,12 @@ public class CassandraSessionModule extends AbstractModule 
{
                 propertiesConfiguration.getInteger(BLOB_PART_SIZE, null)))
             .onTheFlyV1ToV2Migration(Optional.ofNullable(
                 propertiesConfiguration.getBoolean(MIGRATION_V1_V2_ON_THE_FLY, 
null)))
+            .v1ToV2ThreadCount(Optional.ofNullable(
+                
propertiesConfiguration.getInteger(MIGRATION_V1_V2_THREAD_COUNT, null)))
+            .v1ToV2QueueLength(Optional.ofNullable(
+                
propertiesConfiguration.getInteger(MIGRATION_V1_V2_QUEUE_LENGTH, null)))
+            .v1ToV2PollingDelay(Optional.ofNullable(
+                
propertiesConfiguration.getInteger(MIGRATION_V1_V2_POLLING_DELAY, null)))
             .build();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java
 
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java
index 10a0398..aabfd17 100644
--- 
a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java
+++ 
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/CassandraSessionModuleTest.java
@@ -61,6 +61,9 @@ public class CassandraSessionModuleTest {
                 .expungeChunkSize(9)
                 .blobPartSize(10)
                 .onTheFlyV1ToV2Migration(true)
+                .v1ToV2ThreadCount(11)
+                .v1ToV2QueueLength(12)
+                .v1ToV2PollingDelay(13)
                 .build());
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/server/container/guice/cassandra-guice/src/test/resources/modules/mailbox/cassandra.properties
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-guice/src/test/resources/modules/mailbox/cassandra.properties
 
b/server/container/guice/cassandra-guice/src/test/resources/modules/mailbox/cassandra.properties
index e420c68..f1f50cb 100644
--- 
a/server/container/guice/cassandra-guice/src/test/resources/modules/mailbox/cassandra.properties
+++ 
b/server/container/guice/cassandra-guice/src/test/resources/modules/mailbox/cassandra.properties
@@ -9,3 +9,6 @@ chunk.size.message.read=8
 chunk.size.expunge=9
 mailbox.blob.part.size=10
 migration.v1.v2.on.the.fly=true
+migration.v1.v2.thread.count=11
+migration.v1.v2.queue.length=12
+migration.v1.v2.polling.delay.in.ms=13

http://git-wip-us.apache.org/repos/asf/james-project/blob/49cdfb50/src/site/xdoc/server/config-cassandra.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-cassandra.xml 
b/src/site/xdoc/server/config-cassandra.xml
index 4006387..ced7a96 100644
--- a/src/site/xdoc/server/config-cassandra.xml
+++ b/src/site/xdoc/server/config-cassandra.xml
@@ -115,6 +115,12 @@
         <dd>Optional. Defaults to 102400 (100KB).<br/> Controls the size of 
blob parts used to store messages.</dd>
         <dt><strong>migration.v1.v2.on.the.fly</strong></dt>
         <dd>Optional. Defaults to false.<br/> Controls wether v1 to v2 
migration should be run on the fly.</dd>
+        <dt><strong>migration.v1.v2.thread.count</strong></dt>
+        <dd>Optional. Defaults to 2.<br/> Controls the number of threads used 
to asynchronously migrate from v1 to v2.</dd>
+        <dt><strong>migration.v1.v2.queue.length</strong></dt>
+        <dd>Optional. Defaults to 1000.<br/> Controls the queue size of v1 to 
v2 migration task. Drops when full.</dd>
+        <dt><strong>migration.v1.v2.polling.delay.in.ms</strong></dt>
+        <dd>Optional. Defaults to 10.<br/> Controls the polling delay for v1 
to v2 migration threads.</dd>
       </dl>
 
 


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

Reply via email to