cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [3/5] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0
Date Thu, 26 Nov 2015 07:51:35 GMT
Merge branch 'cassandra-2.2' into cassandra-3.0


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

Branch: refs/heads/trunk
Commit: 71bca78006829221c92cc336878da36bb846d28e
Parents: 5fd6c54 96b7603
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Thu Nov 26 08:36:33 2015 +0100
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Thu Nov 26 08:36:33 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../db/compaction/CompactionManager.java        |  6 +-
 .../org/apache/cassandra/db/CleanupTest.java    | 77 ++++++++++++++++++++
 3 files changed, 82 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/71bca780/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index f95f079,a548c9f..db6c72f
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -13,8 -3,18 +13,9 @@@ Merged from 2.2
   * Fix SimpleDateType type compatibility (CASSANDRA-10027)
   * (Hadoop) fix splits calculation (CASSANDRA-10640)
   * (Hadoop) ensure that Cluster instances are always closed (CASSANDRA-10058)
 - * (cqlsh) show partial trace if incomplete after max_trace_wait (CASSANDRA-7645)
 - * Use most up-to-date version of schema for system tables (CASSANDRA-10652)
 - * Deprecate memory_allocator in cassandra.yaml (CASSANDRA-10581,10628)
 - * Expose phi values from failure detector via JMX and tweak debug
 -   and trace logging (CASSANDRA-9526)
 - * Fix RangeNamesQueryPager (CASSANDRA-10509)
 - * Deprecate Pig support (CASSANDRA-10542)
 - * Reduce contention getting instances of CompositeType (CASSANDRA-10433)
  Merged from 2.1:
+  * Fix the sstable-needs-cleanup check (CASSANDRA-10740)
   * (cqlsh) Print column names before COPY operation (CASSANDRA-8935)
 - * Make paging logic consistent between searcher impls (CASSANDRA-10683)
   * Fix CompressedInputStream for proper cleanup (CASSANDRA-10012)
   * (cqlsh) Support counters in COPY commands (CASSANDRA-9043)
   * Try next replica if not possible to connect to primary replica on

http://git-wip-us.apache.org/repos/asf/cassandra/blob/71bca780/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/71bca780/test/unit/org/apache/cassandra/db/CleanupTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/CleanupTest.java
index a4aca7f,0115ad9..167f3b0
--- a/test/unit/org/apache/cassandra/db/CleanupTest.java
+++ b/test/unit/org/apache/cassandra/db/CleanupTest.java
@@@ -32,15 -35,19 +35,17 @@@ import org.junit.Test
  
  import org.apache.cassandra.SchemaLoader;
  import org.apache.cassandra.Util;
 -import org.apache.cassandra.config.KSMetaData;
 +import org.apache.cassandra.config.ColumnDefinition;
  import org.apache.cassandra.cql3.Operator;
 -import org.apache.cassandra.db.filter.IDiskAtomFilter;
 -import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
  import org.apache.cassandra.db.compaction.CompactionManager;
 -import org.apache.cassandra.db.index.SecondaryIndex;
 +import org.apache.cassandra.db.filter.RowFilter;
  import org.apache.cassandra.dht.ByteOrderedPartitioner.BytesToken;
+ import org.apache.cassandra.dht.Range;
  import org.apache.cassandra.exceptions.ConfigurationException;
  import org.apache.cassandra.io.sstable.format.SSTableReader;
 -import org.apache.cassandra.locator.SimpleStrategy;
+ import org.apache.cassandra.dht.Token;
  import org.apache.cassandra.locator.TokenMetadata;
 +import org.apache.cassandra.schema.KeyspaceParams;
  import org.apache.cassandra.service.StorageService;
  import org.apache.cassandra.utils.ByteBufferUtil;
  
@@@ -165,10 -182,83 +170,82 @@@ public class CleanupTes
          tmd.updateNormalToken(new BytesToken(tk2), InetAddress.getByName("127.0.0.2"));
          CompactionManager.instance.performCleanup(cfs);
  
 -        rows = Util.getRangeSlice(cfs);
 -        assertEquals(0, rows.size());
 +        assertEquals(0, Util.getAll(Util.cmd(cfs).build()).size());
      }
  
+     @Test
+     public void testNeedsCleanup() throws Exception
+     {
+         // setup
+         StorageService.instance.getTokenMetadata().clearUnsafe();
+         Keyspace keyspace = Keyspace.open(KEYSPACE1);
 -        ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF1);
 -        fillCF(cfs, LOOPS);
++        ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARD1);
++        fillCF(cfs, "val", LOOPS);
+ 
+         // prepare SSTable and some useful tokens
 -        SSTableReader ssTable = cfs.getSSTables().iterator().next();
++        SSTableReader ssTable = cfs.getLiveSSTables().iterator().next();
+         final Token ssTableMin = ssTable.first.getToken();
+         final Token ssTableMax = ssTable.last.getToken();
+ 
+         final Token min = token((byte) 0);
+         final Token before1 = token((byte) 2);
+         final Token before2 = token((byte) 5);
+         final Token before3 = token((byte) 10);
+         final Token before4 = token((byte) 47);
+         final Token insideSsTable1 = token((byte) 50);
+         final Token insideSsTable2 = token((byte) 55);
+         final Token max = token((byte) 127, (byte) 127, (byte) 127, (byte) 127);
+ 
+         // test sanity check
+         assert (min.compareTo(ssTableMin) < 0);
+         assert (before1.compareTo(ssTableMin) < 0);
+         assert (before2.compareTo(ssTableMin) < 0);
+         assert (before3.compareTo(ssTableMin) < 0);
+         assert (before4.compareTo(ssTableMin) < 0);
+         assert (ssTableMin.compareTo(insideSsTable1) < 0);
+         assert (insideSsTable1.compareTo(ssTableMax) < 0);
+         assert (ssTableMin.compareTo(insideSsTable2) < 0);
+         assert (insideSsTable2.compareTo(ssTableMax) < 0);
+         assert (ssTableMax.compareTo(max) < 0);
+ 
+         // test cases
+         // key: needs cleanup?
+         // value: owned ranges
+         List<Map.Entry<Boolean, List<Range<Token>>>> testCases =
new LinkedList<Map.Entry<Boolean, List<Range<Token>>>>()
+         {
+             {
+                 add(entry(false, Arrays.asList(range(min, max)))); // SSTable owned as a
whole
+                 add(entry(true, Arrays.asList(range(min, insideSsTable1)))); // SSTable
owned only partially
+                 add(entry(true, Arrays.asList(range(insideSsTable1, max)))); // SSTable
owned only partially
+                 add(entry(true, Arrays.asList(range(min, ssTableMin)))); // SSTable not
owned at all
+                 add(entry(true, Arrays.asList(range(ssTableMax, max)))); // only last token
of SSTable is owned
+                 add(entry(true, Arrays.asList(range(min, insideSsTable1), range(insideSsTable2,
max)))); // SSTable partially owned by two ranges
+                 add(entry(true, Arrays.asList(range(ssTableMin, ssTableMax)))); // first
token of SSTable is not owned
+                 add(entry(false, Arrays.asList(range(before4, max)))); // first token of
SSTable is not owned
+                 add(entry(false, Arrays.asList(range(min, before1), range(before2, before3),
range(before4, max)))); // SSTable owned by the last range
+             }
+         };
+ 
+         // check all test cases
+         for (Map.Entry<Boolean, List<Range<Token>>> testCase : testCases)
+         {
+             assertEquals(testCase.getKey(), CompactionManager.needsCleanup(ssTable, testCase.getValue()));
+         }
+     }
+     private static BytesToken token(byte ... value)
+     {
+         return new BytesToken(value);
+     }
+     private static <K, V> Map.Entry<K, V> entry(K k, V v)
+     {
+        return new AbstractMap.SimpleEntry<K, V>(k, v);
+     }
+     private static Range<Token> range(Token from, Token to)
+     {
+         return new Range<>(from, to);
+     }
+ 
 -    protected void fillCF(ColumnFamilyStore cfs, int rowsPerSSTable)
 +    protected void fillCF(ColumnFamilyStore cfs, String colName, int rowsPerSSTable)
      {
          CompactionManager.instance.disableAutoCompaction();
  


Mime
View raw message