You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2010/01/06 23:33:32 UTC

svn commit: r896698 - /incubator/cassandra/trunk/contrib/py_stress/stress.py

Author: jbellis
Date: Wed Jan  6 22:33:32 2010
New Revision: 896698

URL: http://svn.apache.org/viewvc?rev=896698&view=rev
Log:
add --keep-going option to continue past exceptions (e.g. to keep hammering server after timeouts start).  check get return value and raise when expected key is not present (cassandra can skip missing keys really really fast but that is not what we want to measure here).  patch by Brandon Williams; reviewed by jbellis for CASSANDRA-676

Modified:
    incubator/cassandra/trunk/contrib/py_stress/stress.py

Modified: incubator/cassandra/trunk/contrib/py_stress/stress.py
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/contrib/py_stress/stress.py?rev=896698&r1=896697&r2=896698&view=diff
==============================================================================
--- incubator/cassandra/trunk/contrib/py_stress/stress.py (original)
+++ incubator/cassandra/trunk/contrib/py_stress/stress.py Wed Jan  6 22:33:32 2010
@@ -81,6 +81,8 @@
 parser.add_option('-y', '--family-type', type="choice", dest="cftype",
                   choices=('regular','super'), default='regular',
                   help="column family type")
+parser.add_option('-k', '--keep-going', action="store_true", dest="ignore",
+                  help="ignore errors inserting or reading")
 
 (options, args) = parser.parse_args()
  
@@ -148,7 +150,15 @@
                 cfmap= {'Super1': [ColumnOrSuperColumn(super_column=s) for s in supers]}
             else:
                 cfmap = {'Standard1': [ColumnOrSuperColumn(column=c) for c in columns]}
-            self.cclient.batch_insert('Keyspace1', key, cfmap, ConsistencyLevel.ONE)
+            try:
+                self.cclient.batch_insert('Keyspace1', key, cfmap, ConsistencyLevel.ONE)
+            except KeyboardInterrupt:
+                raise
+            except Exception, e:
+                if options.ignore:
+                    print e
+                else:
+                    raise
             self.counts[self.idx]=self.counts[self.idx]+1
 
 class Reader(Operation):
@@ -159,13 +169,31 @@
                 key = str(key_generator())
                 for j in xrange(supers_per_key):
                     parent = ColumnParent('Super1', chr(ord('A') + j))
-                    self.cclient.get_slice('Keyspace1', key, parent, p, ConsistencyLevel.ONE)
+                    try:
+                        r = self.cclient.get_slice('Keyspace1', key, parent, p, ConsistencyLevel.ONE)
+                        if not r: raise RuntimeError("Key %s not found" % key)
+                    except KeyboardInterrupt:
+                        raise
+                    except Exception, e:
+                        if options.ignore:
+                            print e
+                        else:
+                            raise
                     self.counts[self.idx]=self.counts[self.idx]+1
         else:
             parent = ColumnParent('Standard1')
             for i in xrange(keys_per_thread):
                 key = str(key_generator())
-                self.cclient.get_slice('Keyspace1', key, parent, p, ConsistencyLevel.ONE)
+                try:
+                    r = self.cclient.get_slice('Keyspace1', key, parent, p, ConsistencyLevel.ONE)
+                    if not r: raise RuntimeError("Key %s not found" % key)
+                except KeyboardInterrupt:
+                    raise
+                except Exception, e:
+                    if options.ignore:
+                        print e
+                    else:
+                        raise
                 self.counts[self.idx]=self.counts[self.idx]+1
 
 class OperationFactory: