cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject svn commit: r1195217 - in /cassandra/branches/cassandra-1.0: CHANGES.txt src/java/org/apache/cassandra/cli/CliClient.java test/unit/org/apache/cassandra/cli/CliTest.java
Date Sun, 30 Oct 2011 18:50:04 GMT
Author: xedin
Date: Sun Oct 30 18:50:04 2011
New Revision: 1195217

URL: http://svn.apache.org/viewvc?rev=1195217&view=rev
Log:
Add timing information to cassandra-cli GET/SET/LIST queries
patch by satishbabu; reviewed by xedin for CASSANDRA-3326

Modified:
    cassandra/branches/cassandra-1.0/CHANGES.txt
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java
    cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java

Modified: cassandra/branches/cassandra-1.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/CHANGES.txt?rev=1195217&r1=1195216&r2=1195217&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0/CHANGES.txt Sun Oct 30 18:50:04 2011
@@ -1,7 +1,7 @@
 1.0.2
  * "defragment" rows for name-based queries under STCS (CASSANDRA-2503)
  * cleanup usage of StorageService.setMode() (CASANDRA-3388)
-
+ * Add timing information to cassandra-cli GET/SET/LIST queries (CASSANDRA-3326)
 
 1.0.1
  * acquire references during index build to prevent delete problems

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java?rev=1195217&r1=1195216&r2=1195217&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java Sun
Oct 30 18:50:04 2011
@@ -196,7 +196,6 @@ public class CliClient
     public void executeCLIStatement(String statement) throws CharacterCodingException, TException,
TimedOutException, NotFoundException, NoSuchFieldException, InvalidRequestException, UnavailableException,
InstantiationException, IllegalAccessException, ClassNotFoundException, SchemaDisagreementException
     {
         Tree tree = CliCompiler.compileQuery(statement);
-
         try
         {
             switch (tree.getType())
@@ -298,7 +297,7 @@ public class CliClient
         }
         catch (SchemaDisagreementException e)
         {
-        	throw new RuntimeException("schema does not match across nodes, (try again later).",
e);
+            throw new RuntimeException("schema does not match across nodes, (try again later).",
e);
         }
     }
 
@@ -452,6 +451,7 @@ public class CliClient
             throws InvalidRequestException, UnavailableException, TimedOutException, TException,
IllegalAccessException, NotFoundException, InstantiationException, NoSuchFieldException
     {
         
+        long startTime = System.currentTimeMillis();
         ColumnParent parent = new ColumnParent(columnFamily);
         if(superColumnName != null)
             parent.setSuper_column(superColumnName);
@@ -521,6 +521,7 @@ public class CliClient
         }
         
         sessionState.out.println("Returned " + columns.size() + " results.");
+        elapsedTime(startTime);
     }
 
     private AbstractType getFormatType(String compareWith)
@@ -554,7 +555,7 @@ public class CliClient
     {
         if (!CliMain.isConnected() || !hasKeySpace())
             return;
-
+        long startTime = System.currentTimeMillis();
         Tree columnFamilySpec = statement.getChild(0);
         String columnFamily = CliCompiler.getColumnFamily(columnFamilySpec, keyspacesMap.get(keySpace).cf_defs);
         ByteBuffer key = getKeyAsBytes(columnFamily, columnFamilySpec.getChild(1));
@@ -635,6 +636,7 @@ public class CliClient
         if (isCounterCF(cfDef))
         {
             doGetCounter(key, path);
+            elapsedTime(startTime);
             return;
         }
 
@@ -646,6 +648,7 @@ public class CliClient
         catch (NotFoundException e)
         {
             sessionState.out.println("Value was not found");
+            elapsedTime(startTime);
             return;
         }
 
@@ -682,6 +685,7 @@ public class CliClient
                                 valueAsString,
                                 column.timestamp,
                                 column.isSetTtl() ? String.format(", ttl=%d", column.getTtl())
: "");
+        elapsedTime(startTime);
     }
 
     private void doGetCounter(ByteBuffer key, ColumnPath path)
@@ -720,6 +724,8 @@ public class CliClient
         if (!CliMain.isConnected() || !hasKeySpace())
             return;
 
+        long startTime = System.currentTimeMillis();
+
         IndexClause clause = new IndexClause();
         String columnFamily = CliCompiler.getColumnFamily(statement, keyspacesMap.get(keySpace).cf_defs);
         // ^(CONDITIONS ^(CONDITION $column $value) ...)
@@ -802,6 +808,7 @@ public class CliClient
         {
             throw new RuntimeException(e);
         }
+        elapsedTime(startTime);
     }
 
     // Execute SET statement
@@ -811,6 +818,7 @@ public class CliClient
         if (!CliMain.isConnected() || !hasKeySpace())
             return;
         
+        long startTime = System.currentTimeMillis();
         // ^(NODE_COLUMN_ACCESS <cf> <key> <column>)
         Tree columnFamilySpec = statement.getChild(0);
         Tree keyTree = columnFamilySpec.getChild(1); // could be a function or regular text
@@ -890,6 +898,7 @@ public class CliClient
         // do the insert
         thriftClient.insert(getKeyAsBytes(columnFamily, keyTree), parent, columnToInsert,
consistencyLevel);
         sessionState.out.println("Value inserted.");
+        elapsedTime(startTime);
     }
 
     // Execute INCR statement
@@ -1313,7 +1322,9 @@ public class CliClient
     {
         if (!CliMain.isConnected() || !hasKeySpace())
             return;
-        
+
+        long startTime = System.currentTimeMillis();
+
         // extract column family
         String columnFamily = CliCompiler.getColumnFamily(statement, keyspacesMap.get(keySpace).cf_defs);
 
@@ -1375,6 +1386,7 @@ public class CliClient
         ColumnParent columnParent = new ColumnParent(columnFamily);
         List<KeySlice> keySlices = thriftClient.get_range_slices(columnParent, predicate,
range, consistencyLevel);
         printSliceList(columnFamilyDef, keySlices);
+        elapsedTime(startTime);
     }
 
     // DROP INDEX ON <CF>.<COLUMN>
@@ -2853,4 +2865,9 @@ public class CliClient
         }
         return false;
     }
+
+    private void elapsedTime(long startTime)
+    {
+        sessionState.out.println("Elapsed time: " + (System.currentTimeMillis() - startTime)
+ " msec(s).");
+    }
 }

Modified: cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java?rev=1195217&r1=1195216&r2=1195217&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java (original)
+++ cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java Sun Oct
30 18:50:04 2011
@@ -249,15 +249,16 @@ public class CliTest extends CleanupHelp
             }
             else if (statement.startsWith("set "))
             {
-                assertEquals(result, "Value inserted." + System.getProperty("line.separator"));
+                 assertTrue(result.contains("Value inserted."));
+                 assertTrue(result.contains("Elapsed time:"));
             }
             else if (statement.startsWith("incr "))
             {
-                assertEquals(result, "Value incremented." + System.getProperty("line.separator"));
+                 assertTrue(result.contains("Value incremented."));
             }
             else if (statement.startsWith("decr "))
             {
-                assertEquals(result, "Value decremented." + System.getProperty("line.separator"));
+                 assertTrue(result.contains("Value decremented."));
             }
             else if (statement.startsWith("get "))
             {
@@ -273,6 +274,7 @@ public class CliTest extends CleanupHelp
                 {
                     assertTrue(result.startsWith("=> (column=") || result.startsWith("Value
was not found"));
                 }
+                assertTrue(result.contains("Elapsed time:"));
             }
             else if (statement.startsWith("truncate "))
             {



Mime
View raw message