james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [1/5] james-project git commit: MAILBOX-267 enforce modseq uniqueness
Date Mon, 02 May 2016 08:28:49 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 8049cde24 -> 0395ee41b


MAILBOX-267 enforce modseq uniqueness

	It's not really possible to enforce modseq are monotonic,
	the only thing we can do is enforce uniqueness


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

Branch: refs/heads/master
Commit: 267f9c38e0cbd547561ebc2a7ec69f7d41fdfd49
Parents: 84be5d7
Author: Matthieu Baechler <matthieu.baechler@linagora.com>
Authored: Tue Apr 19 15:04:49 2016 +0200
Committer: Matthieu Baechler <matthieu.baechler@linagora.com>
Committed: Mon May 2 10:24:47 2016 +0200

----------------------------------------------------------------------
 .../mail/CassandraUidAndModSeqProviderTest.java   | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/267f9c38/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
index 6d094c4..d62d05e 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertEquals;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.LongStream;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
@@ -161,18 +160,15 @@ public class CassandraUidAndModSeqProviderTest {
     }
 
     @Test
-    public void nextModSeqShouldIncrementValueWhenParallelCalls() throws Exception {
+    public void nextModSeqShouldGenerateUniqueValuesWhenParallelCalls() throws Exception
{
         SimpleMailbox<CassandraId> mailbox = mailboxList.get(mailboxList.size() / 2);
-        long lastUid = modSeqProvider.highestModSeq(null, mailbox);
-        final AtomicLong previousValue = new AtomicLong();
-        LongStream.range(lastUid + 1, lastUid + 10)
+        int nbEntries = 1000;
+        long nbValues = LongStream.range(0, nbEntries)
             .parallel()
-            .forEach(Throwing.longConsumer(value -> {
-                        long result = modSeqProvider.nextModSeq(null, mailbox);
-                        assertThat(result).isGreaterThan(previousValue.get());
-                        previousValue.set(result);
-                })
-            );
+            .map(Throwing.longUnaryOperator(x -> modSeqProvider.nextModSeq(null, mailbox)))
+            .distinct()
+            .count();
+        assertThat(nbValues).isEqualTo(nbEntries);
     }
     
 }


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