Author: jbellis
Date: Fri Sep 3 16:23:38 2010
New Revision: 992354
URL: http://svn.apache.org/viewvc?rev=992354&view=rev
Log:
add multiget to stress.py. patch by Jon Hermes; reviewed by jbellis for
CASSANDRA-1329
Modified:
cassandra/trunk/contrib/py_stress/stress.py
Modified: cassandra/trunk/contrib/py_stress/stress.py
URL:
http://svn.apache.org/viewvc/cassandra/trunk/contrib/py_stress/stress.py?rev=992354&r1=992353&r2=992354&view=diff
==============================================================================
--- cassandra/trunk/contrib/py_stress/stress.py (original)
+++ cassandra/trunk/contrib/py_stress/stress.py Fri Sep 3 16:23:38 2010
@@ -78,7 +78,8 @@ parser.add_option('-p', '--port', type="
parser.add_option('-m', '--unframed', action="store_true", dest="unframed",
help="use unframed transport")
parser.add_option('-o', '--operation', type="choice", dest="operation",
- default="insert", choices=('insert', 'read', 'rangeslice'),
+ default="insert", choices=('insert', 'read', 'rangeslice',
+ 'multiget'),
help="operation to perform")
parser.add_option('-u', '--supercolumns', type="int", dest="supers", default=1,
help="number of super columns per key")
@@ -308,6 +309,46 @@ class RangeSlicer(Operation):
self.keycounts[self.idx] += len(r)
+class MultiGetter(Operation):
+ def run(self):
+ p = SlicePredicate(slice_range=SliceRange('', '', False,
columns_per_key))
+ if 'super' == options.cftype:
+ keys = [key_generator() for i in xrange(keys_per_thread)]
+ for j in xrange(supers_per_key):
+ parent = ColumnParent('Super1', 'S' + str(j))
+ start = time.time()
+ try:
+ r = self.cclient.multiget_slice(keys, parent, p,
consistency)
+ if not r: raise RuntimeError("Keys %s not found" % keys)
+ except KeyboardInterrupt:
+ raise
+ except Exception, e:
+ if options.ignore:
+ print e
+ else:
+ raise
+ self.latencies[self.idx] += time.time() - start
+ self.opcounts[self.idx] += 1
+ self.keycounts[self.idx] += len(keys)
+ else:
+ parent = ColumnParent('Standard1')
+ keys = [key_generator() for i in xrange(keys_per_thread)]
+ start = time.time()
+ try:
+ r = self.cclient.multiget_slice(keys, parent, p, consistency)
+ if not r: raise RuntimeError("Keys %s not found" % keys)
+ except KeyboardInterrupt:
+ raise
+ except Exception, e:
+ if options.ignore:
+ print e
+ else:
+ raise
+ self.latencies[self.idx] += time.time() - start
+ self.opcounts[self.idx] += 1
+ self.keycounts[self.idx] += len(keys)
+
+
class OperationFactory:
@staticmethod
def create(type, i, opcounts, keycounts, latencies):
@@ -317,6 +358,8 @@ class OperationFactory:
return Inserter(i, opcounts, keycounts, latencies)
elif type == 'rangeslice':
return RangeSlicer(i, opcounts, keycounts, latencies)
+ elif type == 'multiget':
+ return MultiGetter(i, opcounts, keycounts, latencies)
else:
raise RuntimeError, 'Unsupported op!'
@@ -378,6 +421,10 @@ class Stress(object):
threads = self.create_threads('rangeslice')
self.run_test(options.file,threads);
+ def multiget(self):
+ threads = self.create_threads('multiget')
+ self.run_test(options.file,threads);
+
stresser = Stress()
benchmark = getattr(stresser, options.operation, None)
if not have_multiproc: