cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [2/7] git commit: add 95th and 99th percentile latency reporting to Stress patch by jbellis; reviewed by brandonwilliams for CASSANDRA-5005
Date Tue, 04 Dec 2012 20:34:25 GMT
add 95th and 99th percentile latency reporting to Stress
patch by jbellis; reviewed by brandonwilliams for CASSANDRA-5005


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

Branch: refs/heads/cassandra-1.2
Commit: b475602be82230ad3d20da8d0b56b99f47b9d192
Parents: ae9faf0
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Sun Dec 2 04:38:59 2012 +0900
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Tue Dec 4 14:34:01 2012 -0600

----------------------------------------------------------------------
 .../src/org/apache/cassandra/stress/Session.java   |   12 ++++-----
 .../org/apache/cassandra/stress/StressAction.java  |   19 ++++++++------
 .../cassandra/stress/operations/CounterAdder.java  |    5 ++-
 .../cassandra/stress/operations/CounterGetter.java |   10 ++++----
 .../stress/operations/CqlCounterAdder.java         |    5 ++-
 .../stress/operations/CqlCounterGetter.java        |    6 ++--
 .../stress/operations/CqlIndexedRangeSlicer.java   |    5 ++-
 .../cassandra/stress/operations/CqlInserter.java   |    5 ++-
 .../stress/operations/CqlRangeSlicer.java          |    5 ++-
 .../cassandra/stress/operations/CqlReader.java     |    5 ++-
 .../stress/operations/IndexedRangeSlicer.java      |    5 ++-
 .../cassandra/stress/operations/Inserter.java      |    5 ++-
 .../cassandra/stress/operations/MultiGetter.java   |    9 ++++---
 .../cassandra/stress/operations/RangeSlicer.java   |    9 ++++---
 .../apache/cassandra/stress/operations/Reader.java |    9 ++++---
 15 files changed, 63 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/Session.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/Session.java b/tools/stress/src/org/apache/cassandra/stress/Session.java
index a0c3617..804e4e8 100644
--- a/tools/stress/src/org/apache/cassandra/stress/Session.java
+++ b/tools/stress/src/org/apache/cassandra/stress/Session.java
@@ -25,6 +25,8 @@ import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
+import com.yammer.metrics.Metrics;
+import com.yammer.metrics.core.Histogram;
 import org.apache.cassandra.cli.transport.FramedTransportFactory;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.EncryptionOptions;
@@ -56,9 +58,9 @@ public class Session implements Serializable
 
     private static InetAddress localInetAddress;
 
-    public final AtomicInteger operations;
-    public final AtomicInteger keys;
-    public final AtomicLong    latency;
+    public final AtomicInteger operations = new AtomicInteger();
+    public final AtomicInteger keys = new AtomicInteger();
+    public final com.yammer.metrics.core.Timer latency = Metrics.newTimer(Session.class,
"latency");
 
     private static final String SSL_TRUSTSTORE = "truststore";
     private static final String SSL_TRUSTSTORE_PW = "truststore-password";
@@ -436,10 +438,6 @@ public class Session implements Serializable
 
         mean  = numDifferentKeys / 2;
         sigma = numDifferentKeys * STDev;
-
-        operations = new AtomicInteger();
-        keys = new AtomicInteger();
-        latency = new AtomicLong();
     }
 
     private TTransportFactory validateAndSetTransportFactory(String transportFactory)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/StressAction.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/StressAction.java b/tools/stress/src/org/apache/cassandra/stress/StressAction.java
index b5a7e6e..27675d1 100644
--- a/tools/stress/src/org/apache/cassandra/stress/StressAction.java
+++ b/tools/stress/src/org/apache/cassandra/stress/StressAction.java
@@ -21,6 +21,7 @@ import java.io.PrintStream;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.SynchronousQueue;
 
+import com.yammer.metrics.stats.Snapshot;
 import org.apache.cassandra.stress.operations.*;
 import org.apache.cassandra.stress.util.CassandraClient;
 import org.apache.cassandra.stress.util.Operation;
@@ -50,7 +51,8 @@ public class StressAction extends Thread
 
     public void run()
     {
-        long latency, oldLatency;
+        Snapshot latency;
+        long oldLatency;
         int epoch, total, oldTotal, keyCount, oldKeyCount;
 
         // creating keyspace and column families
@@ -60,7 +62,7 @@ public class StressAction extends Thread
         int threadCount = client.getThreads();
         Consumer[] consumers = new Consumer[threadCount];
 
-        output.println("total,interval_op_rate,interval_key_rate,avg_latency,elapsed_time");
+        output.println("total,interval_op_rate,interval_key_rate,latency/95th/99th,elapsed_time");
 
         int itemsPerThread = client.getKeysPerThread();
         int modulo = client.getNumKeys() % threadCount;
@@ -82,7 +84,6 @@ public class StressAction extends Thread
 
         // initialization of the values
         boolean terminate = false;
-        latency = 0;
         epoch = total = keyCount = 0;
 
         int interval = client.getProgressInterval();
@@ -124,21 +125,23 @@ public class StressAction extends Thread
                 epoch = 0;
 
                 oldTotal = total;
-                oldLatency = latency;
                 oldKeyCount = keyCount;
 
                 total = client.operations.get();
                 keyCount = client.keys.get();
-                latency = client.latency.get();
+                latency = client.latency.getSnapshot();
 
                 int opDelta = total - oldTotal;
                 int keyDelta = keyCount - oldKeyCount;
-                double latencyDelta = latency - oldLatency;
 
                 long currentTimeInSeconds = (System.currentTimeMillis() - testStartTime)
/ 1000;
-                String formattedDelta = (opDelta > 0) ? Double.toString(latencyDelta /
(opDelta * 1000)) : "NaN";
 
-                output.println(String.format("%d,%d,%d,%s,%d", total, opDelta / interval,
keyDelta / interval, formattedDelta, currentTimeInSeconds));
+                output.println(String.format("%d,%d,%d,%.1f,%.1f,%.1f,%d",
+                                             total,
+                                             opDelta / interval,
+                                             keyDelta / interval,
+                                             latency.getMedian(), latency.get95thPercentile(),
latency.get999thPercentile(),
+                                             currentTimeInSeconds));
             }
         }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/CounterAdder.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CounterAdder.java b/tools/stress/src/org/apache/cassandra/stress/operations/CounterAdder.java
index 0420154..ab6ae9d 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CounterAdder.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CounterAdder.java
@@ -17,6 +17,7 @@
  */
 package org.apache.cassandra.stress.operations;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
 import org.apache.cassandra.stress.util.Operation;
@@ -70,7 +71,7 @@ public class CounterAdder extends Operation
                                                                                 ? getSuperColumnsMutationMap(superColumns)
                                                                                 : getColumnsMutationMap(columns));
 
-        long start = System.currentTimeMillis();
+        TimerContext context = session.latency.time();
 
         boolean success = false;
         String exceptionMessage = null;
@@ -103,7 +104,7 @@ public class CounterAdder extends Operation
 
         session.operations.getAndIncrement();
         session.keys.getAndIncrement();
-        session.latency.getAndAdd(System.currentTimeMillis() - start);
+        context.stop();
     }
 
     private Map<String, List<Mutation>> getSuperColumnsMutationMap(List<CounterSuperColumn>
superColumns)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/CounterGetter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CounterGetter.java b/tools/stress/src/org/apache/cassandra/stress/operations/CounterGetter.java
index a06298d..56ef243 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CounterGetter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CounterGetter.java
@@ -17,6 +17,7 @@
  */
 package org.apache.cassandra.stress.operations;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
 import org.apache.cassandra.stress.util.Operation;
@@ -67,7 +68,7 @@ public class CounterGetter extends Operation
             String superColumn = 'S' + Integer.toString(j);
             ColumnParent parent = new ColumnParent("SuperCounter1").setSuper_column(superColumn.getBytes());
 
-            long start = System.currentTimeMillis();
+            TimerContext context = session.latency.time();
 
             boolean success = false;
             String exceptionMessage = null;
@@ -101,7 +102,7 @@ public class CounterGetter extends Operation
 
             session.operations.getAndIncrement();
             session.keys.getAndIncrement();
-            session.latency.getAndAdd(System.currentTimeMillis() - start);
+            context.stop();
         }
     }
 
@@ -112,7 +113,7 @@ public class CounterGetter extends Operation
         byte[] key = generateKey();
         ByteBuffer keyBuffer = ByteBuffer.wrap(key);
 
-        long start = System.currentTimeMillis();
+        TimerContext context = session.latency.time();
 
         boolean success = false;
         String exceptionMessage = null;
@@ -146,7 +147,6 @@ public class CounterGetter extends Operation
 
         session.operations.getAndIncrement();
         session.keys.getAndIncrement();
-        session.latency.getAndAdd(System.currentTimeMillis() - start);
+        context.stop();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
index 3dfd33e..e1e4e9a 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Collections;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
@@ -71,7 +72,7 @@ public class CqlCounterAdder extends Operation
         String key = String.format("%0" + session.getTotalKeysLength() + "d", index);
         String formattedQuery = null;
 
-        long start = System.currentTimeMillis();
+        TimerContext context = session.latency.time();
 
         boolean success = false;
         String exceptionMessage = null;
@@ -121,6 +122,6 @@ public class CqlCounterAdder extends Operation
 
         session.operations.getAndIncrement();
         session.keys.getAndIncrement();
-        session.latency.getAndAdd(System.currentTimeMillis() - start);
+        context.stop();
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
index 8b5a2bd..db99d0d 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Collections;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
@@ -70,7 +71,7 @@ public class CqlCounterGetter extends Operation
         byte[] key = generateKey();
         String formattedQuery = null;
 
-        long start = System.currentTimeMillis();
+        TimerContext context = session.latency.time();
 
         boolean success = false;
         String exceptionMessage = null;
@@ -125,7 +126,6 @@ public class CqlCounterGetter extends Operation
 
         session.operations.getAndIncrement();
         session.keys.getAndIncrement();
-        session.latency.getAndAdd(System.currentTimeMillis() - start);
+        context.stop();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
b/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
index 66e626a..5a18b30 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import java.util.Collections;
 import java.util.List;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
@@ -74,7 +75,7 @@ public class CqlIndexedRangeSlicer extends Operation
 
         while (received < expectedPerValue)
         {
-            long start = System.currentTimeMillis();
+            TimerContext context = session.latency.time();
 
             boolean success = false;
             String exceptionMessage = null;
@@ -132,7 +133,7 @@ public class CqlIndexedRangeSlicer extends Operation
 
             session.operations.getAndIncrement();
             session.keys.getAndAdd(results.rows.size());
-            session.latency.getAndAdd(System.currentTimeMillis() - start);
+            context.stop();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
index aedf2de..5b5c22c 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
@@ -96,7 +97,7 @@ public class CqlInserter extends Operation
 
         String formattedQuery = null;
 
-        long start = System.currentTimeMillis();
+        TimerContext context = session.latency.time();
 
         boolean success = false;
         String exceptionMessage = null;
@@ -147,6 +148,6 @@ public class CqlInserter extends Operation
 
         session.operations.getAndIncrement();
         session.keys.getAndIncrement();
-        session.latency.getAndAdd(System.currentTimeMillis() - start);
+        context.stop();
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java
index 5a59110..0e27f67 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Collections;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 import org.apache.cassandra.db.ColumnFamilyType;
@@ -62,7 +63,7 @@ public class CqlRangeSlicer extends Operation
         String key = String.format("%0" +  session.getTotalKeysLength() + "d", index);
         String formattedQuery = null;
 
-        long startTime = System.currentTimeMillis();
+        TimerContext context = session.latency.time();
 
         boolean success = false;
         String exceptionMessage = null;
@@ -117,6 +118,6 @@ public class CqlRangeSlicer extends Operation
 
         session.operations.getAndIncrement();
         session.keys.getAndAdd(rowCount);
-        session.latency.getAndAdd(System.currentTimeMillis() - startTime);
+        context.stop();
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java
index 5e3259d..a7f9a09 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
@@ -86,7 +87,7 @@ public class CqlReader extends Operation
 
         String formattedQuery = null;
 
-        long start = System.currentTimeMillis();
+        TimerContext context = session.latency.time();
 
         boolean success = false;
         String exceptionMessage = null;
@@ -140,6 +141,6 @@ public class CqlReader extends Operation
 
         session.operations.getAndIncrement();
         session.keys.getAndIncrement();
-        session.latency.getAndAdd(System.currentTimeMillis() - start);
+        context.stop();
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/IndexedRangeSlicer.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/IndexedRangeSlicer.java
b/tools/stress/src/org/apache/cassandra/stress/operations/IndexedRangeSlicer.java
index 8768de8..b7c72a2 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/IndexedRangeSlicer.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/IndexedRangeSlicer.java
@@ -17,6 +17,7 @@
  */
 package org.apache.cassandra.stress.operations;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
 import org.apache.cassandra.stress.util.Operation;
@@ -66,7 +67,7 @@ public class IndexedRangeSlicer extends Operation
                                                  session.getKeysPerCall());
 
             List<KeySlice> results = null;
-            long start = System.currentTimeMillis();
+            TimerContext context = session.latency.time();
 
             boolean success = false;
             String exceptionMessage = null;
@@ -104,7 +105,7 @@ public class IndexedRangeSlicer extends Operation
 
             session.operations.getAndIncrement();
             session.keys.getAndAdd(results.size());
-            session.latency.getAndAdd(System.currentTimeMillis() - start);
+            context.stop();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/Inserter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/Inserter.java b/tools/stress/src/org/apache/cassandra/stress/operations/Inserter.java
index 24c7eaa..cbf6b98 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/Inserter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/Inserter.java
@@ -17,6 +17,7 @@
  */
 package org.apache.cassandra.stress.operations;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
 import org.apache.cassandra.stress.util.Operation;
@@ -73,7 +74,7 @@ public class Inserter extends Operation
                                         : getColumnsMutationMap(columns);
         Map<ByteBuffer, Map<String, List<Mutation>>> record = Collections.singletonMap(ByteBufferUtil.bytes(rawKey),
row);
 
-        long start = System.currentTimeMillis();
+        TimerContext context = session.latency.time();
 
         boolean success = false;
         String exceptionMessage = null;
@@ -105,7 +106,7 @@ public class Inserter extends Operation
 
         session.operations.getAndIncrement();
         session.keys.getAndIncrement();
-        session.latency.getAndAdd(System.currentTimeMillis() - start);
+        context.stop();
     }
 
     private Map<String, List<Mutation>> getSuperColumnsMutationMap(List<SuperColumn>
superColumns)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/MultiGetter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/MultiGetter.java b/tools/stress/src/org/apache/cassandra/stress/operations/MultiGetter.java
index f569f66..12a39fb 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/MultiGetter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/MultiGetter.java
@@ -17,6 +17,7 @@
  */
 package org.apache.cassandra.stress.operations;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
 import org.apache.cassandra.stress.util.Operation;
@@ -55,7 +56,7 @@ public class MultiGetter extends Operation
             {
                 ColumnParent parent = new ColumnParent("Super1").setSuper_column(ByteBufferUtil.bytes("S"
+ j));
 
-                long start = System.currentTimeMillis();
+                TimerContext context = session.latency.time();
 
                 boolean success = false;
                 String exceptionMessage = null;
@@ -87,7 +88,7 @@ public class MultiGetter extends Operation
 
                 session.operations.getAndIncrement();
                 session.keys.getAndAdd(keys.size());
-                session.latency.getAndAdd(System.currentTimeMillis() - start);
+                context.stop();
 
                 offset += session.getKeysPerCall();
             }
@@ -98,7 +99,7 @@ public class MultiGetter extends Operation
 
             List<ByteBuffer> keys = generateKeys(offset, offset + session.getKeysPerCall());
 
-            long start = System.currentTimeMillis();
+            TimerContext context = session.latency.time();
 
             boolean success = false;
             String exceptionMessage = null;
@@ -131,7 +132,7 @@ public class MultiGetter extends Operation
 
             session.operations.getAndIncrement();
             session.keys.getAndAdd(keys.size());
-            session.latency.getAndAdd(System.currentTimeMillis() - start);
+            context.stop();
 
             offset += session.getKeysPerCall();
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/RangeSlicer.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/RangeSlicer.java b/tools/stress/src/org/apache/cassandra/stress/operations/RangeSlicer.java
index e462e30..f9ba115 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/RangeSlicer.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/RangeSlicer.java
@@ -17,6 +17,7 @@
  */
 package org.apache.cassandra.stress.operations;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
 import org.apache.cassandra.stress.util.Operation;
@@ -61,7 +62,7 @@ public class RangeSlicer extends Operation
                 String superColumnName = "S" + Integer.toString(i);
                 ColumnParent parent = new ColumnParent("Super1").setSuper_column(ByteBufferUtil.bytes(superColumnName));
 
-                long startTime = System.currentTimeMillis();
+                TimerContext context = session.latency.time();
 
                 boolean success = false;
                 String exceptionMessage = null;
@@ -90,7 +91,7 @@ public class RangeSlicer extends Operation
                 }
 
                 session.operations.getAndIncrement();
-                session.latency.getAndAdd(System.currentTimeMillis() - startTime);
+                context.stop();
             }
 
             session.keys.getAndAdd(slices.size());
@@ -104,7 +105,7 @@ public class RangeSlicer extends Operation
             List<KeySlice> slices = new ArrayList<KeySlice>();
             KeyRange range = new KeyRange(count).setStart_key(start).setEnd_key(ByteBufferUtil.EMPTY_BYTE_BUFFER);
 
-            long startTime = System.currentTimeMillis();
+            TimerContext context = session.latency.time();
 
             boolean success = false;
             String exceptionMessage = null;
@@ -137,7 +138,7 @@ public class RangeSlicer extends Operation
 
             session.operations.getAndIncrement();
             session.keys.getAndAdd(slices.size());
-            session.latency.getAndAdd(System.currentTimeMillis() - startTime);
+            context.stop();
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b475602b/tools/stress/src/org/apache/cassandra/stress/operations/Reader.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/Reader.java b/tools/stress/src/org/apache/cassandra/stress/operations/Reader.java
index 412ebdf..f75502a 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/Reader.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/Reader.java
@@ -17,6 +17,7 @@
  */
 package org.apache.cassandra.stress.operations;
 
+import com.yammer.metrics.core.TimerContext;
 import org.apache.cassandra.stress.Session;
 import org.apache.cassandra.stress.util.CassandraClient;
 import org.apache.cassandra.stress.util.Operation;
@@ -66,7 +67,7 @@ public class Reader extends Operation
             String superColumn = 'S' + Integer.toString(j);
             ColumnParent parent = new ColumnParent("Super1").setSuper_column(superColumn.getBytes(UTF_8));
 
-            long start = System.currentTimeMillis();
+            TimerContext context = session.latency.time();
 
             boolean success = false;
             String exceptionMessage = null;
@@ -100,7 +101,7 @@ public class Reader extends Operation
 
             session.operations.getAndIncrement();
             session.keys.getAndIncrement();
-            session.latency.getAndAdd(System.currentTimeMillis() - start);
+            context.stop();
         }
     }
 
@@ -111,7 +112,7 @@ public class Reader extends Operation
         byte[] key = generateKey();
         ByteBuffer keyBuffer = ByteBuffer.wrap(key);
 
-        long start = System.currentTimeMillis();
+        TimerContext context = session.latency.time();
 
         boolean success = false;
         String exceptionMessage = null;
@@ -145,7 +146,7 @@ public class Reader extends Operation
 
         session.operations.getAndIncrement();
         session.keys.getAndIncrement();
-        session.latency.getAndAdd(System.currentTimeMillis() - start);
+        context.stop();
     }
 
     private SliceRange getSliceRange()


Mime
View raw message