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 bt...@apache.org on 2020/03/23 02:29:35 UTC

[james-project] 03/08: JAMES-3121 Use TimeWindowCompationStrategy for Cassandra time serie tables (EnqueuedMail and DeletedMail)

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

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

commit 2638f0db9efb386d02bb33ec561d2dbb5b5c4c55
Author: Gautier DI FOLCO <gd...@linagora.com>
AuthorDate: Wed Mar 18 16:32:24 2020 +0100

    JAMES-3121 Use TimeWindowCompationStrategy for Cassandra time serie tables (EnqueuedMail and DeletedMail)
---
 .../view/cassandra/CassandraMailQueueViewModule.java         | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueViewModule.java b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueViewModule.java
index 6f109fd..cfade20 100644
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueViewModule.java
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueViewModule.java
@@ -26,12 +26,14 @@ import static com.datastax.driver.core.DataType.map;
 import static com.datastax.driver.core.DataType.text;
 import static com.datastax.driver.core.DataType.timestamp;
 import static com.datastax.driver.core.DataType.uuid;
+import static com.datastax.driver.core.schemabuilder.TableOptions.CompactionOptions.TimeWindowCompactionStrategyOptions.CompactionWindowUnit.HOURS;
 
 import org.apache.james.backends.cassandra.components.CassandraModule;
 
 import com.datastax.driver.core.CodecRegistry;
 import com.datastax.driver.core.ProtocolVersion;
 import com.datastax.driver.core.TupleType;
+import com.datastax.driver.core.schemabuilder.SchemaBuilder;
 
 public interface CassandraMailQueueViewModule {
 
@@ -84,7 +86,10 @@ public interface CassandraMailQueueViewModule {
             " when a mail is dequeued from a mail queue, the record associated with that mail still available in this" +
             " table and will not be deleted immediately regarding to the performance impacts," +
             " but after some scheduled tasks")
-        .options(options -> options)
+        .options(options -> options
+            .compactionOptions(SchemaBuilder.timeWindowCompactionStrategy()
+                .compactionWindowSize(1)
+                .compactionWindowUnit(HOURS)))
         .statement(statement -> statement
             .addPartitionKey(EnqueuedMailsTable.QUEUE_NAME, text())
             .addPartitionKey(EnqueuedMailsTable.TIME_RANGE_START, timestamp())
@@ -114,9 +119,10 @@ public interface CassandraMailQueueViewModule {
 
         .table(DeletedMailTable.TABLE_NAME)
         .comment("this table stores the dequeued mails, while browsing mail from table: "
-            + EnqueuedMailsTable.TABLE_NAME + " we need to filter out mails have been dequeued by checking their " +
+            + DeletedMailTable.TABLE_NAME + " we need to filter out mails have been dequeued by checking their " +
             "existence in this table")
-        .options(options -> options)
+        .options(options -> options
+            .compactionOptions(SchemaBuilder.timeWindowCompactionStrategy()))
         .statement(statement -> statement
             .addPartitionKey(DeletedMailTable.QUEUE_NAME, text())
             .addPartitionKey(DeletedMailTable.ENQUEUE_ID, uuid()))


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