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/bd770819
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/bd770819
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/bd770819

Branch: refs/heads/cassandra-3.11
Commit: bd7708192ca9fa9be45ec9a34135a89997df2701
Parents: 689484b 6edc268
Author: Jeff Jirsa <j...@jeffjirsa.net>
Authored: Tue Mar 28 17:28:26 2017 -0700
Committer: Jeff Jirsa <j...@jeffjirsa.net>
Committed: Tue Mar 28 17:29:12 2017 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/schema/LegacySchemaMigrator.java  | 30 +++++++++++++++++++-
 .../schema/LegacySchemaMigratorTest.java        | 26 +++++++++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/bd770819/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index c9e93c4,b46eb50..9cd1ca7
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,23 -1,4 +1,24 @@@
 -3.0.13
 +3.11.0
 + * cdc column addition strikes again (CASSANDRA-13382)
 + * Fix static column indexes (CASSANDRA-13277) 
 + * DataOutputBuffer.asNewBuffer broken (CASSANDRA-13298)
 + * unittest CipherFactoryTest failed on MacOS (CASSANDRA-13370)
 + * Forbid SELECT restrictions and CREATE INDEX over non-frozen UDT columns 
(CASSANDRA-13247)
 + * Default logging we ship will incorrectly print "?:?" for "%F:%L" pattern 
(CASSANDRA-13317)
 + * Possible AssertionError in UnfilteredRowIteratorWithLowerBound 
(CASSANDRA-13366)
 + * Support unaligned memory access for AArch64 (CASSANDRA-13326)
 + * Improve SASI range iterator efficiency on intersection with an empty range 
(CASSANDRA-12915).
 + * Fix equality comparisons of columns using the duration type 
(CASSANDRA-13174)
 + * Obfuscate password in stress-graphs (CASSANDRA-12233)
 + * Move to FastThreadLocalThread and FastThreadLocal (CASSANDRA-13034)
 + * nodetool stopdaemon errors out (CASSANDRA-13030)
 + * Tables in system_distributed should not use gcgs of 0 (CASSANDRA-12954)
 + * Fix primary index calculation for SASI (CASSANDRA-12910)
 + * More fixes to the TokenAllocator (CASSANDRA-12990)
 + * NoReplicationTokenAllocator should work with zero replication factor 
(CASSANDRA-12983)
 + * Address message coalescing regression (CASSANDRA-12676)
 +Merged from 3.0:
++ * Legacy caching options can prevent 3.0 upgrade (CASSANDRA-13384)
   * Use the Kernel32 library to retrieve the PID on Windows and fix startup 
checks (CASSANDRA-13333)
   * Fix code to not exchange schema across major versions (CASSANDRA-13274)
   * Dropping column results in "corrupt" SSTable (CASSANDRA-13337)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/bd770819/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
index 19844a3,ac9cfd9..97d60d5
--- a/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
+++ b/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
@@@ -501,6 -503,32 +502,33 @@@ public final class LegacySchemaMigrato
          return params.build();
      }
  
++
+     /**
+      *
 -     * 2.1 and newer use JSON'ified map of caching parameters, but older 
versions had valid Strings
 -     * NONE, KEYS_ONLY, ROWS_ONLY, and ALL
 -     *
 -     * @param caching, the string representing the table's caching options
 -     * @return CachingParams object corresponding to the input string
 -     */
++      * 2.1 and newer use JSON'ified map of caching parameters, but older 
versions had valid Strings
++      * NONE, KEYS_ONLY, ROWS_ONLY, and ALL
++      *
++      * @param caching, the string representing the table's caching options
++      * @return CachingParams object corresponding to the input string
++      */
+     @VisibleForTesting
+     public static CachingParams cachingFromRow(String caching)
+     {
+         switch(caching)
+         {
+             case "NONE":
+                 return CachingParams.CACHE_NOTHING;
+             case "KEYS_ONLY":
+                 return CachingParams.CACHE_KEYS;
+             case "ROWS_ONLY":
+                 return new CachingParams(false, Integer.MAX_VALUE);
+             case "ALL":
+                 return CachingParams.CACHE_EVERYTHING;
+             default:
+                 return CachingParams.fromMap(fromJsonMap(caching));
+         }
+     }
+ 
      /*
       * The method is needed - to migrate max_compaction_threshold and 
min_compaction_threshold
       * to the compaction map, where they belong.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/bd770819/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
index 239a90d,fe91ddc..f907f22
--- a/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
+++ b/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
@@@ -99,14 -97,34 +100,39 @@@ public class LegacySchemaMigratorTes
          expected.forEach(LegacySchemaMigratorTest::verifyIndexBuildStatus);
      }
  
+     @Test
+     public void testMigrateLegacyCachingOptions() throws IOException
+     {
+         CQLTester.cleanupAndLeaveDirs();
+ 
+         assertEquals(CachingParams.CACHE_EVERYTHING, 
LegacySchemaMigrator.cachingFromRow("ALL"));
+         assertEquals(CachingParams.CACHE_NOTHING, 
LegacySchemaMigrator.cachingFromRow("NONE"));
+         assertEquals(CachingParams.CACHE_KEYS, 
LegacySchemaMigrator.cachingFromRow("KEYS_ONLY"));
+         assertEquals(new CachingParams(false, Integer.MAX_VALUE), 
LegacySchemaMigrator.cachingFromRow("ROWS_ONLY"));
+         assertEquals(CachingParams.CACHE_KEYS, 
LegacySchemaMigrator.cachingFromRow("{\"keys\" : \"ALL\", 
\"rows_per_partition\" : \"NONE\"}" ));
+         assertEquals(new CachingParams(false, Integer.MAX_VALUE), 
LegacySchemaMigrator.cachingFromRow("{\"keys\" : \"NONE\", 
\"rows_per_partition\" : \"ALL\"}" ));
+         assertEquals(new CachingParams(true, 100), 
LegacySchemaMigrator.cachingFromRow("{\"keys\" : \"ALL\", 
\"rows_per_partition\" : \"100\"}" ));
+ 
+         try
+         {
+             LegacySchemaMigrator.cachingFromRow("EXCEPTION");
+             Assert.fail();
+         }
+         catch(RuntimeException e)
+         {
+             // Expected passing path
+             assertTrue(true);
+         }
+     }
+ 
 +    private static FieldIdentifier field(String field)
 +    {
 +        return FieldIdentifier.forQuoted(field);
 +    }
 +
      private static void loadLegacySchemaTables()
      {
 -        KeyspaceMetadata systemKeyspace = 
Schema.instance.getKSMetaData(SystemKeyspace.NAME);
 +        KeyspaceMetadata systemKeyspace = 
Schema.instance.getKSMetaData(SchemaConstants.SYSTEM_KEYSPACE_NAME);
  
          Tables systemTables = systemKeyspace.tables;
          for (CFMetaData table : LegacySchemaMigrator.LegacySchemaTables)

Reply via email to