cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1045359 - in /cassandra/trunk: ./ contrib/word_count/ contrib/word_count/bin/ contrib/word_count/src/ debian/ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/java/org/apache/cassandra/avro/ src/java/org/apache/cassandra/cli/ src...
Date Mon, 13 Dec 2010 20:24:55 GMT
Author: jbellis
Date: Mon Dec 13 20:24:53 2010
New Revision: 1045359

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

Added:
    cassandra/trunk/debian/cassandra.conf
      - copied unchanged from r1045337, cassandra/branches/cassandra-0.7/debian/cassandra.conf
Modified:
    cassandra/trunk/   (props changed)
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/contrib/word_count/README.txt
    cassandra/trunk/contrib/word_count/bin/word_count
    cassandra/trunk/contrib/word_count/src/WordCount.java
    cassandra/trunk/debian/cassandra.install
    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/avro/CassandraServer.java
    cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g
    cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java
    cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
    cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java
    cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java
    cassandra/trunk/test/unit/org/apache/cassandra/cli/CliTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/NameSortTest.java

Propchange: cassandra/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 13 20:24:53 2010
@@ -1,5 +1,5 @@
-/cassandra/branches/cassandra-0.6:922689-1041242
-/cassandra/branches/cassandra-0.7:1026517-1043987
+/cassandra/branches/cassandra-0.6:922689-1044118
+/cassandra/branches/cassandra-0.7:1026517-1045337
 /incubator/cassandra/branches/cassandra-0.3:774578-796573
 /incubator/cassandra/branches/cassandra-0.4:810145-834239,834349-834350
 /incubator/cassandra/branches/cassandra-0.5:888872-915439

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Mon Dec 13 20:24:53 2010
@@ -5,7 +5,14 @@
 0.7-dev
  * expose getNaturalEndpoints in StorageServiceMBean taking byte[]
    key; RMI cannot serialize ByteBuffer (CASSANDRA-1833)
+ * infer org.apache.cassandra.locator for replication strategy classes
+   when not otherwise specified
  * validation that generates less garbage (CASSANDRA-1814)
+ * add TTL support to CLI (CASSANDRA-1838)
+ * cli defaults to bytestype for subcomparator when creating
+   column families (CASSANDRA-1835)
+ * unregister index MBeans when index is dropped (CASSANDRA-1843)
+ * make ByteBufferUtil.clone thread-safe (CASSANDRA-1847)
 
 
 0.7.0-rc2
@@ -59,8 +66,9 @@
  * Fix misuse of DataOutputBuffer.getData in AntiEntropyService
    (CASSANDRA-1729)
  * detect and warn when obsolete version of JNA is present (CASSANDRA-1770)
-
-
+ * reduce fat client timeout (CASSANDRA-1730)
+ * cleanup smallest CFs first to increase free temp space for larger ones
+   (CASSANDRA-1811)
  * Update windows .bat files to work outside of main Cassandra
    directory (CASSANDRA-1713)
  * fix read repair regression from 0.6.7 (CASSANDRA-1727)

Modified: cassandra/trunk/contrib/word_count/README.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/contrib/word_count/README.txt?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/contrib/word_count/README.txt (original)
+++ cassandra/trunk/contrib/word_count/README.txt Mon Dec 13 20:24:53 2010
@@ -10,19 +10,19 @@ contrib/word_count$ ant
 contrib/word_count$ bin/word_count_setup
 contrib/word_count$ bin/word_count
 
-The output of the word count can now be configured. In the bin/word_count
-file, you can specify the OUTPUT_REDUCER. The two options are 'filesystem'
-and 'cassandra'. The filesystem option outputs to the /tmp/word_count*
-directories. The cassandra option outputs to the 'output_words' column family
-in the 'wordcount' keyspace.
-
 In order to view the results in Cassandra, one can use bin/cassandra-cli and
 perform the following operations:
 $ bin/cassandra-cli
-> connect localhost/9160
+> connect localhost/9160;
 > use wordcount;
 > list output_words;
 
+The output of the word count can now be configured. In the bin/word_count
+file, you can specify the OUTPUT_REDUCER. The two options are 'filesystem'
+and 'cassandra'. The filesystem option outputs to the /tmp/word_count*
+directories. The cassandra option outputs to the 'output_words' column family
+in the 'wordcount' keyspace.  'cassandra' is the default.
+
 Read the code in src/ for more details.
 
 *If you want to point wordcount at a real cluster, modify the seed

Modified: cassandra/trunk/contrib/word_count/bin/word_count
URL: http://svn.apache.org/viewvc/cassandra/trunk/contrib/word_count/bin/word_count?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/contrib/word_count/bin/word_count (original)
+++ cassandra/trunk/contrib/word_count/bin/word_count Mon Dec 13 20:24:53 2010
@@ -53,7 +53,7 @@ if [ "x$JAVA" = "x" ]; then
     exit 1
 fi
 
-OUTPUT_REDUCER=filesystem
+OUTPUT_REDUCER=cassandra
 
 #echo $CLASSPATH
 $JAVA -Xmx1G -ea -cp $CLASSPATH WordCount output_reducer=$OUTPUT_REDUCER

Modified: cassandra/trunk/contrib/word_count/src/WordCount.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/contrib/word_count/src/WordCount.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/contrib/word_count/src/WordCount.java (original)
+++ cassandra/trunk/contrib/word_count/src/WordCount.java Mon Dec 13 20:24:53 2010
@@ -49,6 +49,9 @@ import org.apache.hadoop.util.ToolRunner
  * "text" containing a sequence of words.
  *
  * For each word, we output the total number of occurrences across all texts.
+ *
+ * When outputting to Cassandra, we write the word counts as a {word, count} column/value pair,
+ * with a row key equal to the name of the source column we read the words from.
  */
 public class WordCount extends Configured implements Tool
 {
@@ -74,11 +77,17 @@ public class WordCount extends Configure
     {
         private final static IntWritable one = new IntWritable(1);
         private Text word = new Text();
-        private ByteBuffer columnName;
+        private ByteBuffer sourceColumn;
+
+        protected void setup(org.apache.hadoop.mapreduce.Mapper.Context context)
+        throws IOException, InterruptedException
+        {
+            sourceColumn = ByteBuffer.wrap(context.getConfiguration().get(CONF_COLUMN_NAME).getBytes());
+        }
 
         public void map(ByteBuffer key, SortedMap<ByteBuffer, IColumn> columns, Context context) throws IOException, InterruptedException
         {
-            IColumn column = columns.get(columnName);
+            IColumn column = columns.get(sourceColumn);
             if (column == null)
                 return;
             String value = ByteBufferUtil.string(column.value());
@@ -91,78 +100,49 @@ public class WordCount extends Configure
                 context.write(word, one);
             }
         }
-
-        protected void setup(org.apache.hadoop.mapreduce.Mapper.Context context)
-            throws IOException, InterruptedException
-        {
-            this.columnName = ByteBuffer.wrap(context.getConfiguration().get(CONF_COLUMN_NAME).getBytes());
-        }
-        
     }
 
     public static class ReducerToFilesystem extends Reducer<Text, IntWritable, Text, IntWritable>
     {
-        private IntWritable result = new IntWritable();
-
         public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException
         {
             int sum = 0;
             for (IntWritable val : values)
-            {
                 sum += val.get();
-            }
-
-            result.set(sum);
-            context.write(key, result);
+            context.write(key, new IntWritable(sum));
         }
     }
 
     public static class ReducerToCassandra extends Reducer<Text, IntWritable, ByteBuffer, List<Mutation>>
     {
-        private List<Mutation> results = new ArrayList<Mutation>();
-        private String columnName;
-
-        public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException
-        {
-            int sum = 0;
-            for (IntWritable val : values)
-            {
-                sum += val.get();
-            }
-
-            results.add(getMutation(key, sum));
-            context.write(ByteBuffer.wrap(columnName.getBytes()), results);
-            results.clear();
-        }
+        private ByteBuffer outputKey;
 
         protected void setup(org.apache.hadoop.mapreduce.Reducer.Context context)
-            throws IOException, InterruptedException
+        throws IOException, InterruptedException
         {
-            this.columnName = context.getConfiguration().get(CONF_COLUMN_NAME);
+            outputKey = ByteBuffer.wrap(context.getConfiguration().get(CONF_COLUMN_NAME).getBytes());
         }
 
-        private static Mutation getMutation(Text key, int sum)
+        public void reduce(Text word, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException
         {
-            Mutation m = new Mutation();
-            m.column_or_supercolumn = getCoSC(key, sum);
-            return m;
+            int sum = 0;
+            for (IntWritable val : values)
+                sum += val.get();
+            context.write(outputKey, Collections.singletonList(getMutation(word, sum)));
         }
 
-        private static ColumnOrSuperColumn getCoSC(Text key, int sum)
+        private static Mutation getMutation(Text word, int sum)
         {
-            // Have to convert both the key and the sum to ByteBuffers
-            // for the generalized output format
-            ByteBuffer name = ByteBuffer.wrap(key.getBytes());
-            ByteBuffer value = ByteBuffer.wrap(String.valueOf(sum).getBytes());
-
             Column c = new Column();
-            c.name = name;
-            c.value = value;
+            byte[] wordBytes = word.getBytes();
+            c.name = ByteBuffer.wrap(Arrays.copyOf(wordBytes, wordBytes.length));
+            c.value = ByteBuffer.wrap(String.valueOf(sum).getBytes());
             c.timestamp = System.currentTimeMillis() * 1000;
-            c.ttl = 0;
-            ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
-            cosc.column = c;
-            return cosc;
+
+            Mutation m = new Mutation();
+            m.column_or_supercolumn = new ColumnOrSuperColumn();
+            m.column_or_supercolumn.column = c;
+            return m;
         }
     }
 
@@ -204,7 +184,7 @@ public class WordCount extends Configure
                 job.setOutputValueClass(List.class);
 
                 job.setOutputFormatClass(ColumnFamilyOutputFormat.class);
-                
+
                 ConfigHelper.setOutputColumnFamily(job.getConfiguration(), KEYSPACE, OUTPUT_COLUMN_FAMILY);
             }
 

Modified: cassandra/trunk/debian/cassandra.install
URL: http://svn.apache.org/viewvc/cassandra/trunk/debian/cassandra.install?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/debian/cassandra.install (original)
+++ cassandra/trunk/debian/cassandra.install Mon Dec 13 20:24:53 2010
@@ -2,6 +2,7 @@ conf/log4j-server.properties etc/cassand
 conf/cassandra.yaml etc/cassandra
 conf/cassandra-env.sh etc/cassandra
 debian/cassandra.in.sh usr/share/cassandra
+debian/cassandra.conf etc/security/limits.d
 bin/cassandra usr/sbin
 bin/cassandra-cli usr/bin
 bin/nodetool usr/bin

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 13 20:24:53 2010
@@ -1,5 +1,5 @@
-/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:922689-1041242
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1026517-1043987
+/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:922689-1044118
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1026517-1045337
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/Cassandra.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/Cassandra.java:810145-834239,834349-834350
 /incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/Cassandra.java:888872-903502

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 13 20:24:53 2010
@@ -1,5 +1,5 @@
-/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:922689-1041242
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1026517-1043987
+/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:922689-1044118
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1026517-1045337
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/column_t.java:774578-792198
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/Column.java:810145-834239,834349-834350
 /incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/Column.java:888872-903502

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 13 20:24:53 2010
@@ -1,5 +1,5 @@
-/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:922689-1041242
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1026517-1043987
+/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:922689-1044118
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1026517-1045337
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:810145-834239,834349-834350
 /incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:888872-903502

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 13 20:24:53 2010
@@ -1,5 +1,5 @@
-/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:922689-1041242
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1026517-1043987
+/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:922689-1044118
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1026517-1045337
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:810145-834239,834349-834350
 /incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:888872-903502

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 13 20:24:53 2010
@@ -1,5 +1,5 @@
-/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:922689-1041242
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1026517-1043987
+/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:922689-1044118
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1026517-1045337
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/superColumn_t.java:774578-792198
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/SuperColumn.java:810145-834239,834349-834350
 /incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/SuperColumn.java:888872-903502

Modified: cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java Mon Dec 13 20:24:53 2010
@@ -47,12 +47,10 @@ import org.apache.avro.ipc.AvroRemoteExc
 import org.apache.avro.util.Utf8;
 import org.apache.cassandra.concurrent.Stage;
 import org.apache.cassandra.db.migration.DropKeyspace;
-import org.apache.cassandra.db.migration.RenameKeyspace;
 import org.apache.cassandra.db.migration.UpdateColumnFamily;
 import org.apache.cassandra.db.migration.UpdateKeyspace;
 import org.apache.cassandra.dht.*;
-import org.apache.cassandra.gms.Gossiper;
-import org.apache.cassandra.utils.FBUtilities;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -72,7 +70,6 @@ import org.apache.cassandra.db.migration
 import org.apache.cassandra.db.migration.AddKeyspace;
 import org.apache.cassandra.db.migration.DropColumnFamily;
 import org.apache.cassandra.db.migration.Migration;
-import org.apache.cassandra.db.migration.RenameColumnFamily;
 import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.scheduler.IRequestScheduler;
 import org.apache.cassandra.service.ClientState;
@@ -652,7 +649,7 @@ public class CassandraServer implements 
 
             KSMetaData ksmeta = new KSMetaData(
                     ksDef.name.toString(),
-                    FBUtilities.<AbstractReplicationStrategy>classForName(ksDef.strategy_class.toString(), "keyspace replication strategy"),
+                    AbstractReplicationStrategy.getClass(ksDef.strategy_class.toString()),
                     strategyOptions,
                     ksDef.replication_factor,
                     cfDefs.toArray(new CFMetaData[cfDefs.size()]));
@@ -744,7 +741,7 @@ public class CassandraServer implements 
             
             KSMetaData ksm = new KSMetaData(
                     ks_def.name.toString(), 
-                    (Class<? extends AbstractReplicationStrategy>) FBUtilities.<AbstractReplicationStrategy>classForName(ks_def.strategy_class.toString(), "keyspace replication strategy"),
+                    AbstractReplicationStrategy.getClass(ks_def.strategy_class.toString()),
                     strategyOptions,
                     ks_def.replication_factor);
             applyMigrationOnStage(new UpdateKeyspace(ksm));

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/Cli.g Mon Dec 13 20:24:53 2010
@@ -240,8 +240,8 @@ typeIdentifier
     ;
 
 setStatement
-    : SET columnFamilyExpr '=' value 
-        -> ^(NODE_THRIFT_SET columnFamilyExpr value)
+    : SET columnFamilyExpr '=' objectValue=value (WITH TTL '=' ttlValue=value)?
+        -> ^(NODE_THRIFT_SET columnFamilyExpr $objectValue ( $ttlValue )?)
     ;
 
 countStatement
@@ -525,6 +525,7 @@ LIST:       'LIST';
 LIMIT:      'LIMIT';
 TRUNCATE:   'TRUNCATE';
 ASSUME:     'ASSUME';
+TTL:        'TTL';
 
 IP_ADDRESS 
     : IntegerLiteral '.' IntegerLiteral '.' IntegerLiteral '.' IntegerLiteral

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java Mon Dec 13 20:24:53 2010
@@ -319,8 +319,9 @@ public class CliClient extends CliUserHe
                 for (Column col : superColumn.getColumns())
                 {
                     validator = getValidatorForValue(cfDef, col.getName());
-                    sessionState.out.printf("%n     (column=%s, value=%s, timestamp=%d)", formatSubcolumnName(keyspace, columnFamily, col),
-                                    validator.getString(col.value), col.timestamp);
+                    sessionState.out.printf("%n     (column=%s, value=%s, timestamp=%d%s)", formatSubcolumnName(keyspace, columnFamily, col),
+                                                    validator.getString(col.value), col.timestamp,
+                                                    col.isSetTtl() ? String.format(", ttl=%d", col.getTtl()) : "");
                 }
                 
                 sessionState.out.println(")");
@@ -329,8 +330,9 @@ public class CliClient extends CliUserHe
             {
                 Column column = cosc.column;
                 validator = getValidatorForValue(cfDef, column.getName());
-                sessionState.out.printf("=> (column=%s, value=%s, timestamp=%d)%n", formatColumnName(keyspace, columnFamily, column),
-                                validator.getString(column.value), column.timestamp);
+                sessionState.out.printf("=> (column=%s, value=%s, timestamp=%d%s)%n", formatColumnName(keyspace, columnFamily, column),
+                                                validator.getString(column.value), column.timestamp,
+                                                column.isSetTtl() ? String.format(", ttl=%d", column.getTtl()) : "");
             }
         }
         
@@ -453,8 +455,9 @@ public class CliClient extends CliUserHe
         }
 
         // print results
-        sessionState.out.printf("=> (column=%s, value=%s, timestamp=%d)%n",
-                                formatColumnName(keySpace, columnFamily, column), valueAsString, column.timestamp);
+        sessionState.out.printf("=> (column=%s, value=%s, timestamp=%d%s)%n",
+                                formatColumnName(keySpace, columnFamily, column), valueAsString, column.timestamp,
+                                column.isSetTtl() ? String.format(", ttl=%d", column.getTtl()) : "");
     }
 
     /**
@@ -612,10 +615,30 @@ public class CliClient extends CliUserHe
         if(superColumnName != null)
             parent.setSuper_column(superColumnName);
 
-        // do the insert
-        thriftClient.insert(getKeyAsBytes(columnFamily, keyTree), parent, new Column(columnName, columnValueInBytes,
-                FBUtilities.timestampMicros()), ConsistencyLevel.ONE);
+        Column columnToInsert = new Column(columnName, columnValueInBytes, FBUtilities.timestampMicros());
         
+        // children count = 3 mean that we have ttl in arguments
+        if (statement.getChildCount() == 3)
+        {
+            String ttl = statement.getChild(2).getText();
+
+            try
+            {
+                columnToInsert.setTtl(Integer.valueOf(ttl));
+            }
+            catch (NumberFormatException e)
+            {
+                sessionState.err.println(String.format("TTL '%s' is invalid, should be a positive integer.", ttl));
+                return;
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException(e.getMessage());
+            }
+        }
+
+        // do the insert
+        thriftClient.insert(getKeyAsBytes(columnFamily, keyTree), parent, columnToInsert, ConsistencyLevel.ONE);
         sessionState.out.println("Value inserted.");
     }
 
@@ -1521,6 +1544,13 @@ public class CliClient extends CliUserHe
     private ByteBuffer subColumnNameAsBytes(String superColumn, CfDef columnFamilyDef) 
     {
         String comparatorClass = columnFamilyDef.subcomparator_type;
+
+        if (comparatorClass == null)
+        {
+            sessionState.out.println(String.format("Notice: defaulting to BytesType subcomparator for '%s'", columnFamilyDef.getName()));
+            comparatorClass = "BytesType";
+        }
+
         return getBytesAccordingToType(superColumn, getFormatTypeForColumn(comparatorClass));   
     }
 
@@ -1814,8 +1844,9 @@ public class CliClient extends CliUserHe
                     Column col = columnOrSuperColumn.column;
                     validator = getValidatorForValue(columnFamilyDef, col.getName());
 
-                    sessionState.out.printf("=> (column=%s, value=%s, timestamp=%d)%n",
-                                    formatColumnName(keySpace, columnFamilyName, col), validator.getString(col.value), col.timestamp);
+                    sessionState.out.printf("=> (column=%s, value=%s, timestamp=%d%s)%n",
+                                    formatColumnName(keySpace, columnFamilyName, col), validator.getString(col.value), col.timestamp,
+                                    col.isSetTtl() ? String.format(", ttl=%d", col.getTtl()) : "");
                 }
                 else if (columnOrSuperColumn.super_column != null)
                 {
@@ -1826,8 +1857,9 @@ public class CliClient extends CliUserHe
                     {
                         validator = getValidatorForValue(columnFamilyDef, col.getName());
 
-                        sessionState.out.printf("%n     (column=%s, value=%s, timestamp=%d)",
-                                        formatSubcolumnName(keySpace, columnFamilyName, col), validator.getString(col.value), col.timestamp);
+                        sessionState.out.printf("%n     (column=%s, value=%s, timestamp=%d%s)",
+                                        formatSubcolumnName(keySpace, columnFamilyName, col), validator.getString(col.value), col.timestamp,
+                                        col.isSetTtl() ? String.format(", ttl=%d", col.getTtl()) : "");
                     }
 
                     sessionState.out.println(")");

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/CliUserHelp.java Mon Dec 13 20:24:53 2010
@@ -248,12 +248,15 @@ public class CliUserHelp {
                 state.out.println("set <cf>['<key>']['<col>'] = <function>(<argument>);");
                 state.out.println("set <cf>['<key>']['<super>']['<col>'] = <function>(<argument>);");
                 state.out.println("set <cf>[<key>][<function>(<col>)] = <value> || <function>;");
+                state.out.println("set <cf>[<key>][<function>(<col>) || <col>] = <value> || <function> with ttl = <secs>;");
                 state.out.println("Available functions: " + CliClient.Function.getFunctionNames() + "\n");
                 state.out.println("examples:");
                 state.out.println("set bar['testkey']['my super']['test col']='this is a test';");
                 state.out.println("set baz['testkey']['test col']='this is also a test';");
                 state.out.println("set diz[testkey][testcol] = utf8('this is utf8 string.');");
                 state.out.println("set bar[testkey][timeuuid()] = utf('hello world');");
+                state.out.println("set bar[testkey][timeuuid()] = utf('hello world') with ttl = 30;");
+                state.out.println("set diz[testkey][testcol] = 'this is utf8 string.' with ttl = 150;");
                 break;
 
             case CliParser.NODE_THRIFT_DEL:
@@ -339,8 +342,8 @@ public class CliUserHelp {
             state.out.println("get <cf> where <column> = <value> [and <column> > <value> and ...] [limit int];  ");
             state.out.println("get <cf>['<key>']['<col>'] (as <type>)*;                      Get a column value.");
             state.out.println("get <cf>['<key>']['<super>']['<col>'] (as <type>)*;       Get a sub column value.");
-            state.out.println("set <cf>['<key>']['<col>'] = <value>;                               Set a column.");
-            state.out.println("set <cf>['<key>']['<super>']['<col>'] = <value>;                Set a sub column.");
+            state.out.println("set <cf>['<key>']['<col>'] = <value> (with ttl = <secs>)*;          Set a column.");
+            state.out.println("set <cf>['<key>']['<super>']['<col>'] = <value> (with ttl = <secs>)*;   Set a sub column.");
             state.out.println("del <cf>['<key>'];                                                 Delete record.");
             state.out.println("del <cf>['<key>']['<col>'];                                        Delete column.");
             state.out.println("del <cf>['<key>']['<super>']['<col>'];                         Delete sub column.");

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Mon Dec 13 20:24:53 2010
@@ -896,7 +896,7 @@ public class ColumnFamilyStore implement
         return maxFile;
     }
 
-    void forceCleanup() throws ExecutionException, InterruptedException
+    public void forceCleanup() throws ExecutionException, InterruptedException
     {
         CompactionManager.instance.performCleanup(ColumnFamilyStore.this);
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java Mon Dec 13 20:24:53 2010
@@ -200,6 +200,11 @@ public class RowMutation
         Table.open(table_).apply(this, true);
     }
 
+    public void applyUnsafe() throws IOException
+    {
+        Table.open(table_).apply(this, false);
+    }
+
     /*
      * This is equivalent to calling commit. Applies the changes to
      * to the table that is obtained by calling Table.open().

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Mon Dec 13 20:24:53 2010
@@ -22,14 +22,7 @@ import java.io.File;
 import java.io.IOError;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import java.util.*;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledFuture;
@@ -162,10 +155,28 @@ public class Table
     public void forceCleanup() throws IOException, ExecutionException, InterruptedException
     {
         if (name.equals(SYSTEM_TABLE))
-            throw new RuntimeException("Cleanup of the system table is neither necessary nor wise");
+            throw new UnsupportedOperationException("Cleanup of the system table is neither necessary nor wise");
 
-        for (ColumnFamilyStore cfStore : columnFamilyStores.values())
-            cfStore.forceCleanup();
+        // Sort the column families in order of SSTable size, so cleanup of smaller CFs
+        // can free up space for larger ones
+        List<ColumnFamilyStore> sortedColumnFamilies = new ArrayList<ColumnFamilyStore>(columnFamilyStores.values());
+        Collections.sort(sortedColumnFamilies, new Comparator<ColumnFamilyStore>()
+        {
+            // Compare first on size and, if equal, sort by name (arbitrary & deterministic).
+            public int compare(ColumnFamilyStore cf1, ColumnFamilyStore cf2)
+            {
+                long diff = (cf1.getTotalDiskSpaceUsed() - cf2.getTotalDiskSpaceUsed());
+                if (diff > 0)
+                    return 1;
+                if (diff < 0)
+                    return -1;
+                return cf1.columnFamily.compareTo(cf2.columnFamily);
+            }
+        });
+
+        // Cleanup in sorted order to free up space for the larger ones
+        for (ColumnFamilyStore cfs : sortedColumnFamilies)
+            cfs.forceCleanup();
     }
 
     /**

Modified: cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java Mon Dec 13 20:24:53 2010
@@ -261,7 +261,13 @@ public abstract class AbstractReplicatio
                                                                         Map<String, String> strategyOptions)
             throws ConfigurationException
     {
-        Class<AbstractReplicationStrategy> c = FBUtilities.<AbstractReplicationStrategy>classForName(strategyClassName, "replication-strategy");
+        Class<AbstractReplicationStrategy> c = getClass(strategyClassName);
         return createReplicationStrategy(table, c, tokenMetadata, snitch, strategyOptions);
     }
+
+    public static Class<AbstractReplicationStrategy> getClass(String cls) throws ConfigurationException
+    {
+        String className = cls.contains(".") ? cls : "org.apache.cassandra.locator." + cls;
+        return FBUtilities.classForName(className, "replication strategy");
+    }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Mon Dec 13 20:24:53 2010
@@ -446,9 +446,8 @@ public class StorageService implements I
             }
         } 
 
-        if(!bootstrapped)
-            setToken(token);
-
+        SystemTable.setBootstrapped(true); // first startup is only chance to bootstrap
+        setToken(token);
         assert tokenMetadata_.sortedTokens().size() > 0;
     }
 
@@ -580,7 +579,7 @@ public class StorageService implements I
      * STATE_NORMAL,token 
      *   ready to serve reads and writes.
      * STATE_NORMAL,token,REMOVE_TOKEN,token
-     *   specialized normal state in which this node acts as a proxy to tell the cluster about a dead node whose 
+     *   specialized normal state in which this node acts as a proxy to tell the cluster about a dead node whose
      *   token is being removed. this value becomes the permanent state of this node (unless it coordinates another
      *   removetoken in the future).
      * STATE_LEAVING,token 
@@ -1175,32 +1174,23 @@ public class StorageService implements I
         return Gossiper.instance.getCurrentGenerationNumber(FBUtilities.getLocalAddress());
     }
 
-    public void forceTableCleanup() throws IOException, ExecutionException, InterruptedException
+    public void forceTableCleanup(String tableName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException
     {
-        List<String> tables = DatabaseDescriptor.getNonSystemTables();
-        for (String tName : tables)
+        if (tableName.equals("system"))
+            throw new RuntimeException("Cleanup of the system table is neither necessary nor wise");
+                    
+        for (ColumnFamilyStore cfStore : getValidColumnFamilies(tableName, columnFamilies))
         {
-            Table table = Table.open(tName);
-            table.forceCleanup();
+            cfStore.forceCleanup();
         }
     }
 
-    public void forceTableCleanup(String tableName) throws IOException, ExecutionException, InterruptedException
+    public void forceTableCompaction(String tableName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException
     {
-        Table table = getValidTable(tableName);
-        table.forceCleanup();
-    }
-
-    public void forceTableCompaction() throws IOException, ExecutionException, InterruptedException
-    {
-        for (Table table : Table.all())
-            table.forceCompaction();
-    }
-
-    public void forceTableCompaction(String tableName) throws IOException, ExecutionException, InterruptedException
-    {
-        Table table = getValidTable(tableName);
-        table.forceCompaction();
+        for (ColumnFamilyStore cfStore : getValidColumnFamilies(tableName, columnFamilies))
+        {
+            cfStore.forceMajorCompaction();
+        }
     }
 
     /**
@@ -2069,4 +2059,10 @@ public class StorageService implements I
         return partitioner_.describeOwnership(sortedTokens);
     }
 
+    public List<String> getKeyspaces()
+    {
+        List<String> tableslist = new ArrayList<String>(DatabaseDescriptor.getTables());
+        return Collections.unmodifiableList(tableslist);
+    }
+
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java Mon Dec 13 20:24:53 2010
@@ -131,26 +131,6 @@ public interface StorageServiceMBean
     public List<InetAddress> getNaturalEndpoints(String table, ByteBuffer key);
 
     /**
-     * Forces major compaction (all sstable files compacted)
-     */
-    public void forceTableCompaction() throws IOException, ExecutionException, InterruptedException;
-
-    /**
-     * Forces major compaction of a single keyspace
-     */
-    public void forceTableCompaction(String tableName) throws IOException, ExecutionException, InterruptedException;
-
-    /**
-     * Trigger a cleanup of keys on all tables.
-     */
-    public void forceTableCleanup() throws IOException, ExecutionException, InterruptedException;
-
-    /**
-     * Trigger a cleanup of keys on a single keyspace
-     */
-    public void forceTableCleanup(String tableName) throws IOException, ExecutionException, InterruptedException;
-
-    /**
      * Takes the snapshot for a given table.
      * 
      * @param tableName the name of the table.
@@ -171,6 +151,16 @@ public interface StorageServiceMBean
     public void clearSnapshot() throws IOException;
 
     /**
+     * Forces major compaction of a single keyspace
+     */
+    public void forceTableCompaction(String tableName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException;
+
+    /**
+     * Trigger a cleanup of keys on a single keyspace
+     */
+    public void forceTableCleanup(String tableName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException;
+
+    /**
      * Flush all memtables for the given column families, or all columnfamilies for the given table
      * if none are explicitly listed.
      * @param tableName
@@ -270,4 +260,6 @@ public interface StorageServiceMBean
      *   a mapping from "token -> %age of cluster owned by that token"
      */
     public Map<Token, Float> getOwnership();
+
+    public List<String> getKeyspaces();
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java Mon Dec 13 20:24:53 2010
@@ -42,7 +42,6 @@ import org.apache.cassandra.config.Confi
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.db.ColumnFamily;
-import org.apache.cassandra.db.ColumnFamilyNotDefinedException;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.ExpiringColumn;
@@ -60,8 +59,6 @@ import org.apache.cassandra.db.migration
 import org.apache.cassandra.db.migration.DropColumnFamily;
 import org.apache.cassandra.db.migration.DropKeyspace;
 import org.apache.cassandra.db.migration.Migration;
-import org.apache.cassandra.db.migration.RenameColumnFamily;
-import org.apache.cassandra.db.migration.RenameKeyspace;
 import org.apache.cassandra.db.migration.UpdateColumnFamily;
 import org.apache.cassandra.db.migration.UpdateKeyspace;
 import org.apache.cassandra.dht.AbstractBounds;
@@ -75,7 +72,6 @@ import org.apache.cassandra.scheduler.IR
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.StorageProxy;
 import org.apache.cassandra.service.StorageService;
-import org.apache.cassandra.utils.FBUtilities;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -767,7 +763,7 @@ public class CassandraServer implements 
             }
 
             KSMetaData ksm = new KSMetaData(ks_def.name,
-                                            FBUtilities.<AbstractReplicationStrategy>classForName(ks_def.strategy_class, "keyspace replication strategy"),
+                                            AbstractReplicationStrategy.getClass(ks_def.strategy_class),
                                             ks_def.strategy_options,
                                             ks_def.replication_factor,
                                             cfDefs.toArray(new CFMetaData[cfDefs.size()]));
@@ -826,7 +822,7 @@ public class CassandraServer implements 
         {
             KSMetaData ksm = new KSMetaData(
                     ks_def.name, 
-                    FBUtilities.<AbstractReplicationStrategy>classForName(ks_def.strategy_class, "keyspace replication strategy"),
+                    AbstractReplicationStrategy.getClass(ks_def.strategy_class),
                     ks_def.strategy_options,
                     ks_def.replication_factor);
             applyMigrationOnStage(new UpdateKeyspace(ksm));

Modified: cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java Mon Dec 13 20:24:53 2010
@@ -30,6 +30,8 @@ import java.util.*;
 import java.util.Map.Entry;
 import java.util.concurrent.ExecutionException;
 
+import org.apache.cassandra.db.Table;
+import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.EstimatedHistogram;
 import org.apache.commons.cli.*;
 
@@ -64,6 +66,14 @@ public class NodeCmd {
     {
         this.probe = probe;
     }
+
+    public enum NodeCommand {
+        RING, INFO, CFSTATS, SNAPSHOT, CLEARSNAPSHOT, VERSION, TPSTATS, FLUSH, DRAIN,
+        DECOMMISSION, MOVE, LOADBALANCE, REMOVETOKEN, REPAIR, CLEANUP, COMPACT,
+        SETCACHECAPACITY, GETCOMPACTIONTHRESHOLD, SETCOMPACTIONTHRESHOLD, NETSTATS, CFHISTOGRAMS,
+        COMPACTIONSTATS
+    }
+
     
     /**
      * Prints usage information to stdout.
@@ -71,12 +81,37 @@ public class NodeCmd {
     private static void printUsage()
     {
         HelpFormatter hf = new HelpFormatter();
-        String header = String.format(
-                "%nAvailable commands: ring, info, version, cleanup, compact [keyspacename], cfstats, snapshot [snapshotname], " +
-                "clearsnapshot, tpstats, flush, drain, repair, decommission, move, loadbalance, removetoken [status|force]|[token], " +
-                "setcachecapacity [keyspace] [cfname] [keycachecapacity] [rowcachecapacity], " +
-                "getcompactionthreshold [keyspace] [cfname], setcompactionthreshold [cfname] [minthreshold] [maxthreshold], " +
-                "netstats [host], cfhistograms <keyspace> <column_family>, compactionstats");
+        String header = "\nAvailable commands:\n"
+                         // No args
+                         + "ring\n"
+                         + "info\n"
+                         + "cfstats\n"
+                         + "clearsnapshot\n"
+                         + "version\n"
+                         + "tpstats\n"
+                         + "drain\n"
+                         + "decommission\n"
+                         + "loadbalance\n"
+                         + "compactionstats\n"
+
+                         // One arg
+                         + "snapshot [snapshotname]\n"
+                         + "netstats [host]\n"
+                         + "move <new token>\n"
+                         + "removetoken status|force|<token>\n"
+
+                         // Two args
+                         + "flush [keyspace] [cfnames]\n"
+                         + "repair [keyspace] [cfnames]\n"
+                         + "cleanup [keyspace] [cfnames]\n"
+                         + "compact [keyspace] [cfnames]\n"
+                         + "getcompactionthreshold <keyspace> <cfname>\n"
+                         + "cfhistograms <keyspace> <cfname>\n"
+
+                         // Four args
+                         + "setcachecapacity <keyspace> <cfname> <keycachecapacity> <rowcachecapacity>\n"
+                         + "setcompactionthreshold <keyspace> <cfname> <minthreshold> <maxthreshold>\n";
+
         String usage = String.format("java %s --host <arg> <command>%n", NodeCmd.class.getName());
         hf.printHelp(usage, "", options, header);
     }
@@ -419,9 +454,7 @@ public class NodeCmd {
         }
         catch (ParseException parseExcep)
         {
-            System.err.println(parseExcep);
-            printUsage();
-            System.exit(1);
+            badUse(parseExcep.toString());
         }
 
         String host = cmd.getOptionValue(HOST_OPT_LONG);
@@ -447,248 +480,177 @@ public class NodeCmd {
         }
         catch (IOException ioe)
         {
-            System.err.println("Error connecting to remote JMX agent!");
-            ioe.printStackTrace();
-            System.exit(3);
+            err(ioe, "Error connection to remote JMX agent!");
         }
         
         if (cmd.getArgs().length < 1)
-        {
-            System.err.println("Missing argument for command.");
-            printUsage();
-            System.exit(1);
-        }
-        
+            badUse("Missing argument for command.");
+
         NodeCmd nodeCmd = new NodeCmd(probe);
         
         // Execute the requested command.
         String[] arguments = cmd.getArgs();
         String cmdName = arguments[0];
-        if (cmdName.equals("ring"))
-        {
-            nodeCmd.printRing(System.out);
-        }
-        else if (cmdName.equals("info"))
-        {
-            nodeCmd.printInfo(System.out);
-        }
-        else if (cmdName.equals("cleanup"))
-        {
-            try
-            {
-                if (arguments.length > 1)
-                    probe.forceTableCleanup(arguments[1]);
-                else
-                    probe.forceTableCleanup();
-            }
-            catch (ExecutionException ee)
-            {
-                System.err.println("Error occured during Keyspace cleanup");
-                ee.printStackTrace();
-                System.exit(3);
-            }
-        }
-        else if (cmdName.equals("compact"))
-        {
-            try
-            {
-                if (arguments.length > 1)
-                    probe.forceTableCompaction(arguments[1]);
-                else
-                    probe.forceTableCompaction();
-            }
-            catch (ExecutionException ee)
-            {
-                System.err.println("Error occured during Keyspace compaction");
-                ee.printStackTrace();
-                System.exit(3);
-            }
-        }
-        else if (cmdName.equals("compactionstats"))
-        {
-            nodeCmd.printCompactionStats(System.out);
-        }
-        else if (cmdName.equals("cfstats"))
-        {
-            nodeCmd.printColumnFamilyStats(System.out);
-        }
-        else if (cmdName.equals("decommission"))
-        {
-            probe.decommission();
-        }
-        else if (cmdName.equals("loadbalance"))
-        {
-            probe.loadBalance();
-        }
-        else if (cmdName.equals("move"))
-        {
-            if (arguments.length <= 1)
-            {
-                System.err.println("missing token argument");
-            }
-            probe.move(arguments[1]);
-        }
-        else if (cmdName.equals("removetoken"))
-        {
-            if (arguments.length <= 1)
-            {
-                System.err.println("Missing an argument.");
-                printUsage();
-            }
-            else if (arguments[1].equals("status"))
-            {
-                nodeCmd.printRemovalStatus(System.out);
-            }
-            else if (arguments[1].equals("force"))
-            {
-                nodeCmd.printRemovalStatus(System.out);
-                probe.forceRemoveCompletion();
-            }
-            else
-                probe.removeToken(arguments[1]);
 
-        }
-        else if (cmdName.equals("snapshot"))
-        {
-            String snapshotName = "";
-            if (arguments.length > 1)
-            {
-                snapshotName = arguments[1];
-            }
-            probe.takeSnapshot(snapshotName);
-        }
-        else if (cmdName.equals("clearsnapshot"))
+        boolean validCommand = false;
+        for (NodeCommand n : NodeCommand.values())
         {
-            probe.clearSnapshot();
+            if (cmdName.toUpperCase().equals(n.name()))
+                validCommand = true;
         }
-        else if (cmdName.equals("tpstats"))
-        {
-            nodeCmd.printThreadPoolStats(System.out);
+
+        if (!validCommand)
+            badUse("Unrecognized command: " + cmdName);
+
+        NodeCommand nc = NodeCommand.valueOf(cmdName.toUpperCase());
+        switch (nc)
+        {
+            case RING            : nodeCmd.printRing(System.out); break;
+            case INFO            : nodeCmd.printInfo(System.out); break;
+            case CFSTATS         : nodeCmd.printColumnFamilyStats(System.out); break;
+            case DECOMMISSION    : probe.decommission(); break;
+            case LOADBALANCE     : probe.loadBalance(); break;
+            case CLEARSNAPSHOT   : probe.clearSnapshot(); break;
+            case TPSTATS         : nodeCmd.printThreadPoolStats(System.out); break;
+            case VERSION         : nodeCmd.printReleaseVersion(System.out); break;
+            case COMPACTIONSTATS : nodeCmd.printCompactionStats(System.out); break;
+
+            case DRAIN :
+                try { probe.drain(); }
+                catch (ExecutionException ee) { err(ee, "Error occured during flushing"); }
+                break;
+
+            case NETSTATS :
+                if (arguments.length > 1) { nodeCmd.printNetworkStats(InetAddress.getByName(arguments[1]), System.out); }
+                else                      { nodeCmd.printNetworkStats(null, System.out); }
+                break;
+
+            case SNAPSHOT :
+                if (arguments.length > 1) { probe.takeSnapshot(arguments[1]); }
+                else                      { probe.takeSnapshot(""); }
+                break;
+
+            case MOVE :
+                if (arguments.length != 2) { badUse("Missing token argument for move."); }
+                probe.move(arguments[1]);
+                break;
+
+            case REMOVETOKEN :
+                if (arguments.length != 2) { badUse("Missing an argument for removetoken (either status, force, or a token)"); }
+                else if (arguments[1].equals("status")) { nodeCmd.printRemovalStatus(System.out); }
+                else if (arguments[1].equals("force"))  { nodeCmd.printRemovalStatus(System.out); probe.forceRemoveCompletion(); }
+                else                                    { probe.removeToken(arguments[1]); }
+                break;
+
+            case CLEANUP :
+            case COMPACT :
+            case REPAIR  :
+            case FLUSH   :
+                optionalKSandCFs(nc, arguments, probe);
+                break;
+
+            case GETCOMPACTIONTHRESHOLD :
+                if (arguments.length != 3) { badUse("getcompactionthreshold requires ks and cf args."); }
+                probe.getCompactionThreshold(System.out, arguments[1], arguments[2]);
+                break;
+
+            case CFHISTOGRAMS :
+                if (arguments.length != 3) { badUse("cfhistograms requires ks and cf args"); }
+                nodeCmd.printCfHistograms(arguments[1], arguments[2], System.out);
+                break;
+
+            case SETCACHECAPACITY :
+                if (arguments.length != 5) { badUse("setcachecapacity requires ks, cf, keycachecap, and rowcachecap args."); }
+                probe.setCacheCapacities(arguments[1], arguments[2], Integer.valueOf(arguments[3]), Integer.valueOf(arguments[4]));
+                break;
+
+            case SETCOMPACTIONTHRESHOLD :
+                if (arguments.length != 5) { badUse("setcompactionthreshold requires ks, cf, min, and max threshold args."); }
+                int minthreshold = Integer.parseInt(arguments[3]);
+                int maxthreshold = Integer.parseInt(arguments[4]);
+                if ((minthreshold < 0) || (maxthreshold < 0)) { badUse("Thresholds must be positive integers"); }
+                if (minthreshold > maxthreshold)              { badUse("Min threshold cannot be greater than max."); }
+                if (minthreshold < 2 && maxthreshold != 0)    { badUse("Min threshold must be at least 2"); }
+                probe.setCompactionThreshold(arguments[1], arguments[2], minthreshold, maxthreshold);
+                break;
+
+            default :
+                throw new RuntimeException("Unreachable code.");
+
         }
-        else if (cmdName.equals("flush") || cmdName.equals("repair"))
-        {
-            if (cmd.getArgs().length < 2)
-            {
-                System.err.println("Missing keyspace argument.");
-                printUsage();
-                System.exit(1);
-            }
 
-            String[] columnFamilies = new String[cmd.getArgs().length - 2];
-            for (int i = 0; i < columnFamilies.length; i++)
+        System.exit(0);
+    }
+
+    private static void badUse(String useStr)
+    {
+        System.err.println(useStr);
+        printUsage();
+        System.exit(1);
+    }
+
+    private static void err(Exception e, String errStr)
+    {
+        System.err.println(errStr);
+        e.printStackTrace();
+        System.exit(3);
+    }
+
+    private static void optionalKSandCFs(NodeCommand nc, String[] cmdArgs, NodeProbe probe) throws InterruptedException, IOException
+    {
+        // Per-keyspace
+        if (cmdArgs.length == 1)
+        {
+            for (String keyspace : probe.getKeyspaces())
             {
-                columnFamilies[i] = cmd.getArgs()[i + 2];
-            }
-            if (cmdName.equals("flush"))
-                try
-                {
-                    probe.forceTableFlush(cmd.getArgs()[1], columnFamilies);
-                } catch (ExecutionException ee)
+                switch (nc)
                 {
-                    System.err.println("Error occured during flushing");
-                    ee.printStackTrace();
-                    System.exit(3);
+                    case REPAIR  : probe.forceTableRepair(keyspace); break;
+                    case FLUSH   :
+                        try { probe.forceTableFlush(keyspace); }
+                        catch (ExecutionException ee) { err(ee, "Error occured while flushing keyspace " + keyspace); }
+                        break;
+                    case COMPACT :
+                        try { probe.forceTableCompaction(keyspace); }
+                        catch (ExecutionException ee) { err(ee, "Error occured while compacting keyspace " + keyspace); }
+                        break;
+                    case CLEANUP :
+                        if (keyspace.equals("system")) { break; } // Skip cleanup on system cfs.
+                        try { probe.forceTableCleanup(keyspace); }
+                        catch (ExecutionException ee) { err(ee, "Error occured while cleaning up keyspace " + keyspace); }
+                        break;
+                    default:
+                        throw new RuntimeException("Unreachable code.");
                 }
-            else // cmdName.equals("repair")
-                probe.forceTableRepair(cmd.getArgs()[1], columnFamilies);
-        }
-        else if (cmdName.equals("drain"))
-        {
-            try 
-            {
-                probe.drain();
-            } catch (ExecutionException ee) 
-            {
-                System.err.println("Error occured during flushing");
-                ee.printStackTrace();
-                System.exit(3);
-            }    	
-        }
-        else if (cmdName.equals("setcachecapacity"))
-        {
-            if (cmd.getArgs().length != 5) // ks cf keycachecap rowcachecap
-            {
-                System.err.println("cacheinfo requires: Keyspace name, ColumnFamily name, key cache capacity (in keys), and row cache capacity (in rows)");
             }
-            String tableName = cmd.getArgs()[1];
-            String cfName = cmd.getArgs()[2];
-            int keyCacheCapacity = Integer.valueOf(cmd.getArgs()[3]);
-            int rowCacheCapacity = Integer.valueOf(cmd.getArgs()[4]);
-            probe.setCacheCapacities(tableName, cfName, keyCacheCapacity, rowCacheCapacity);
         }
-        else if (cmdName.equals("getcompactionthreshold"))
-        {
-            if (arguments.length < 3) // ks cf
-            {
-                System.err.println("Missing keyspace/cfname");
-                printUsage();
-                System.exit(1);
-            }
-            probe.getCompactionThreshold(System.out, cmd.getArgs()[1], cmd.getArgs()[2]);
-        }
-        else if (cmdName.equals("setcompactionthreshold"))
+        // Per-cf (or listed cfs) in given keyspace
+        else
         {
-            if (cmd.getArgs().length != 5) // ks cf min max
-            {
-                System.err.println("setcompactionthreshold requires: Keyspace name, ColumnFamily name, " +
-                                   "min threshold, and max threshold.");
-                printUsage();
-                System.exit(1);
-            }
-            String ks = cmd.getArgs()[1];
-            String cf = cmd.getArgs()[2];
-            int minthreshold = Integer.parseInt(arguments[3]);
-            int maxthreshold = Integer.parseInt(arguments[4]);
-
-            if ((minthreshold < 0) || (maxthreshold < 0))
-            {
-                System.err.println("Thresholds must be positive integers.");
-                printUsage();
-                System.exit(1);
-            }
-
-            if (minthreshold > maxthreshold)
-            {
-                System.err.println("Min threshold can't be greater than Max threshold");
-                printUsage();
-                System.exit(1);
-            }
-
-            if (minthreshold < 2 && maxthreshold != 0)
+            String keyspace = cmdArgs[1];
+            String[] columnFamilies = new String[cmdArgs.length - 2];
+            for (int i = 0; i < columnFamilies.length; i++)
             {
-                System.err.println("Min threshold must be at least 2");
-                printUsage();
-                System.exit(1);
+                columnFamilies[i] = cmdArgs[i + 2];
             }
-            probe.setCompactionThreshold(ks, cf, minthreshold, maxthreshold);
-        }
-        else if (cmdName.equals("netstats"))
-        {
-            // optional host
-            String otherHost = arguments.length > 1 ? arguments[1] : null;
-            nodeCmd.printNetworkStats(otherHost == null ? null : InetAddress.getByName(otherHost), System.out);
-        }
-        else if (cmdName.equals("cfhistograms"))
-        {
-            if (arguments.length < 3)
+            switch (nc)
             {
-                System.err.println("Usage of cfhistograms: <keyspace> <column_family>.");
-                System.exit(1);
+                case REPAIR  : probe.forceTableRepair(keyspace, columnFamilies); break;
+                case FLUSH   :
+                    try { probe.forceTableFlush(keyspace, columnFamilies); }
+                    catch (ExecutionException ee) { err(ee, "Error occured during flushing"); }
+                    break;
+                case COMPACT :
+                    try { probe.forceTableCompaction(keyspace, columnFamilies); }
+                    catch (ExecutionException ee) { err(ee, "Error occured during compaction"); }
+                    break;
+                case CLEANUP :
+                    try { probe.forceTableCleanup(keyspace, columnFamilies); }
+                    catch (ExecutionException ee) { err(ee, "Error occured during cleanup"); }
+                    break;
+                default:
+                    throw new RuntimeException("Unreachable code.");
             }
-
-            nodeCmd.printCfHistograms(arguments[1], arguments[2], System.out);
         }
-        else if (cmdName.equals("version"))
-        {
-            nodeCmd.printReleaseVersion(System.out);
-        }
-        else
-        {
-            System.err.println("Unrecognized command: " + cmdName + ".");
-            printUsage();
-            System.exit(1);
-        }
-
-        System.exit(0);
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java Mon Dec 13 20:24:53 2010
@@ -143,24 +143,14 @@ public class NodeProbe
         jmxc.close();
     }
 
-    public void forceTableCleanup() throws IOException, ExecutionException, InterruptedException
+    public void forceTableCleanup(String tableName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException
     {
-        ssProxy.forceTableCleanup();
+        ssProxy.forceTableCleanup(tableName, columnFamilies);
     }
 
-    public void forceTableCleanup(String tableName) throws IOException, ExecutionException, InterruptedException
+    public void forceTableCompaction(String tableName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException
     {
-        ssProxy.forceTableCleanup(tableName);
-    }
-
-    public void forceTableCompaction() throws IOException, ExecutionException, InterruptedException
-    {
-        ssProxy.forceTableCompaction();
-    }
-
-    public void forceTableCompaction(String tableName) throws IOException, ExecutionException, InterruptedException
-    {
-        ssProxy.forceTableCompaction(tableName);
+        ssProxy.forceTableCompaction(tableName, columnFamilies);
     }
 
     public void forceTableFlush(String tableName, String... columnFamilies) throws IOException, ExecutionException, InterruptedException
@@ -490,6 +480,11 @@ public class NodeProbe
 
         return cfsProxy;
     }
+
+    public List<String> getKeyspaces()
+    {
+        return ssProxy.getKeyspaces();
+    }
 }
 
 class ColumnFamilyStoreMBeanIterator implements Iterator<Map.Entry<String, ColumnFamilyStoreMBean>>
@@ -554,5 +549,5 @@ class ThreadPoolProxyMBeanIterator imple
     public void remove()
     {
         throw new UnsupportedOperationException();
-    }   
+    }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java Mon Dec 13 20:24:53 2010
@@ -101,11 +101,26 @@ public class ByteBufferUtil
     
     public static ByteBuffer clone(ByteBuffer o)
     {
+        assert o != null;
+        
+        if (o.remaining() == 0)
+            return FBUtilities.EMPTY_BYTE_BUFFER;
+          
         ByteBuffer clone = ByteBuffer.allocate(o.remaining());
-        o.mark();
-        clone.put(o);
-        o.reset();
-        clone.flip();
+
+        if (o.isDirect())
+        {
+            for (int i = o.position(); i < o.limit(); i++)
+            {
+                clone.put(o.get(i));
+            }
+            clone.flip();
+        }
+        else
+        {
+            System.arraycopy(o.array(), o.arrayOffset() + o.position(), clone.array(), 0, o.remaining());
+        }
+
         return clone;
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java Mon Dec 13 20:24:53 2010
@@ -50,6 +50,7 @@ import org.apache.cassandra.db.marshal.A
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.dht.Token;
+import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.locator.PropertyFileSnitch;
 import org.apache.thrift.TBase;
 import org.apache.thrift.TDeserializer;

Modified: cassandra/trunk/test/unit/org/apache/cassandra/cli/CliTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/cli/CliTest.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/cli/CliTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/cli/CliTest.java Mon Dec 13 20:24:53 2010
@@ -99,6 +99,8 @@ public class CliTest extends CleanupHelp
         "get CF7[3][lexicaluuid(550e8400-e29b-41d4-a716-446655440000)];",
         "get sCf1['hello'][1][9999];",
         "set sCf1['hello'][1][9999] = 938;",
+        "set sCf1['hello'][1][9999] = 938 with ttl = 30;",
+        "set sCf1['hello'][1][9999] = 938 with ttl = 560;",
         "list sCf1;",
         "del SCF1['hello'][1][9999];",
         "assume sCf1 comparator as utf8;",

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/NameSortTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/NameSortTest.java?rev=1045359&r1=1045358&r2=1045359&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/NameSortTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/NameSortTest.java Mon Dec 13 20:24:53 2010
@@ -20,6 +20,7 @@ package org.apache.cassandra.db;
 
 import static junit.framework.Assert.assertEquals;
 import static org.apache.cassandra.Util.addMutation;
+import static org.apache.cassandra.Util.column;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -28,7 +29,10 @@ import java.util.concurrent.ExecutionExc
 
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.Util;
+import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.utils.ByteBufferUtil;
+
 import org.junit.Test;
 
 public class NameSortTest extends CleanupHelper
@@ -69,7 +73,7 @@ public class NameSortTest extends Cleanu
                 ByteBuffer bytes = ByteBuffer.wrap(j % 2 == 0 ? "a".getBytes() : "b".getBytes());
                 rm = new RowMutation("Keyspace1", key);
                 rm.add(new QueryPath("Standard1", null, ByteBuffer.wrap(("Column-" + j).getBytes())), bytes, j);
-                rm.apply();
+                rm.applyUnsafe();
             }
 
             // super
@@ -81,7 +85,7 @@ public class NameSortTest extends Cleanu
                     String value = (j + k) % 2 == 0 ? "a" : "b";
                     addMutation(rm, "Super1", "SuperColumn-" + j, k, value, k);
                 }
-                rm.apply();
+                rm.applyUnsafe();
             }
         }
 
@@ -103,10 +107,10 @@ public class NameSortTest extends Cleanu
             Collection<IColumn> columns = cf.getSortedColumns();
             for (IColumn column : columns)
             {
-                int j = Integer.valueOf(new String(column.name().array(),column.name().position(),column.name().remaining()).split("-")[1]);
+                String name = ByteBufferUtil.string(column.name());
+                int j = Integer.valueOf(name.substring(name.length() - 1));
                 byte[] bytes = j % 2 == 0 ? "a".getBytes() : "b".getBytes();
-                assertEquals(new String(bytes), new String(column.value().array(), column.value().position(), column
-                        .value().remaining()));
+                assertEquals(new String(bytes), ByteBufferUtil.string(column.value()));
             }
 
             cf = Util.getColumnFamily(table, key, "Super1");
@@ -115,15 +119,14 @@ public class NameSortTest extends Cleanu
             assert superColumns.size() == 8 : cf;
             for (IColumn superColumn : superColumns)
             {
-                int j = Integer.valueOf(new String(superColumn.name().array(),superColumn.name().position(),superColumn.name().remaining()).split("-")[1]);
+                int j = Integer.valueOf(ByteBufferUtil.string(superColumn.name()).split("-")[1]);
                 Collection<IColumn> subColumns = superColumn.getSubColumns();
                 assert subColumns.size() == 4;
                 for (IColumn subColumn : subColumns)
                 {
                     long k = subColumn.name().getLong(subColumn.name().position() + subColumn.name().arrayOffset());
                     byte[] bytes = (j + k) % 2 == 0 ? "a".getBytes() : "b".getBytes();
-                    assertEquals(new String(bytes), new String(subColumn.value().array(), subColumn.value().position(),
-                            subColumn.value().remaining()));
+                    assertEquals(new String(bytes), ByteBufferUtil.string(subColumn.value()));
                 }
             }
         }



Mime
View raw message