Skip to content

Commit

Permalink
Merge remote branch 'origin/master'
Browse files Browse the repository at this point in the history
Conflicts:
	pom.xml
  • Loading branch information
patricioe committed Sep 3, 2011
2 parents 2cfc36f + 43ccbd1 commit 8c9cb72
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -4,7 +4,7 @@

<groupId>com.riptano.cassandra.stress</groupId>
<artifactId>cassandra-stress</artifactId>
<version>0.8.3_1</version>
<version>0.8_1</version>
<packaging>jar</packaging>

<name>cassandra-stress</name>
Expand Down
36 changes: 23 additions & 13 deletions src/main/java/com/riptano/cassandra/stress/InsertCommand.java
Expand Up @@ -41,26 +41,18 @@ public Void call() throws Exception {
key = String.format(KEY_FORMAT, rows+startKey);
for (int j2 = 0; j2 < commandArgs.columnCount; j2++) {
mutator.addInsertion(key, commandArgs.workingColumnFamily, HFactory.createStringColumn(String.format(COLUMN_NAME_FORMAT, j2),
String.format(COLUMN_VAL_FORMAT, j2, RandomStringUtils.random(colWidth))));
String.format(COLUMN_VAL_FORMAT, j2, RandomStringUtils.random(colWidth))));
if ( j2 > 0 && j2 % commandArgs.batchSize == 0 ) {
executeMutator(rows);
}
}

if (++rows == commandArgs.getKeysPerThread() ) {
break;
}

}
try {
MutationResult mr = mutator.execute();
LatencyTracker writeCount = commandRunner.latencies.get(mr.getHostUsed());
if ( writeCount != null )
writeCount.addMicro(mr.getExecutionTimeMicro());
mutator.discardPendingMutations();

log.info("executed batch of {}. {} of {} complete", new Object[]{commandArgs.batchSize, rows, commandArgs.getKeysPerThread()});

} catch (Exception ex){
log.error("Problem executing insert:",ex);
}
executeMutator(rows);
}
commandRunner.doneSignal.countDown();
log.info("Last key was: {} for thread {}", key, Thread.currentThread().getId());
Expand All @@ -73,6 +65,24 @@ public Void call() throws Exception {
log.info("Executed chunk of {}. Latch now at {}", commandArgs.getKeysPerThread(), commandRunner.doneSignal.getCount());
return null;
}

private void executeMutator(int rows) {
try {
MutationResult mr = mutator.execute();
// could be null here when our batch size is zero
if ( mr.getHostUsed() != null ) {
LatencyTracker writeCount = commandRunner.latencies.get(mr.getHostUsed());
if ( writeCount != null )
writeCount.addMicro(mr.getExecutionTimeMicro());
}
mutator.discardPendingMutations();

log.info("executed batch of {}. {} of {} complete", new Object[]{commandArgs.batchSize, rows, commandArgs.getKeysPerThread()});

} catch (Exception ex){
log.error("Problem executing insert:",ex);
}
}

private static final String COLUMN_VAL_FORMAT = "%08d_%s";
private static final String COLUMN_NAME_FORMAT = "col_%08d";
Expand Down
6 changes: 3 additions & 3 deletions stress-schema.txt
@@ -1,6 +1,6 @@
create keyspace StressKeyspace
with replication_factor = 1
and placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy';
create keyspace StressKeyspace
with placement_strategy = 'SimpleStrategy'
and strategy_options = [{replication_factor : 1}];

use StressKeyspace;
drop column family StressStandard;
Expand Down

0 comments on commit 8c9cb72

Please sign in to comment.