Merge branch 'cassandra-3.0' into trunk
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b63e6eef Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b63e6eef Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b63e6eef Branch: refs/heads/trunk Commit: b63e6eef53053099cf238179b71553916877923d Parents: c798783 b2f38ef Author: Aleksey Yeschenko <[email protected]> Authored: Thu Feb 11 13:08:42 2016 +0000 Committer: Aleksey Yeschenko <[email protected]> Committed: Thu Feb 11 13:08:42 2016 +0000 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/batchlog/BatchlogManager.java | 3 +- .../apache/cassandra/hints/HintVerbHandler.java | 22 +++- .../cassandra/hints/HintsDispatchExecutor.java | 28 ++++- .../apache/cassandra/hints/HintsDispatcher.java | 7 +- .../apache/cassandra/hints/HintsService.java | 20 +++- .../apache/cassandra/service/StorageProxy.java | 20 +++- .../cassandra/service/StorageService.java | 8 ++ .../org/apache/cassandra/hints/HintTest.java | 109 +++++++++++++++++++ 9 files changed, 199 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b63e6eef/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index da99e3f,e723aba..ee759d4 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,25 -1,5 +1,26 @@@ -3.0.4 +3.4 + * Support long name output for nodetool commands (CASSANDRA-7950) + * Encrypted hints (CASSANDRA-11040) + * SASI index options validation (CASSANDRA-11136) + * Optimize disk seek using min/max column name meta data when the LIMIT clause is used + (CASSANDRA-8180) + * Add LIKE support to CQL3 (CASSANDRA-11067) + * Generic Java UDF types (CASSANDRA-10819) + * cqlsh: Include sub-second precision in timestamps by default (CASSANDRA-10428) + * Set javac encoding to utf-8 (CASSANDRA-11077) + * Integrate SASI index into Cassandra (CASSANDRA-10661) + * Add --skip-flush option to nodetool snapshot + * Skip values for non-queried columns (CASSANDRA-10657) + * Add support for secondary indexes on static columns (CASSANDRA-8103) + * CommitLogUpgradeTestMaker creates broken commit logs (CASSANDRA-11051) + * Add metric for number of dropped mutations (CASSANDRA-10866) + * Simplify row cache invalidation code (CASSANDRA-10396) + * Support user-defined compaction through nodetool (CASSANDRA-10660) + * Stripe view locks by key and table ID to reduce contention (CASSANDRA-10981) + * Add nodetool gettimeout and settimeout commands (CASSANDRA-10953) + * Add 3.0 metadata to sstablemetadata output (CASSANDRA-10838) +Merged from 3.0: + * Properly handle hinted handoff after topology changes (CASSANDRA-5902) * AssertionError when listing sstable files on inconsistent disk state (CASSANDRA-11156) * Fix wrong rack counting and invalid conditions check for TokenAllocation (CASSANDRA-11139) http://git-wip-us.apache.org/repos/asf/cassandra/blob/b63e6eef/src/java/org/apache/cassandra/hints/HintVerbHandler.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b63e6eef/src/java/org/apache/cassandra/service/StorageProxy.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b63e6eef/src/java/org/apache/cassandra/service/StorageService.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b63e6eef/test/unit/org/apache/cassandra/hints/HintTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/hints/HintTest.java index 4d6ed15,1d486e1..658a41c --- a/test/unit/org/apache/cassandra/hints/HintTest.java +++ b/test/unit/org/apache/cassandra/hints/HintTest.java @@@ -185,6 -203,97 +203,97 @@@ public class HintTes assertNoPartitions(key, TABLE2); } + @SuppressWarnings("unchecked") + @Test + public void testChangedTopology() throws Exception + { + // create a hint + long now = FBUtilities.timestampMicros(); + String key = "testChangedTopology"; + Mutation mutation = createMutation(key, now); + Hint hint = Hint.create(mutation, now / 1000); + + // Prepare metadata with injected stale endpoint serving the mutation key. + TokenMetadata tokenMeta = StorageService.instance.getTokenMetadata(); + InetAddress local = FBUtilities.getBroadcastAddress(); + InetAddress endpoint = InetAddress.getByName("1.1.1.1"); + UUID localId = StorageService.instance.getLocalHostUUID(); + UUID targetId = UUID.randomUUID(); + tokenMeta.updateHostId(targetId, endpoint); + tokenMeta.updateNormalTokens(ImmutableList.of(mutation.key().getToken()), endpoint); + + // sanity check that there is no data inside yet + assertNoPartitions(key, TABLE0); + assertNoPartitions(key, TABLE1); + assertNoPartitions(key, TABLE2); + + assert StorageProxy.instance.getHintsInProgress() == 0; + long totalHintCount = StorageProxy.instance.getTotalHints(); + // Process hint message. + HintMessage message = new HintMessage(localId, hint); + MessagingService.instance().getVerbHandler(MessagingService.Verb.HINT).doVerb( - MessageIn.create(local, message, Collections.emptyMap(), MessagingService.Verb.HINT, MessagingService.current_version), ++ MessageIn.create(local, message, Collections.emptyMap(), MessagingService.Verb.HINT, MessagingService.current_version, MessageIn.createTimestamp()), + -1); + + // hint should not be applied as we no longer are a replica + assertNoPartitions(key, TABLE0); + assertNoPartitions(key, TABLE1); + assertNoPartitions(key, TABLE2); + + // Attempt to send to new endpoint should have been made. Node is not live hence it should now be a hint. + assertEquals(totalHintCount + 1, StorageProxy.instance.getTotalHints()); + } + + @SuppressWarnings("unchecked") + @Test + public void testChangedTopologyNotHintable() throws Exception + { + // create a hint + long now = FBUtilities.timestampMicros(); + String key = "testChangedTopology"; + Mutation mutation = createMutation(key, now); + Hint hint = Hint.create(mutation, now / 1000); + + // Prepare metadata with injected stale endpoint. + TokenMetadata tokenMeta = StorageService.instance.getTokenMetadata(); + InetAddress local = FBUtilities.getBroadcastAddress(); + InetAddress endpoint = InetAddress.getByName("1.1.1.1"); + UUID localId = StorageService.instance.getLocalHostUUID(); + UUID targetId = UUID.randomUUID(); + tokenMeta.updateHostId(targetId, endpoint); + tokenMeta.updateNormalTokens(ImmutableList.of(mutation.key().getToken()), endpoint); + + // sanity check that there is no data inside yet + assertNoPartitions(key, TABLE0); + assertNoPartitions(key, TABLE1); + assertNoPartitions(key, TABLE2); + + try + { + DatabaseDescriptor.setHintedHandoffEnabled(false); + + assert StorageMetrics.totalHintsInProgress.getCount() == 0; + long totalHintCount = StorageMetrics.totalHints.getCount(); + // Process hint message. + HintMessage message = new HintMessage(localId, hint); + MessagingService.instance().getVerbHandler(MessagingService.Verb.HINT).doVerb( - MessageIn.create(local, message, Collections.emptyMap(), MessagingService.Verb.HINT, MessagingService.current_version), ++ MessageIn.create(local, message, Collections.emptyMap(), MessagingService.Verb.HINT, MessagingService.current_version, MessageIn.createTimestamp()), + -1); + + // hint should not be applied as we no longer are a replica + assertNoPartitions(key, TABLE0); + assertNoPartitions(key, TABLE1); + assertNoPartitions(key, TABLE2); + + // Attempt to send to new endpoint should not have been made. + assertEquals(totalHintCount, StorageMetrics.totalHints.getCount()); + } + finally + { + DatabaseDescriptor.setHintedHandoffEnabled(true); + } + } + private static Mutation createMutation(String key, long now) { Mutation mutation = new Mutation(KEYSPACE, dk(key));
