Пример #1
0
 def run(self):
     data = md5(str(get_ident())).hexdigest()
     columns = [{'name': 'C' + str(j), 'value': data, 'timestamp': int(time.time() * 1000000)} for j in xrange(columns_per_key)]
     fmt = '%0' + str(len(str(total_keys))) + 'd'
     if 'super' == options.cftype:
         supers = [{'name': 'S' + str(j), 'columns': columns} for j in xrange(supers_per_key)]
     for i in self.range:
         key = fmt % i
         if 'super' == options.cftype:
             cfmap= {'key': key, 'mutations': {'Super1' : [{'column_or_supercolumn': {'super_column': s}} for s in supers]}}
         else:
             cfmap = {'key': key, 'mutations': {'Standard1': [{'column_or_supercolumn': {'column': c}} for c in columns]}}
         start = time.time()
         try:
             self.cclient.request('batch_mutate', {'mutation_map': [cfmap], 'consistency_level': consistency})
         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] += 1
Пример #2
0
 def run(self):
     data = md5(str(get_ident())).hexdigest()
     columns = [Column('C' + str(j), data, 0) for j in xrange(columns_per_key)]
     fmt = '%0' + str(len(str(total_keys))) + 'd'
     if 'super' == options.cftype:
         supers = [SuperColumn('S' + str(j), columns) for j in xrange(supers_per_key)]
     for i in self.range:
         key = fmt % i
         if 'super' == options.cftype:
             cfmap= {'Super1': [ColumnOrSuperColumn(super_column=s) for s in supers]}
         else:
             cfmap = {'Standard1': [ColumnOrSuperColumn(column=c) for c in columns]}
         start = time.time()
         try:
             self.cclient.batch_insert('Keyspace1', key, cfmap, ConsistencyLevel.ONE)
         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] += 1
Пример #3
0
 def run(self):
     data = md5(str(get_ident())).hexdigest()
     data = data * int(options.column_size /
                       len(data)) + data[:options.column_size % len(data)]
     columns = [
         Column('C' + str(j), data, 0) for j in xrange(columns_per_key)
     ]
     fmt = '%0' + str(len(str(total_keys))) + 'd'
     if 'super' == options.cftype:
         supers = [
             SuperColumn('S' + str(j), columns)
             for j in xrange(supers_per_key)
         ]
     for i in self.range:
         key = fmt % i
         if 'super' == options.cftype:
             cfmap = {
                 'Super1':
                 [ColumnOrSuperColumn(super_column=s) for s in supers]
             }
         else:
             cfmap = {
                 'Standard1':
                 [ColumnOrSuperColumn(column=c) for c in columns]
             }
         start = time.time()
         try:
             self.cclient.batch_insert('Keyspace1', key, cfmap,
                                       ConsistencyLevel.ONE)
         except KeyboardInterrupt:
             raise
         except Exception, e:
             if options.ignore:
                 print e
             else:
                 raise
         self.latencies[self.idx] += time.time() - start
         self.counts[self.idx] += 1