cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject svn commit: r1211849 - in /cassandra/trunk: ./ contrib/ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/java/org/apache/cassandra/io/sstable/ test/data/legacy-sstables/hb/ test/data/legacy-sstables/hb/Keyspace1/ test/unit/org/apache/cassandr...
Date Thu, 08 Dec 2011 12:07:14 GMT
Author: slebresne
Date: Thu Dec  8 12:07:13 2011
New Revision: 1211849

URL: http://svn.apache.org/viewvc?rev=1211849&view=rev
Log:
merge from 1.0

Added:
    cassandra/trunk/test/data/legacy-sstables/hb/
      - copied from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/
      - copied from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Data.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Data.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Digest.sha1
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Digest.sha1
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Filter.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Filter.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Index.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Index.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Statistics.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1-hb-1-Statistics.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Data.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Data.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Digest.sha1
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Digest.sha1
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Filter.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Filter.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Index.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Index.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Statistics.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Statistics.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Data.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Data.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Digest.sha1
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Digest.sha1
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Filter.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Filter.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Index.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Index.db
    cassandra/trunk/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Statistics.db
      - copied unchanged from r1211848, cassandra/branches/cassandra-1.0/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Statistics.db
Modified:
    cassandra/trunk/   (props changed)
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/contrib/   (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java 
 (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java   (props
changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
  (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
  (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
  (props changed)
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
    cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java

Propchange: cassandra/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 12:07:13 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1209609,1210902,1211000,1211486
 /cassandra/branches/cassandra-0.8.0:1125021-1130369
 /cassandra/branches/cassandra-0.8.1:1101014-1125018
-/cassandra/branches/cassandra-1.0:1167085-1211632
+/cassandra/branches/cassandra-1.0:1167085-1211632,1211848
 /cassandra/branches/cassandra-1.0.0:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1:1102511-1125020

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1211849&r1=1211848&r2=1211849&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Thu Dec  8 12:07:13 2011
@@ -42,6 +42,7 @@
    (CASSANDRA-3558)
  * fix missing response during range slice repair (CASSANDRA-3551)
  * 'describe ring' moved from CLI to nodetool and available through JMX (CASSANDRA-3220)
+ * add back partitioner to sstable metadata (CASSANDRA-3540)
 Merged from 0.8:
  * use cannonical host for local node in nodetool info (CASSANDRA-3556)
  * detect misuses of CounterColumnType (CASSANDRA-3422)

Propchange: cassandra/trunk/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 12:07:13 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/contrib:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1209609,1210902,1211000,1211486
 /cassandra/branches/cassandra-0.8.0/contrib:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/contrib:1101014-1125018
-/cassandra/branches/cassandra-1.0/contrib:1167085-1211632
+/cassandra/branches/cassandra-1.0/contrib:1167085-1211632,1211848
 /cassandra/branches/cassandra-1.0.0/contrib:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/contrib:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/contrib:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 12:07:13 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1209609,1210902,1211000,1211486
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1167085-1211632
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1167085-1211632,1211848
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 12:07:13 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1209609,1210902,1211000,1211486
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1167085-1211632
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1167085-1211632,1211848
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 12:07:13 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1209609,1210902,1211000,1211486
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1167085-1211632
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1167085-1211632,1211848
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 12:07:13 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1209609,1210902,1211000,1211486
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1167085-1211632
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1167085-1211632,1211848
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 12:07:13 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090934-1125013,1125019-1198724,1198726-1206097,1206099-1209609,1210902,1211000,1211486
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1167085-1211632
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1167085-1211632,1211848
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1102511-1125020

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java?rev=1211849&r1=1211848&r2=1211849&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java Thu Dec
 8 12:07:13 2011
@@ -29,7 +29,6 @@ import java.io.IOException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.commitlog.ReplayPosition;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.utils.EstimatedHistogram;
@@ -67,7 +66,7 @@ public class SSTableMetadata
              ReplayPosition.NONE,
              Long.MIN_VALUE,
              Double.MIN_VALUE,
-             DatabaseDescriptor.getPartitioner().getClass().getCanonicalName());
+             null);
     }
 
     private SSTableMetadata(EstimatedHistogram rowSizes, EstimatedHistogram columnCounts,
ReplayPosition replayPosition, long maxTimestamp, double cr, String partitioner)
@@ -134,14 +133,14 @@ public class SSTableMetadata
             maxTimestamp = Math.max(maxTimestamp, potentialMax);
         }
 
-        public SSTableMetadata finalizeMetadata()
+        public SSTableMetadata finalizeMetadata(String partitioner)
         {
             return new SSTableMetadata(estimatedRowSize,
                                        estimatedColumnCount,
                                        replayPosition,
                                        maxTimestamp,
                                        compressionRatio,
-                                       DatabaseDescriptor.getPartitioner().getClass().getCanonicalName());
+                                       partitioner);
         }
 
         public Collector estimatedRowSize(EstimatedHistogram estimatedRowSize)
@@ -169,6 +168,8 @@ public class SSTableMetadata
 
         public void serialize(SSTableMetadata sstableStats, DataOutput dos) throws IOException
         {
+            assert sstableStats.partitioner != null;
+
             EstimatedHistogram.serializer.serialize(sstableStats.estimatedRowSize, dos);
             EstimatedHistogram.serializer.serialize(sstableStats.estimatedColumnCount, dos);
             ReplayPosition.serializer.serialize(sstableStats.replayPosition, dos);
@@ -209,9 +210,7 @@ public class SSTableMetadata
             double compressionRatio = desc.hasCompressionRatio
                                     ? dis.readDouble()
                                     : Double.MIN_VALUE;
-            String partitioner = desc.hasPartitioner
-                               ? dis.readUTF()
-                               : DatabaseDescriptor.getPartitioner().getClass().getCanonicalName();
+            String partitioner = desc.hasPartitioner ? dis.readUTF() : null;
             return new SSTableMetadata(rowSizes, columnCounts, replayPosition, maxTimestamp,
compressionRatio, partitioner);
         }
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java?rev=1211849&r1=1211848&r2=1211849&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java Thu Dec  8
12:07:13 2011
@@ -138,9 +138,11 @@ public class SSTableReader extends SSTab
                                         ? SSTableMetadata.serializer.deserialize(descriptor)
                                         : SSTableMetadata.createDefaultInstance();
 
-        // check if sstable is created using same partitioner as this node
+        // Check if sstable is created using same partitioner.
+        // Partitioner can be null, which indicates older version of sstable or no stats
available.
+        // In that case, we skip the check.
         String partitionerName = partitioner.getClass().getCanonicalName();
-        if (!partitionerName.equals(sstableMetadata.partitioner))
+        if (sstableMetadata.partitioner != null && !partitionerName.equals(sstableMetadata.partitioner))
             throw new RuntimeException(String.format("Cannot open %s because partitioner
does not match %s",
                                                      descriptor, partitionerName));
 

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java?rev=1211849&r1=1211848&r2=1211849&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java Thu Dec  8
12:07:13 2011
@@ -311,7 +311,7 @@ public class SSTableWriter extends SSTab
         dataFile.close();
 
         // write sstable statistics
-        SSTableMetadata sstableMetadata = sstableMetadataCollector.finalizeMetadata();
+        SSTableMetadata sstableMetadata = sstableMetadataCollector.finalizeMetadata(partitioner.getClass().getCanonicalName());
         writeMetadata(descriptor, sstableMetadata);
         maybeWriteDigest();
 

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java?rev=1211849&r1=1211848&r2=1211849&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java
(original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java
Thu Dec  8 12:07:13 2011
@@ -28,6 +28,7 @@ import java.io.IOException;
 import org.junit.Test;
 
 import org.apache.cassandra.db.commitlog.ReplayPosition;
+import org.apache.cassandra.dht.RandomPartitioner;
 import org.apache.cassandra.utils.EstimatedHistogram;
 
 public class SSTableMetadataSerializerTest
@@ -49,7 +50,7 @@ public class SSTableMetadataSerializerTe
                                                              .estimatedColumnCount(columnCounts)
                                                              .replayPosition(rp);
         collector.updateMaxTimestamp(maxTimestamp);
-        SSTableMetadata originalMetadata = collector.finalizeMetadata();
+        SSTableMetadata originalMetadata = collector.finalizeMetadata(RandomPartitioner.class.getCanonicalName());
 
         ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
         DataOutputStream dos = new DataOutputStream(byteOutput);
@@ -69,5 +70,6 @@ public class SSTableMetadataSerializerTe
         assert stats.replayPosition.equals(rp);
         assert stats.maxTimestamp == maxTimestamp;
         assert stats.maxTimestamp == originalMetadata.maxTimestamp;
+        assert RandomPartitioner.class.getCanonicalName().equals(stats.partitioner);
     }
 }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java?rev=1211849&r1=1211848&r2=1211849&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java Thu Dec
 8 12:07:13 2011
@@ -21,6 +21,7 @@ package org.apache.cassandra.io.sstable;
  */
 
 
+import java.io.File;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.ExecutionException;
@@ -33,14 +34,21 @@ import org.junit.Test;
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.*;
+import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.io.util.FileDataInput;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.io.util.MmappedSegmentedFile;
 import org.apache.cassandra.service.StorageService;
+import org.apache.cassandra.thrift.IndexClause;
+import org.apache.cassandra.thrift.IndexExpression;
+import org.apache.cassandra.thrift.IndexOperator;
 import org.apache.cassandra.utils.ByteBufferUtil;
+import org.apache.cassandra.utils.CLibrary;
 import org.apache.cassandra.utils.Pair;
 
 import org.apache.cassandra.Util;
@@ -188,6 +196,75 @@ public class SSTableReaderTest extends C
         assert p.right == p7;
     }
 
+    @Test
+    public void testPersistentStatisticsWithSecondaryIndex() throws IOException, ExecutionException,
InterruptedException
+    {
+        // Create secondary index and flush to disk
+        Table table = Table.open("Keyspace1");
+        ColumnFamilyStore store = table.getColumnFamilyStore("Indexed1");
+        ByteBuffer key = ByteBufferUtil.bytes(String.valueOf("k1"));
+        RowMutation rm = new RowMutation("Keyspace1", key);
+        rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L),
System.currentTimeMillis());
+        rm.apply();
+        store.forceBlockingFlush();
+
+        // check if opening and querying works
+        assertIndexQueryWorks(store);
+    }
+
+    @Test
+    public void testPersistentStatisticsFromOlderIndexedSSTable() throws IOException, ExecutionException,
InterruptedException
+    {
+        // copy legacy indexed sstables
+        String root = System.getProperty("legacy-sstable-root");
+        assert root != null;
+        File rootDir = new File(root + File.separator + "hb" + File.separator + "Keyspace1");
+        assert rootDir.isDirectory();
+
+        String[] destDirs = DatabaseDescriptor.getAllDataFileLocationsForTable("Keyspace1");
+        assert destDirs != null;
+        assert destDirs.length > 0;
+
+        FileUtils.createDirectory(destDirs[0]);
+        for (File srcFile : rootDir.listFiles())
+        {
+            if (!srcFile.getName().startsWith("Indexed1"))
+                continue;
+            File destFile = new File(destDirs[0] + File.separator + srcFile.getName());
+            CLibrary.createHardLinkWithExec(srcFile, destFile);
+
+            destFile = new File(destDirs[0] + File.separator + srcFile.getName());
+
+            assert destFile.exists() : destFile.getAbsoluteFile();
+        }
+        ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Indexed1");
+
+        // check if opening and querying works
+        assertIndexQueryWorks(store);
+    }
+
+    private void assertIndexQueryWorks(ColumnFamilyStore indexedCFS)
+    {
+        assert "Indexed1".equals(indexedCFS.getColumnFamilyName());
+
+        // make sure all sstables including 2ary indexes load from disk
+        indexedCFS.clearUnsafe();
+        for (ColumnFamilyStore indexCfs : indexedCFS.indexManager.getIndexesBackedByCfs())
+        {
+            indexCfs.clearUnsafe();
+            indexCfs.loadNewSSTables(); // v1.0.4 would fail here (see CASSANDRA-3540)
+        }
+        indexedCFS.loadNewSSTables();
+
+        // query using index to see if sstable for secondary index opens
+        IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
ByteBufferUtil.bytes(1L));
+        IndexClause clause = new IndexClause(Arrays.asList(expr), ByteBufferUtil.EMPTY_BYTE_BUFFER,
100);
+        IPartitioner p = StorageService.getPartitioner();
+        Range range = new Range(p.getMinimumToken(), p.getMinimumToken());
+        List<Row> rows = indexedCFS.search(clause, range, new IdentityQueryFilter());
+        assert rows.size() == 1;
+    }
+
     private List<Range<Token>> makeRanges(Token left, Token right)
     {
         return Arrays.<Range<Token>>asList(new Range[]{ new Range<Token>(left,
right) });



Mime
View raw message