http://git-wip-us.apache.org/repos/asf/cassandra/blob/3b13457d/test/unit/org/apache/cassandra/db/context/CounterContextTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/context/CounterContextTest.java b/test/unit/org/apache/cassandra/db/context/CounterContextTest.java index b976065..e3b5e4c 100644 --- a/test/unit/org/apache/cassandra/db/context/CounterContextTest.java +++ b/test/unit/org/apache/cassandra/db/context/CounterContextTest.java @@ -45,7 +45,7 @@ public class CounterContextTest static { - idLength = NodeId.LENGTH; // size of int + idLength = CounterId.LENGTH; // size of int clockLength = 8; // size of long countLength = 8; // size of long stepLength = idLength + clockLength + countLength; @@ -85,9 +85,9 @@ public class CounterContextTest ContextState right; // equality: equal nodes, all counts same - left.writeElement(NodeId.fromInt(3), 3L, 0L); - left.writeElement(NodeId.fromInt(6), 2L, 0L); - left.writeElement(NodeId.fromInt(9), 1L, 0L); + left.writeElement(CounterId.fromInt(3), 3L, 0L); + left.writeElement(CounterId.fromInt(6), 2L, 0L); + left.writeElement(CounterId.fromInt(9), 1L, 0L); right = new ContextState(ByteBufferUtil.clone(left.context), left.headerLength); assert ContextRelationship.EQUAL == @@ -95,171 +95,171 @@ public class CounterContextTest // greater than: left has superset of nodes (counts equal) left = ContextState.allocate(4, 0, allocator); - left.writeElement(NodeId.fromInt(3), 3L, 0L); - left.writeElement(NodeId.fromInt(6), 2L, 0L); - left.writeElement(NodeId.fromInt(9), 1L, 0L); - left.writeElement(NodeId.fromInt(12), 0L, 0L); + left.writeElement(CounterId.fromInt(3), 3L, 0L); + left.writeElement(CounterId.fromInt(6), 2L, 0L); + left.writeElement(CounterId.fromInt(9), 1L, 0L); + left.writeElement(CounterId.fromInt(12), 0L, 0L); right = ContextState.allocate(3, 0, allocator); - right.writeElement(NodeId.fromInt(3), 3L, 0L); - right.writeElement(NodeId.fromInt(6), 2L, 0L); - right.writeElement(NodeId.fromInt(9), 1L, 0L); + right.writeElement(CounterId.fromInt(3), 3L, 0L); + right.writeElement(CounterId.fromInt(6), 2L, 0L); + right.writeElement(CounterId.fromInt(9), 1L, 0L); assert ContextRelationship.GREATER_THAN == cc.diff(left.context, right.context); // less than: left has subset of nodes (counts equal) left = ContextState.allocate(3, 0, allocator); - left.writeElement(NodeId.fromInt(3), 3L, 0L); - left.writeElement(NodeId.fromInt(6), 2L, 0L); - left.writeElement(NodeId.fromInt(9), 1L, 0L); + left.writeElement(CounterId.fromInt(3), 3L, 0L); + left.writeElement(CounterId.fromInt(6), 2L, 0L); + left.writeElement(CounterId.fromInt(9), 1L, 0L); right = ContextState.allocate(4, 0, allocator); - right.writeElement(NodeId.fromInt(3), 3L, 0L); - right.writeElement(NodeId.fromInt(6), 2L, 0L); - right.writeElement(NodeId.fromInt(9), 1L, 0L); - right.writeElement(NodeId.fromInt(12), 0L, 0L); + right.writeElement(CounterId.fromInt(3), 3L, 0L); + right.writeElement(CounterId.fromInt(6), 2L, 0L); + right.writeElement(CounterId.fromInt(9), 1L, 0L); + right.writeElement(CounterId.fromInt(12), 0L, 0L); assert ContextRelationship.LESS_THAN == cc.diff(left.context, right.context); // greater than: equal nodes, but left has higher counts left = ContextState.allocate(3, 0, allocator); - left.writeElement(NodeId.fromInt(3), 3L, 0L); - left.writeElement(NodeId.fromInt(6), 2L, 0L); - left.writeElement(NodeId.fromInt(9), 3L, 0L); + left.writeElement(CounterId.fromInt(3), 3L, 0L); + left.writeElement(CounterId.fromInt(6), 2L, 0L); + left.writeElement(CounterId.fromInt(9), 3L, 0L); right = ContextState.allocate(3, 0, allocator); - right.writeElement(NodeId.fromInt(3), 3L, 0L); - right.writeElement(NodeId.fromInt(6), 2L, 0L); - right.writeElement(NodeId.fromInt(9), 1L, 0L); + right.writeElement(CounterId.fromInt(3), 3L, 0L); + right.writeElement(CounterId.fromInt(6), 2L, 0L); + right.writeElement(CounterId.fromInt(9), 1L, 0L); assert ContextRelationship.GREATER_THAN == cc.diff(left.context, right.context); // less than: equal nodes, but right has higher counts left = ContextState.allocate(3, 0, allocator); - left.writeElement(NodeId.fromInt(3), 3L, 0L); - left.writeElement(NodeId.fromInt(6), 2L, 0L); - left.writeElement(NodeId.fromInt(9), 3L, 0L); + left.writeElement(CounterId.fromInt(3), 3L, 0L); + left.writeElement(CounterId.fromInt(6), 2L, 0L); + left.writeElement(CounterId.fromInt(9), 3L, 0L); right = ContextState.allocate(3, 0, allocator); - right.writeElement(NodeId.fromInt(3), 3L, 0L); - right.writeElement(NodeId.fromInt(6), 9L, 0L); - right.writeElement(NodeId.fromInt(9), 3L, 0L); + right.writeElement(CounterId.fromInt(3), 3L, 0L); + right.writeElement(CounterId.fromInt(6), 9L, 0L); + right.writeElement(CounterId.fromInt(9), 3L, 0L); assert ContextRelationship.LESS_THAN == cc.diff(left.context, right.context); // disjoint: right and left have disjoint node sets left = ContextState.allocate(3, 0, allocator); - left.writeElement(NodeId.fromInt(3), 1L, 0L); - left.writeElement(NodeId.fromInt(4), 1L, 0L); - left.writeElement(NodeId.fromInt(9), 1L, 0L); + left.writeElement(CounterId.fromInt(3), 1L, 0L); + left.writeElement(CounterId.fromInt(4), 1L, 0L); + left.writeElement(CounterId.fromInt(9), 1L, 0L); right = ContextState.allocate(3, 0, allocator); - right.writeElement(NodeId.fromInt(3), 1L, 0L); - right.writeElement(NodeId.fromInt(6), 1L, 0L); - right.writeElement(NodeId.fromInt(9), 1L, 0L); + right.writeElement(CounterId.fromInt(3), 1L, 0L); + right.writeElement(CounterId.fromInt(6), 1L, 0L); + right.writeElement(CounterId.fromInt(9), 1L, 0L); assert ContextRelationship.DISJOINT == cc.diff(left.context, right.context); left = ContextState.allocate(3, 0, allocator); - left.writeElement(NodeId.fromInt(3), 1L, 0L); - left.writeElement(NodeId.fromInt(4), 1L, 0L); - left.writeElement(NodeId.fromInt(9), 1L, 0L); + left.writeElement(CounterId.fromInt(3), 1L, 0L); + left.writeElement(CounterId.fromInt(4), 1L, 0L); + left.writeElement(CounterId.fromInt(9), 1L, 0L); right = ContextState.allocate(3, 0, allocator); - right.writeElement(NodeId.fromInt(2), 1L, 0L); - right.writeElement(NodeId.fromInt(6), 1L, 0L); - right.writeElement(NodeId.fromInt(12), 1L, 0L); + right.writeElement(CounterId.fromInt(2), 1L, 0L); + right.writeElement(CounterId.fromInt(6), 1L, 0L); + right.writeElement(CounterId.fromInt(12), 1L, 0L); assert ContextRelationship.DISJOINT == cc.diff(left.context, right.context); // disjoint: equal nodes, but right and left have higher counts in differing nodes left = ContextState.allocate(3, 0, allocator); - left.writeElement(NodeId.fromInt(3), 1L, 0L); - left.writeElement(NodeId.fromInt(6), 3L, 0L); - left.writeElement(NodeId.fromInt(9), 1L, 0L); + left.writeElement(CounterId.fromInt(3), 1L, 0L); + left.writeElement(CounterId.fromInt(6), 3L, 0L); + left.writeElement(CounterId.fromInt(9), 1L, 0L); right = ContextState.allocate(3, 0, allocator); - right.writeElement(NodeId.fromInt(3), 1L, 0L); - right.writeElement(NodeId.fromInt(6), 1L, 0L); - right.writeElement(NodeId.fromInt(9), 5L, 0L); + right.writeElement(CounterId.fromInt(3), 1L, 0L); + right.writeElement(CounterId.fromInt(6), 1L, 0L); + right.writeElement(CounterId.fromInt(9), 5L, 0L); assert ContextRelationship.DISJOINT == cc.diff(left.context, right.context); left = ContextState.allocate(3, 0, allocator); - left.writeElement(NodeId.fromInt(3), 2L, 0L); - left.writeElement(NodeId.fromInt(6), 3L, 0L); - left.writeElement(NodeId.fromInt(9), 1L, 0L); + left.writeElement(CounterId.fromInt(3), 2L, 0L); + left.writeElement(CounterId.fromInt(6), 3L, 0L); + left.writeElement(CounterId.fromInt(9), 1L, 0L); right = ContextState.allocate(3, 0, allocator); - right.writeElement(NodeId.fromInt(3), 1L, 0L); - right.writeElement(NodeId.fromInt(6), 9L, 0L); - right.writeElement(NodeId.fromInt(9), 5L, 0L); + right.writeElement(CounterId.fromInt(3), 1L, 0L); + right.writeElement(CounterId.fromInt(6), 9L, 0L); + right.writeElement(CounterId.fromInt(9), 5L, 0L); assert ContextRelationship.DISJOINT == cc.diff(left.context, right.context); // disjoint: left has more nodes, but lower counts left = ContextState.allocate(4, 0, allocator); - left.writeElement(NodeId.fromInt(3), 2L, 0L); - left.writeElement(NodeId.fromInt(6), 3L, 0L); - left.writeElement(NodeId.fromInt(9), 1L, 0L); - left.writeElement(NodeId.fromInt(12), 1L, 0L); + left.writeElement(CounterId.fromInt(3), 2L, 0L); + left.writeElement(CounterId.fromInt(6), 3L, 0L); + left.writeElement(CounterId.fromInt(9), 1L, 0L); + left.writeElement(CounterId.fromInt(12), 1L, 0L); right = ContextState.allocate(3, 0, allocator); - right.writeElement(NodeId.fromInt(3), 4L, 0L); - right.writeElement(NodeId.fromInt(6), 9L, 0L); - right.writeElement(NodeId.fromInt(9), 5L, 0L); + right.writeElement(CounterId.fromInt(3), 4L, 0L); + right.writeElement(CounterId.fromInt(6), 9L, 0L); + right.writeElement(CounterId.fromInt(9), 5L, 0L); assert ContextRelationship.DISJOINT == cc.diff(left.context, right.context); // disjoint: left has less nodes, but higher counts left = ContextState.allocate(3, 0, allocator); - left.writeElement(NodeId.fromInt(3), 5L, 0L); - left.writeElement(NodeId.fromInt(6), 3L, 0L); - left.writeElement(NodeId.fromInt(9), 2L, 0L); + left.writeElement(CounterId.fromInt(3), 5L, 0L); + left.writeElement(CounterId.fromInt(6), 3L, 0L); + left.writeElement(CounterId.fromInt(9), 2L, 0L); right = ContextState.allocate(4, 0, allocator); - right.writeElement(NodeId.fromInt(3), 4L, 0L); - right.writeElement(NodeId.fromInt(6), 3L, 0L); - right.writeElement(NodeId.fromInt(9), 2L, 0L); - right.writeElement(NodeId.fromInt(12), 1L, 0L); + right.writeElement(CounterId.fromInt(3), 4L, 0L); + right.writeElement(CounterId.fromInt(6), 3L, 0L); + right.writeElement(CounterId.fromInt(9), 2L, 0L); + right.writeElement(CounterId.fromInt(12), 1L, 0L); assert ContextRelationship.DISJOINT == cc.diff(left.context, right.context); // disjoint: mixed nodes and counts left = ContextState.allocate(3, 0, allocator); - left.writeElement(NodeId.fromInt(3), 5L, 0L); - left.writeElement(NodeId.fromInt(6), 2L, 0L); - left.writeElement(NodeId.fromInt(9), 2L, 0L); + left.writeElement(CounterId.fromInt(3), 5L, 0L); + left.writeElement(CounterId.fromInt(6), 2L, 0L); + left.writeElement(CounterId.fromInt(9), 2L, 0L); right = ContextState.allocate(4, 0, allocator); - right.writeElement(NodeId.fromInt(3), 4L, 0L); - right.writeElement(NodeId.fromInt(6), 3L, 0L); - right.writeElement(NodeId.fromInt(9), 2L, 0L); - right.writeElement(NodeId.fromInt(12), 1L, 0L); + right.writeElement(CounterId.fromInt(3), 4L, 0L); + right.writeElement(CounterId.fromInt(6), 3L, 0L); + right.writeElement(CounterId.fromInt(9), 2L, 0L); + right.writeElement(CounterId.fromInt(12), 1L, 0L); assert ContextRelationship.DISJOINT == cc.diff(left.context, right.context); left = ContextState.allocate(4, 0, allocator); - left.writeElement(NodeId.fromInt(3), 5L, 0L); - left.writeElement(NodeId.fromInt(6), 2L, 0L); - left.writeElement(NodeId.fromInt(7), 2L, 0L); - left.writeElement(NodeId.fromInt(9), 2L, 0L); + left.writeElement(CounterId.fromInt(3), 5L, 0L); + left.writeElement(CounterId.fromInt(6), 2L, 0L); + left.writeElement(CounterId.fromInt(7), 2L, 0L); + left.writeElement(CounterId.fromInt(9), 2L, 0L); right = ContextState.allocate(3, 0, allocator); - right.writeElement(NodeId.fromInt(3), 4L, 0L); - right.writeElement(NodeId.fromInt(6), 3L, 0L); - right.writeElement(NodeId.fromInt(9), 2L, 0L); + right.writeElement(CounterId.fromInt(3), 4L, 0L); + right.writeElement(CounterId.fromInt(6), 3L, 0L); + right.writeElement(CounterId.fromInt(9), 2L, 0L); assert ContextRelationship.DISJOINT == cc.diff(left.context, right.context); @@ -276,39 +276,39 @@ public class CounterContextTest { // note: local counts aggregated; remote counts are reconciled (i.e. take max) ContextState left = ContextState.allocate(4, 1, allocator); - left.writeElement(NodeId.fromInt(1), 1L, 1L); - left.writeElement(NodeId.fromInt(2), 2L, 2L); - left.writeElement(NodeId.fromInt(4), 6L, 3L); - left.writeElement(NodeId.getLocalId(), 7L, 3L, true); + left.writeElement(CounterId.fromInt(1), 1L, 1L); + left.writeElement(CounterId.fromInt(2), 2L, 2L); + left.writeElement(CounterId.fromInt(4), 6L, 3L); + left.writeElement(CounterId.getLocalId(), 7L, 3L, true); ContextState right = ContextState.allocate(3, 1, allocator); - right.writeElement(NodeId.fromInt(4), 4L, 4L); - right.writeElement(NodeId.fromInt(5), 5L, 5L); - right.writeElement(NodeId.getLocalId(), 2L, 9L, true); + right.writeElement(CounterId.fromInt(4), 4L, 4L); + right.writeElement(CounterId.fromInt(5), 5L, 5L); + right.writeElement(CounterId.getLocalId(), 2L, 9L, true); ByteBuffer merged = cc.merge(left.context, right.context, allocator); int hd = 4; assertEquals(hd + 5 * stepLength, merged.remaining()); // local node id's counts are aggregated - assert Util.equalsNodeId(NodeId.getLocalId(), merged, hd + 4*stepLength); + assert Util.equalsCounterId(CounterId.getLocalId(), merged, hd + 4 * stepLength); assertEquals( 9L, merged.getLong(merged.position() + hd + 4*stepLength + idLength)); assertEquals(12L, merged.getLong(merged.position() + hd + 4*stepLength + idLength + clockLength)); // remote node id counts are reconciled (i.e. take max) - assert Util.equalsNodeId(NodeId.fromInt(4), merged, hd + 2*stepLength); + assert Util.equalsCounterId(CounterId.fromInt(4), merged, hd + 2 * stepLength); assertEquals( 6L, merged.getLong(merged.position() + hd + 2*stepLength + idLength)); assertEquals( 3L, merged.getLong(merged.position() + hd + 2*stepLength + idLength + clockLength)); - assert Util.equalsNodeId(NodeId.fromInt(5), merged, hd + 3*stepLength); + assert Util.equalsCounterId(CounterId.fromInt(5), merged, hd + 3 * stepLength); assertEquals( 5L, merged.getLong(merged.position() + hd + 3*stepLength + idLength)); assertEquals( 5L, merged.getLong(merged.position() + hd + 3*stepLength + idLength + clockLength)); - assert Util.equalsNodeId(NodeId.fromInt(2), merged, hd + 1*stepLength); + assert Util.equalsCounterId(CounterId.fromInt(2), merged, hd + 1 * stepLength); assertEquals( 2L, merged.getLong(merged.position() + hd + 1*stepLength + idLength)); assertEquals( 2L, merged.getLong(merged.position() + hd + 1*stepLength + idLength + clockLength)); - assert Util.equalsNodeId(NodeId.fromInt(1), merged, hd + 0*stepLength); + assert Util.equalsCounterId(CounterId.fromInt(1), merged, hd + 0 * stepLength); assertEquals( 1L, merged.getLong(merged.position() + hd + 0*stepLength + idLength)); assertEquals( 1L, merged.getLong(merged.position() + hd + 0*stepLength + idLength + clockLength)); } @@ -323,15 +323,15 @@ public class CounterContextTest private void runTotal(Allocator allocator) { ContextState left = ContextState.allocate(4, 1, allocator); - left.writeElement(NodeId.fromInt(1), 1L, 1L); - left.writeElement(NodeId.fromInt(2), 2L, 2L); - left.writeElement(NodeId.fromInt(4), 3L, 3L); - left.writeElement(NodeId.getLocalId(), 3L, 3L, true); + left.writeElement(CounterId.fromInt(1), 1L, 1L); + left.writeElement(CounterId.fromInt(2), 2L, 2L); + left.writeElement(CounterId.fromInt(4), 3L, 3L); + left.writeElement(CounterId.getLocalId(), 3L, 3L, true); ContextState right = ContextState.allocate(3, 1, allocator); - right.writeElement(NodeId.fromInt(4), 4L, 4L); - right.writeElement(NodeId.fromInt(5), 5L, 5L); - right.writeElement(NodeId.getLocalId(), 9L, 9L, true); + right.writeElement(CounterId.fromInt(4), 4L, 4L); + right.writeElement(CounterId.fromInt(5), 5L, 5L); + right.writeElement(CounterId.getLocalId(), 9L, 9L, true); ByteBuffer merged = cc.merge(left.context, right.context, allocator); @@ -354,34 +354,34 @@ public class CounterContextTest private void runMergeOldShards(Allocator allocator) { long now = System.currentTimeMillis(); - NodeId id1 = NodeId.fromInt(1); - NodeId id3 = NodeId.fromInt(3); - List<NodeId.NodeIdRecord> records = new ArrayList<NodeId.NodeIdRecord>(); - records.add(new NodeId.NodeIdRecord(id1, 2L)); - records.add(new NodeId.NodeIdRecord(id3, 4L)); + CounterId id1 = CounterId.fromInt(1); + CounterId id3 = CounterId.fromInt(3); + List<CounterId.CounterIdRecord> records = new ArrayList<CounterId.CounterIdRecord>(); + records.add(new CounterId.CounterIdRecord(id1, 2L)); + records.add(new CounterId.CounterIdRecord(id3, 4L)); ContextState ctx = ContextState.allocate(5, 3, allocator); ctx.writeElement(id1, 1L, 1L, true); - ctx.writeElement(NodeId.fromInt(2), 2L, 2L); + ctx.writeElement(CounterId.fromInt(2), 2L, 2L); ctx.writeElement(id3, 3L, 3L, true); - ctx.writeElement(NodeId.fromInt(4), 6L, 3L); - ctx.writeElement(NodeId.fromInt(5), 7L, 3L, true); + ctx.writeElement(CounterId.fromInt(4), 6L, 3L); + ctx.writeElement(CounterId.fromInt(5), 7L, 3L, true); ByteBuffer merger = cc.computeOldShardMerger(ctx.context, records, Integer.MAX_VALUE); ContextState m = new ContextState(merger); - assert m.getNodeId().equals(id1); + assert m.getCounterId().equals(id1); assert m.getClock() <= -now; assert m.getCount() == -1L; assert m.isDelta(); m.moveToNext(); - assert m.getNodeId().equals(id3); + assert m.getCounterId().equals(id3); assert m.getClock() <= -now; assert m.getCount() == -3L; assert m.isDelta(); m.moveToNext(); - assert m.getNodeId().equals(NodeId.getLocalId()); + assert m.getCounterId().equals(CounterId.getLocalId()); assert m.getClock() == 1L; assert m.getCount() == 4L; assert m.isDelta(); @@ -397,20 +397,20 @@ public class CounterContextTest private void runRemoveOldShards(Allocator allocator) { - NodeId id1 = NodeId.fromInt(1); - NodeId id3 = NodeId.fromInt(3); - NodeId id6 = NodeId.fromInt(6); - List<NodeId.NodeIdRecord> records = new ArrayList<NodeId.NodeIdRecord>(); - records.add(new NodeId.NodeIdRecord(id1, 2L)); - records.add(new NodeId.NodeIdRecord(id3, 4L)); - records.add(new NodeId.NodeIdRecord(id6, 10L)); + CounterId id1 = CounterId.fromInt(1); + CounterId id3 = CounterId.fromInt(3); + CounterId id6 = CounterId.fromInt(6); + List<CounterId.CounterIdRecord> records = new ArrayList<CounterId.CounterIdRecord>(); + records.add(new CounterId.CounterIdRecord(id1, 2L)); + records.add(new CounterId.CounterIdRecord(id3, 4L)); + records.add(new CounterId.CounterIdRecord(id6, 10L)); ContextState ctx = ContextState.allocate(6, 3, allocator); ctx.writeElement(id1, 1L, 1L, true); - ctx.writeElement(NodeId.fromInt(2), 2L, 2L); + ctx.writeElement(CounterId.fromInt(2), 2L, 2L); ctx.writeElement(id3, 3L, 3L, true); - ctx.writeElement(NodeId.fromInt(4), 6L, 3L); - ctx.writeElement(NodeId.fromInt(5), 7L, 3L, true); + ctx.writeElement(CounterId.fromInt(4), 6L, 3L); + ctx.writeElement(CounterId.fromInt(5), 7L, 3L, true); ctx.writeElement(id6, 5L, 6L); ByteBuffer merger = cc.computeOldShardMerger(ctx.context, records, Integer.MAX_VALUE); @@ -431,20 +431,20 @@ public class CounterContextTest private void runRemoveOldShardsNotAllExpiring(Allocator allocator) { - NodeId id1 = NodeId.fromInt(1); - NodeId id3 = NodeId.fromInt(3); - NodeId id6 = NodeId.fromInt(6); - List<NodeId.NodeIdRecord> records = new ArrayList<NodeId.NodeIdRecord>(); - records.add(new NodeId.NodeIdRecord(id1, 2L)); - records.add(new NodeId.NodeIdRecord(id3, 4L)); - records.add(new NodeId.NodeIdRecord(id6, 10L)); + CounterId id1 = CounterId.fromInt(1); + CounterId id3 = CounterId.fromInt(3); + CounterId id6 = CounterId.fromInt(6); + List<CounterId.CounterIdRecord> records = new ArrayList<CounterId.CounterIdRecord>(); + records.add(new CounterId.CounterIdRecord(id1, 2L)); + records.add(new CounterId.CounterIdRecord(id3, 4L)); + records.add(new CounterId.CounterIdRecord(id6, 10L)); ContextState ctx = ContextState.allocate(6, 3, allocator); ctx.writeElement(id1, 0L, 1L, true); - ctx.writeElement(NodeId.fromInt(2), 0L, 2L); + ctx.writeElement(CounterId.fromInt(2), 0L, 2L); ctx.writeElement(id3, 0L, 3L, true); - ctx.writeElement(NodeId.fromInt(4), 0L, 3L); - ctx.writeElement(NodeId.fromInt(5), 0L, 3L, true); + ctx.writeElement(CounterId.fromInt(4), 0L, 3L); + ctx.writeElement(CounterId.fromInt(5), 0L, 3L, true); ctx.writeElement(id6, 0L, 6L); int timeFirstMerge = (int)(System.currentTimeMillis() / 1000); @@ -475,7 +475,7 @@ public class CounterContextTest // We should have cleaned id1 but not id3 ContextState m = new ContextState(cleaned); m.moveToNext(); - assert m.getNodeId().equals(id3); + assert m.getCounterId().equals(id3); } @@ -489,10 +489,10 @@ public class CounterContextTest private void runRemoveNotDeltaOldShards(Allocator allocator) { ContextState ctx = ContextState.allocate(4, 1, allocator); - ctx.writeElement(NodeId.fromInt(1), 1L, 1L, true); - ctx.writeElement(NodeId.fromInt(2), -System.currentTimeMillis(), 0L); - ctx.writeElement(NodeId.fromInt(3), -System.currentTimeMillis(), 0L); - ctx.writeElement(NodeId.fromInt(4), -System.currentTimeMillis(), 0L); + ctx.writeElement(CounterId.fromInt(1), 1L, 1L, true); + ctx.writeElement(CounterId.fromInt(2), -System.currentTimeMillis(), 0L); + ctx.writeElement(CounterId.fromInt(3), -System.currentTimeMillis(), 0L); + ctx.writeElement(CounterId.fromInt(4), -System.currentTimeMillis(), 0L); ByteBuffer cleaned = cc.removeOldShards(ctx.context, (int)(System.currentTimeMillis() / 1000) + 1); assert cc.total(ctx.context) == cc.total(cleaned);
http://git-wip-us.apache.org/repos/asf/cassandra/blob/3b13457d/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java b/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java index 390dcbb..00fc262 100644 --- a/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java +++ b/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java @@ -42,8 +42,8 @@ import org.apache.cassandra.io.sstable.SSTableReader; import org.apache.cassandra.service.StorageService; import org.apache.cassandra.thrift.IndexExpression; import org.apache.cassandra.thrift.IndexOperator; +import org.apache.cassandra.utils.CounterId; import org.apache.cassandra.utils.FBUtilities; -import org.apache.cassandra.utils.NodeId; import org.junit.BeforeClass; import org.junit.Test; @@ -196,10 +196,10 @@ public class StreamingTransferTest extends SchemaLoader ColumnFamily cf = ColumnFamily.create(cfs.metadata); ColumnFamily cfCleaned = ColumnFamily.create(cfs.metadata); CounterContext.ContextState state = CounterContext.ContextState.allocate(4, 1); - state.writeElement(NodeId.fromInt(2), 9L, 3L, true); - state.writeElement(NodeId.fromInt(4), 4L, 2L); - state.writeElement(NodeId.fromInt(6), 3L, 3L); - state.writeElement(NodeId.fromInt(8), 2L, 4L); + state.writeElement(CounterId.fromInt(2), 9L, 3L, true); + state.writeElement(CounterId.fromInt(4), 4L, 2L); + state.writeElement(CounterId.fromInt(6), 3L, 3L); + state.writeElement(CounterId.fromInt(8), 2L, 4L); cf.addColumn(new CounterColumn(ByteBufferUtil.bytes(col), state.context, timestamp));