Merge branch 'cassandra-3.0' into cassandra-3.11

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/32f9e676
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/32f9e676
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/32f9e676

Branch: refs/heads/cassandra-3.11
Commit: 32f9e6763b7a857a015da0b20af1d3ff486da0c9
Parents: 684120d b2f6ce9
Author: Aleksey Yeshchenko <alek...@apple.com>
Authored: Mon Apr 30 18:48:08 2018 +0100
Committer: Aleksey Yeshchenko <alek...@apple.com>
Committed: Mon Apr 30 18:48:08 2018 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../apache/cassandra/hints/HintsCatalog.java    |   7 ++
 .../apache/cassandra/hints/HintsService.java    |   2 +-
 .../org/apache/cassandra/hints/HintsStore.java  |   7 ++
 .../cassandra/service/StorageService.java       |   7 +-
 .../cassandra/hints/HintsCatalogTest.java       | 120 ++++++++++++++++++-
 6 files changed, 138 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/32f9e676/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 5450322,857cf96..c392059
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,15 -1,5 +1,16 @@@
 -3.0.17
 +3.11.3
 + * Allow existing nodes to use all peers in shadow round (CASSANDRA-13851)
 + * Fix cqlsh to read connection.ssl cqlshrc option again (CASSANDRA-14299)
 + * Downgrade log level to trace for CommitLogSegmentManager (CASSANDRA-14370)
 + * CQL fromJson(null) throws NullPointerException (CASSANDRA-13891)
 + * Serialize empty buffer as empty string for json output format 
(CASSANDRA-14245)
 + * Allow logging implementation to be interchanged for embedded testing 
(CASSANDRA-13396)
 + * SASI tokenizer for simple delimiter based entries (CASSANDRA-14247)
 + * Fix Loss of digits when doing CAST from varint/bigint to decimal 
(CASSANDRA-14170)
 + * RateBasedBackPressure unnecessarily invokes a lock on the Guava 
RateLimiter (CASSANDRA-14163)
 + * Fix wildcard GROUP BY queries (CASSANDRA-14209)
 +Merged from 3.0:
+  * Delay hints store excise by write timeout to avoid race with decommission 
(CASSANDRA-13740)
   * Deprecate background repair and probablistic read_repair_chance table 
options
     (CASSANDRA-13910)
   * Add missed CQL keywords to documentation (CASSANDRA-14359)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/32f9e676/src/java/org/apache/cassandra/hints/HintsService.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/32f9e676/src/java/org/apache/cassandra/hints/HintsStore.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/32f9e676/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/32f9e676/test/unit/org/apache/cassandra/hints/HintsCatalogTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/hints/HintsCatalogTest.java
index a255338,928fd31..68acd0c
--- a/test/unit/org/apache/cassandra/hints/HintsCatalogTest.java
+++ b/test/unit/org/apache/cassandra/hints/HintsCatalogTest.java
@@@ -43,7 -69,21 +69,7 @@@ public class HintsCatalogTes
          }
      }
  
-     public static void loadCompletenessAndOrderTest(File directory) throws 
IOException
 -    @Test
 -    public void exciseHintFiles() throws IOException
 -    {
 -        File directory = Files.createTempDirectory(null).toFile();
 -        try
 -        {
 -            exciseHintFiles(directory);
 -        }
 -        finally
 -        {
 -            directory.deleteOnExit();
 -        }
 -    }
 -
+     private void loadCompletenessAndOrderTest(File directory) throws 
IOException
      {
          UUID hostId1 = UUID.randomUUID();
          UUID hostId2 = UUID.randomUUID();
@@@ -79,37 -119,39 +105,84 @@@
          assertNull(store2.poll());
      }
  
 +    @Test
 +    public void deleteHintsTest() throws IOException
 +    {
 +        File directory = Files.createTempDirectory(null).toFile();
 +        UUID hostId1 = UUID.randomUUID();
 +        UUID hostId2 = UUID.randomUUID();
 +        long now = System.currentTimeMillis();
 +        writeDescriptor(directory, new HintsDescriptor(hostId1, now));
-         writeDescriptor(directory, new HintsDescriptor(hostId1, now+1));
-         writeDescriptor(directory, new HintsDescriptor(hostId2, now+2));
-         writeDescriptor(directory, new HintsDescriptor(hostId2, now+3));
++        writeDescriptor(directory, new HintsDescriptor(hostId1, now + 1));
++        writeDescriptor(directory, new HintsDescriptor(hostId2, now + 2));
++        writeDescriptor(directory, new HintsDescriptor(hostId2, now + 3));
 +
 +        // load catalog containing two stores (one for each host)
 +        HintsCatalog catalog = HintsCatalog.load(directory, 
ImmutableMap.of());
 +        assertEquals(2, catalog.stores().count());
 +        assertTrue(catalog.hasFiles());
 +
 +        // delete all hints from store 1
 +        assertTrue(catalog.get(hostId1).hasFiles());
 +        catalog.deleteAllHints(hostId1);
 +        assertFalse(catalog.get(hostId1).hasFiles());
 +        // stores are still keepts for each host, even after deleting hints
 +        assertEquals(2, catalog.stores().count());
 +        assertTrue(catalog.hasFiles());
 +
 +        // delete all hints from all stores
 +        catalog.deleteAllHints();
 +        assertEquals(2, catalog.stores().count());
 +        assertFalse(catalog.hasFiles());
 +    }
 +
++    @Test
++    public void exciseHintFiles() throws IOException
++    {
++        File directory = Files.createTempDirectory(null).toFile();
++        try
++        {
++            exciseHintFiles(directory);
++        }
++        finally
++        {
++            directory.deleteOnExit();
++        }
++    }
++
+     private static void exciseHintFiles(File directory) throws IOException
+     {
+         UUID hostId = UUID.randomUUID();
+ 
+         HintsDescriptor descriptor1 = new HintsDescriptor(hostId, 
System.currentTimeMillis());
+         HintsDescriptor descriptor2 = new HintsDescriptor(hostId, 
System.currentTimeMillis() + 1);
+         HintsDescriptor descriptor3 = new HintsDescriptor(hostId, 
System.currentTimeMillis() + 2);
+         HintsDescriptor descriptor4 = new HintsDescriptor(hostId, 
System.currentTimeMillis() + 3);
+ 
+         createHintFile(directory, descriptor1);
+         createHintFile(directory, descriptor2);
+         createHintFile(directory, descriptor3);
+         createHintFile(directory, descriptor4);
+ 
+         HintsCatalog catalog = HintsCatalog.load(directory, 
ImmutableMap.of());
+         assertEquals(1, catalog.stores().count());
+ 
+         HintsStore store = catalog.get(hostId);
+ 
+         //should have 4 hint files
+         assertEquals(4, store.getDispatchQueueSize());
+ 
+         //excise store as a result it should remove all the hint files
+         catalog.exciseStore(hostId);
+ 
+         catalog = HintsCatalog.load(directory, ImmutableMap.of());
+         assertEquals(0, catalog.stores().count());
+         store = catalog.get(hostId);
+ 
+         //should have 0 hint files now
+         assertEquals(0, store.getDispatchQueueSize());
+     }
+ 
      @SuppressWarnings("EmptyTryBlock")
      private static void writeDescriptor(File directory, HintsDescriptor 
descriptor) throws IOException
      {
@@@ -117,4 -159,43 +190,43 @@@
          {
          }
      }
+ 
+     private static Mutation createMutation(String key, long now)
+     {
 -        Mutation mutation = new Mutation(KEYSPACE, dk(key));
++        Mutation.SimpleBuilder builder = Mutation.simpleBuilder(KEYSPACE, 
dk(key));
+ 
 -        new RowUpdateBuilder(Schema.instance.getCFMetaData(KEYSPACE, TABLE0), 
now, mutation)
 -                .clustering("column0")
 -                .add("val", "value0")
 -                .build();
++        builder.update(Schema.instance.getCFMetaData(KEYSPACE, TABLE0))
++               .timestamp(now)
++               .row("column0")
++               .add("val", "value0");
+ 
 -        new RowUpdateBuilder(Schema.instance.getCFMetaData(KEYSPACE, TABLE1), 
now + 1, mutation)
 -                .clustering("column1")
 -                .add("val", "value1")
 -                .build();
++        builder.update(Schema.instance.getCFMetaData(KEYSPACE, TABLE1))
++               .timestamp(now + 1)
++               .row("column1")
++               .add("val", "value1");
+ 
 -        new RowUpdateBuilder(Schema.instance.getCFMetaData(KEYSPACE, TABLE2), 
now + 2, mutation)
 -                .clustering("column2")
 -                .add("val", "value2")
 -                .build();
++        builder.update(Schema.instance.getCFMetaData(KEYSPACE, TABLE2))
++               .timestamp(now + 2)
++               .row("column2")
++               .add("val", "value2");
+ 
 -        return mutation;
++        return builder.build();
+     }
+ 
+     @SuppressWarnings("EmptyTryBlock")
+     private static void createHintFile(File directory, HintsDescriptor 
descriptor) throws IOException
+     {
+         try (HintsWriter writer = HintsWriter.create(directory, descriptor))
+         {
+             ByteBuffer writeBuffer = 
ByteBuffer.allocateDirect(WRITE_BUFFER_SIZE);
+             try (HintsWriter.Session session = writer.newSession(writeBuffer))
+             {
+                 long now = FBUtilities.timestampMicros();
+                 Mutation mutation = createMutation("testSerializer", now);
+                 Hint hint = Hint.create(mutation, now / 1000);
+ 
+                 session.append(hint);
+             }
+         }
+     }
  }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to