merge from 2.1.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/24d85715 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/24d85715 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/24d85715 Branch: refs/heads/cassandra-2.1 Commit: 24d85715045fb32b4fb59341c3eec18502a7d979 Parents: 78b734e 33de6dc Author: Jonathan Ellis <jbel...@apache.org> Authored: Thu Aug 7 09:25:17 2014 -0500 Committer: Jonathan Ellis <jbel...@apache.org> Committed: Thu Aug 7 09:25:17 2014 -0500 ---------------------------------------------------------------------- CHANGES.txt | 2 + .../DebuggableThreadPoolExecutor.java | 8 +- .../db/compaction/CompactionManager.java | 4 +- .../apache/cassandra/tools/SSTableExport.java | 131 +++++++++++-------- 4 files changed, 83 insertions(+), 62 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/24d85715/CHANGES.txt ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/24d85715/src/java/org/apache/cassandra/db/compaction/CompactionManager.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/24d85715/src/java/org/apache/cassandra/tools/SSTableExport.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/tools/SSTableExport.java index c4d693c,3572296..cc725a4 --- a/src/java/org/apache/cassandra/tools/SSTableExport.java +++ b/src/java/org/apache/cassandra/tools/SSTableExport.java @@@ -226,20 -228,26 +226,26 @@@ public class SSTableExpor throws IOException { KeyIterator iter = new KeyIterator(desc); - DecoratedKey lastKey = null; - while (iter.hasNext()) + try { - DecoratedKey key = iter.next(); - - // validate order of the keys in the sstable - if (lastKey != null && lastKey.compareTo(key) > 0) - throw new IOException("Key out of order! " + lastKey + " > " + key); - lastKey = key; - - outs.println(metadata.getKeyValidator().getString(key.getKey())); - checkStream(outs); // flushes + DecoratedKey lastKey = null; + while (iter.hasNext()) + { + DecoratedKey key = iter.next(); + + // validate order of the keys in the sstable + if (lastKey != null && lastKey.compareTo(key) > 0) + throw new IOException("Key out of order! " + lastKey + " > " + key); + lastKey = key; + - outs.println(bytesToHex(key.getKey())); ++ outs.println(metadata.getKeyValidator().getString(key.getKey())); + checkStream(outs); // flushes + } + } + finally + { + iter.close(); } - iter.close(); } /** @@@ -256,47 -263,53 +262,53 @@@ { SSTableReader sstable = SSTableReader.open(desc); RandomAccessReader dfile = sstable.openDataReader(); + try + { + IPartitioner<?> partitioner = sstable.partitioner; - IPartitioner<?> partitioner = sstable.partitioner; + if (excludes != null) + toExport.removeAll(Arrays.asList(excludes)); - if (excludes != null) - toExport.removeAll(Arrays.asList(excludes)); + outs.println("["); - outs.println("["); + int i = 0; - int i = 0; + // last key to compare order + DecoratedKey lastKey = null; - // last key to compare order - DecoratedKey lastKey = null; + for (String key : toExport) + { - DecoratedKey decoratedKey = partitioner.decorateKey(hexToBytes(key)); ++ DecoratedKey decoratedKey = partitioner.decorateKey(metadata.getKeyValidator().fromString(key)); - for (String key : toExport) - { - DecoratedKey decoratedKey = partitioner.decorateKey(metadata.getKeyValidator().fromString(key)); + if (lastKey != null && lastKey.compareTo(decoratedKey) > 0) + throw new IOException("Key out of order! " + lastKey + " > " + decoratedKey); - if (lastKey != null && lastKey.compareTo(decoratedKey) > 0) - throw new IOException("Key out of order! " + lastKey + " > " + decoratedKey); + lastKey = decoratedKey; - lastKey = decoratedKey; + RowIndexEntry entry = sstable.getPosition(decoratedKey, SSTableReader.Operator.EQ); + if (entry == null) + continue; - RowIndexEntry entry = sstable.getPosition(decoratedKey, SSTableReader.Operator.EQ); - if (entry == null) - continue; + dfile.seek(entry.position); + ByteBufferUtil.readWithShortLength(dfile); // row key + DeletionInfo deletionInfo = new DeletionInfo(DeletionTime.serializer.deserialize(dfile)); - dfile.seek(entry.position); - ByteBufferUtil.readWithShortLength(dfile); // row key - DeletionInfo deletionInfo = new DeletionInfo(DeletionTime.serializer.deserialize(dfile)); - Iterator<OnDiskAtom> atomIterator = sstable.metadata.getOnDiskIterator(dfile, sstable.descriptor.version); + Iterator<OnDiskAtom> atomIterator = sstable.metadata.getOnDiskIterator(dfile, sstable.descriptor.version); + checkStream(outs); - checkStream(outs); + if (i != 0) + outs.println(","); + i++; + serializeRow(deletionInfo, atomIterator, sstable.metadata, decoratedKey, outs); + } - if (i != 0) - outs.println(","); - i++; - serializeRow(deletionInfo, atomIterator, sstable.metadata, decoratedKey, outs); + outs.println("\n]"); + outs.flush(); + } + finally + { + dfile.close(); } - - outs.println("\n]"); - outs.flush(); } // This is necessary to accommodate the test suite since you cannot open a Reader more @@@ -308,36 -321,39 +320,39 @@@ if (excludes != null) excludeSet = new HashSet<String>(Arrays.asList(excludes)); - SSTableIdentityIterator row; SSTableScanner scanner = reader.getScanner(); + try + { + outs.println("["); - outs.println("["); + int i = 0; - int i = 0; + // collecting keys to export + while (scanner.hasNext()) + { + row = (SSTableIdentityIterator) scanner.next(); - // collecting keys to export - while (scanner.hasNext()) - { - row = (SSTableIdentityIterator) scanner.next(); - String currentKey = bytesToHex(row.getKey().getKey()); ++ String currentKey = row.getColumnFamily().metadata().getKeyValidator().getString(row.getKey().getKey()); - String currentKey = row.getColumnFamily().metadata().getKeyValidator().getString(row.getKey().getKey()); + if (excludeSet.contains(currentKey)) + continue; + else if (i != 0) + outs.println(","); - if (excludeSet.contains(currentKey)) - continue; - else if (i != 0) - outs.println(","); + serializeRow(row, row.getKey(), outs); + checkStream(outs); - serializeRow(row, row.getKey(), outs); - checkStream(outs); + i++; + } - i++; + outs.println("\n]"); + outs.flush(); + } + finally + { + scanner.close(); } - - outs.println("\n]"); - outs.flush(); - - scanner.close(); } /**