james-server-dev mailing list archives

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

URL: http://svn.apache.org/r1685956
Log:
MAILBOX-227 Use Time Uuid for Uuid stored in cassandra - patch contributed by Matthieu Baechlor

Modified:
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java?rev=1685956&r1=1685955&r2=1685956&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java
(original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java
Wed Jun 17 09:02:34 2015
@@ -44,7 +44,7 @@ public class CassandraTableManager {
         Mailbox(CassandraMailboxTable.TABLE_NAME,
             SchemaBuilder.createTable(CassandraMailboxTable.TABLE_NAME)
                 .ifNotExists()
-                .addPartitionKey(CassandraMailboxTable.ID, uuid())
+                .addPartitionKey(CassandraMailboxTable.ID, timeuuid())
                 .addColumn(CassandraMailboxTable.NAMESPACE, text())
                 .addColumn(CassandraMailboxTable.USER, text())
                 .addColumn(CassandraMailboxTable.NAME, text())
@@ -53,19 +53,19 @@ public class CassandraTableManager {
         MailboxCounter(CassandraMailboxCountersTable.TABLE_NAME,
             SchemaBuilder.createTable(CassandraMailboxCountersTable.TABLE_NAME)
                 .ifNotExists()
-                .addPartitionKey(CassandraMailboxCountersTable.MAILBOX_ID, uuid())
+                .addPartitionKey(CassandraMailboxCountersTable.MAILBOX_ID, timeuuid())
                 .addColumn(CassandraMailboxCountersTable.COUNT, counter())
                 .addColumn(CassandraMailboxCountersTable.UNSEEN, counter())
                 .addColumn(CassandraMailboxCountersTable.NEXT_MOD_SEQ, counter())),
         MessageUid(CassandraMessageUidTable.TABLE_NAME,
             SchemaBuilder.createTable(CassandraMessageUidTable.TABLE_NAME)
                 .ifNotExists()
-                .addPartitionKey(CassandraMessageUidTable.MAILBOX_ID, uuid())
+                .addPartitionKey(CassandraMessageUidTable.MAILBOX_ID, timeuuid())
                 .addColumn(CassandraMessageUidTable.NEXT_UID, bigint())),
         Message(CassandraMessageTable.TABLE_NAME,
             SchemaBuilder.createTable(CassandraMessageTable.TABLE_NAME)
                 .ifNotExists()
-                .addPartitionKey(CassandraMessageTable.MAILBOX_ID, uuid())
+                .addPartitionKey(CassandraMessageTable.MAILBOX_ID, timeuuid())
                 .addClusteringColumn(CassandraMessageTable.IMAP_UID, bigint())
                 .addColumn(CassandraMessageTable.INTERNAL_DATE, timestamp())
                 .addColumn(CassandraMessageTable.BODY_START_OCTET, cint())
@@ -94,7 +94,7 @@ public class CassandraTableManager {
         Acl(CassandraACLTable.TABLE_NAME,
             SchemaBuilder.createTable(CassandraACLTable.TABLE_NAME)
                 .ifNotExists()
-                .addPartitionKey(CassandraACLTable.ID, uuid())
+                .addPartitionKey(CassandraACLTable.ID, timeuuid())
                 .addColumn(CassandraACLTable.ACL, text())
                 .addColumn(CassandraACLTable.VERSION, bigint())
         )

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java?rev=1685956&r1=1685955&r2=1685956&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
(original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
Wed Jun 17 09:02:34 2015
@@ -25,6 +25,7 @@ import static org.apache.james.mailbox.c
 import java.util.List;
 import java.util.UUID;
 
+import com.datastax.driver.core.utils.UUIDs;
 import com.google.common.base.Preconditions;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
@@ -94,7 +95,7 @@ public class CassandraMailboxMapper impl
         Preconditions.checkArgument(mailbox instanceof SimpleMailbox);
         SimpleMailbox<UUID> cassandraMailbox = (SimpleMailbox<UUID>) mailbox;
         if (cassandraMailbox.getMailboxId() == null) {
-            cassandraMailbox.setMailboxId(UUID.randomUUID());
+            cassandraMailbox.setMailboxId(UUIDs.timeBased());
         }
         upsertMailbox(cassandraMailbox);
     }

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java?rev=1685956&r1=1685955&r2=1685956&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
Wed Jun 17 09:02:34 2015
@@ -55,7 +55,7 @@ public class CassandraACLMapperTest {
         cassandra.ensureAllTables();
         uidValidity = 10;
         mailbox = new SimpleMailbox<>(new MailboxPath("#private", "benwa@linagora.com",
"INBOX"), uidValidity);
-        mailbox.setMailboxId(UUID.fromString("87B045A5-7657-44B7-81E8-40C2937BC9FE"));
+        mailbox.setMailboxId(UUID.fromString("464765a0-e4e7-11e4-aba4-710c1de3782b"));
         maxRetry = 100;
         cassandraACLMapper = new CassandraACLMapper(mailbox, cassandra.getConf(), maxRetry);
         executor = Executors.newFixedThreadPool(2);

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java?rev=1685956&r1=1685955&r2=1685956&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
Wed Jun 17 09:02:34 2015
@@ -1,5 +1,6 @@
 package org.apache.james.mailbox.cassandra.mail;
 
+import com.datastax.driver.core.utils.UUIDs;
 import org.apache.james.mailbox.cassandra.CassandraClusterSingleton;
 import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
 import org.apache.james.mailbox.exception.MailboxException;
@@ -34,7 +35,7 @@ public class CassandraMapperProvider imp
 
     @Override
     public UUID generateId() {
-        return UUID.randomUUID();
+        return UUIDs.timeBased();
     }
 
     @Override



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