Repository: cassandra Updated Branches: refs/heads/trunk 007a3f57a -> ecaf3b079
Switch counter shards' clock to timestamps patch by Aleksey Yeschenko; reviewed by Sam Tunnicliffe for CASSANDRA-9811 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ecaf3b07 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ecaf3b07 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ecaf3b07 Branch: refs/heads/trunk Commit: ecaf3b079dad89e220885791fefb1372c3d2f9d6 Parents: 007a3f5 Author: Aleksey Yeschenko <[email protected]> Authored: Thu Jun 2 17:29:04 2016 +0100 Committer: Aleksey Yeschenko <[email protected]> Committed: Fri Jun 3 22:44:09 2016 +0100 ---------------------------------------------------------------------- CHANGES.txt | 1 + src/java/org/apache/cassandra/db/CounterMutation.java | 2 +- test/unit/org/apache/cassandra/db/CounterCacheTest.java | 8 ++++---- test/unit/org/apache/cassandra/db/CounterMutationTest.java | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaf3b07/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 0de27e0..9e8fa77 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.8 + * Switch counter shards' clock to timestamps (CASSANDRA-9811) * Introduce HdrHistogram and response/service/wait separation to stress tool (CASSANDRA-11853) * entry-weighers in QueryProcessor should respect partitionKeyBindIndexes field (CASSANDRA-11718) * Support older ant versions (CASSANDRA-11807) http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaf3b07/src/java/org/apache/cassandra/db/CounterMutation.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/CounterMutation.java b/src/java/org/apache/cassandra/db/CounterMutation.java index 9cad6d6..a61f3e8 100644 --- a/src/java/org/apache/cassandra/db/CounterMutation.java +++ b/src/java/org/apache/cassandra/db/CounterMutation.java @@ -211,7 +211,7 @@ public class CounterMutation implements IMutation private void updateWithCurrentValue(PartitionUpdate.CounterMark mark, ClockAndCount currentValue, ColumnFamilyStore cfs) { - long clock = currentValue.clock + 1L; + long clock = Math.max(FBUtilities.timestampMicros(), currentValue.clock + 1L); long count = currentValue.count + CounterContext.instance().total(mark.value()); mark.setValue(CounterContext.instance().createGlobal(CounterId.getLocalId(), clock, count)); http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaf3b07/test/unit/org/apache/cassandra/db/CounterCacheTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/CounterCacheTest.java b/test/unit/org/apache/cassandra/db/CounterCacheTest.java index 91157ad..4cfd848 100644 --- a/test/unit/org/apache/cassandra/db/CounterCacheTest.java +++ b/test/unit/org/apache/cassandra/db/CounterCacheTest.java @@ -169,10 +169,10 @@ public class CounterCacheTest Clustering c2 = CBuilder.create(cfs.metadata.comparator).add(ByteBufferUtil.bytes(2)).build(); ColumnDefinition cd = cfs.metadata.getColumnDefinition(ByteBufferUtil.bytes("c")); - assertEquals(ClockAndCount.create(1L, 1L), cfs.getCachedCounter(bytes(1), c1, cd, null)); - assertEquals(ClockAndCount.create(1L, 2L), cfs.getCachedCounter(bytes(1), c2, cd, null)); - assertEquals(ClockAndCount.create(1L, 1L), cfs.getCachedCounter(bytes(2), c1, cd, null)); - assertEquals(ClockAndCount.create(1L, 2L), cfs.getCachedCounter(bytes(2), c2, cd, null)); + assertEquals(1L, cfs.getCachedCounter(bytes(1), c1, cd, null).count); + assertEquals(2L, cfs.getCachedCounter(bytes(1), c2, cd, null).count); + assertEquals(1L, cfs.getCachedCounter(bytes(2), c1, cd, null).count); + assertEquals(2L, cfs.getCachedCounter(bytes(2), c2, cd, null).count); } @Test http://git-wip-us.apache.org/repos/asf/cassandra/blob/ecaf3b07/test/unit/org/apache/cassandra/db/CounterMutationTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/CounterMutationTest.java b/test/unit/org/apache/cassandra/db/CounterMutationTest.java index 912dd68..c8d4703 100644 --- a/test/unit/org/apache/cassandra/db/CounterMutationTest.java +++ b/test/unit/org/apache/cassandra/db/CounterMutationTest.java @@ -150,11 +150,11 @@ public class CounterMutationTest CBuilder cb = CBuilder.create(cfsOne.metadata.comparator); cb.add("cc"); - assertEquals(ClockAndCount.create(1L, 1L), cfsOne.getCachedCounter(Util.dk("key1").getKey(), cb.build(), c1cfs1, null)); - assertEquals(ClockAndCount.create(1L, -1L), cfsOne.getCachedCounter(Util.dk("key1").getKey(), cb.build(), c2cfs1, null)); + assertEquals(1L, cfsOne.getCachedCounter(Util.dk("key1").getKey(), cb.build(), c1cfs1, null).count); + assertEquals(-1L, cfsOne.getCachedCounter(Util.dk("key1").getKey(), cb.build(), c2cfs1, null).count); - assertEquals(ClockAndCount.create(1L, 2L), cfsTwo.getCachedCounter(Util.dk("key1").getKey(), cb.build(), c1cfs2, null)); - assertEquals(ClockAndCount.create(1L, -2L), cfsTwo.getCachedCounter(Util.dk("key1").getKey(), cb.build(), c2cfs2, null)); + assertEquals(2L, cfsTwo.getCachedCounter(Util.dk("key1").getKey(), cb.build(), c1cfs2, null).count); + assertEquals(-2L, cfsTwo.getCachedCounter(Util.dk("key1").getKey(), cb.build(), c2cfs2, null).count); } @Test
