Permalink
Browse files

Format and add entry in README

  • Loading branch information...
1 parent e8a7664 commit 2a5052ebcc7ac2c96c009616bb0c2772d8638512 @patricioe patricioe committed Nov 1, 2011
Showing with 27 additions and 25 deletions.
  1. +1 −1 README.mdown
  2. +26 −24 src/main/java/com/riptano/cassandra/stress/VerifyLastInsertCommand.java
View
@@ -62,7 +62,7 @@ This will perform the operation then drop you into a shell in which you can perf
[cassandra-stress]
usage: operation [options]
operation can be one of: insert, read, rangeslice, multiget, replay [N]
- -o,--operation <arg> One of insert, read, rangeslice, multiget
+ -o,--operation <arg> One of insert, read, rangeslice, multiget, verify_last_insert
-b,--batch-size <arg> The number of rows in the batch_mutate call
-t,--threads <arg> The number of client threads we will create
-c,--columns <arg> The number of columsn to create per key
@@ -45,34 +45,36 @@ private void verifyCondition() {
@Override
public Void call() throws Exception {
+ log.debug("Starting VerifyLastInsertCommand");
+ String key = "test";
+ sliceQuery.setColumnFamily(commandArgs.workingColumnFamily);
- String key = "test";
- sliceQuery.setColumnFamily(commandArgs.workingColumnFamily);
+ log.info("StartKey: {} for thread {}", key, Thread.currentThread().getId());
+ String colValue;
- log.info("StartKey: {} for thread {}", key, Thread.currentThread().getId());
- String colValue;
+ for (int col = 0; col < commandArgs.columnCount; col++) {
+ colValue = String.format(COLUMN_VAL_FORMAT, col);
+ mutator.addInsertion(key,
+ commandArgs.workingColumnFamily,
+ HFactory.createStringColumn(String.format(COLUMN_NAME_FORMAT, col),
+ colValue));
+ executeMutator(col);
- for (int col = 0; col < commandArgs.columnCount; col++) {
- colValue = String.format(COLUMN_VAL_FORMAT, col);
- mutator.addInsertion(key,
- commandArgs.workingColumnFamily,
- HFactory.createStringColumn(String.format(COLUMN_NAME_FORMAT, col),
- colValue));
- executeMutator(col);
+ // Let's verify
+ sliceQuery.setKey(key);
+ sliceQuery.setRange(null, null, true, 1);
+ QueryResult<ColumnSlice<String,String>> result = sliceQuery.execute();
+ String actualValue = result.get().getColumns().get(0).getValue();
- // Let's verify
- sliceQuery.setKey(key);
- sliceQuery.setRange(null, null, true, 1);
- QueryResult<ColumnSlice<String,String>> result = sliceQuery.execute();
- String actualValue = result.get().getColumns().get(0).getValue();
- if (!actualValue.equals(colValue)) {
- log.error("Column values don't match. Expected: " + colValue + " - Actual: " + actualValue);
- break;
- }
+ if (!actualValue.equals(colValue)) {
+ log.error("Column values don't match. Expected: " + colValue + " - Actual: " + actualValue);
+ break;
}
+ }
- commandRunner.doneSignal.countDown();
- return null;
+ commandRunner.doneSignal.countDown();
+ log.debug("VerifyLastInsertCommand complete");
+ return null;
}
private void executeMutator(int cols) {
@@ -93,6 +95,6 @@ private void executeMutator(int cols) {
}
}
- private static final String COLUMN_VAL_FORMAT = "%08d_%s";
- private static final String COLUMN_NAME_FORMAT = "col_%08d";
+ private static final String COLUMN_VAL_FORMAT = "%08d";
+ private static final String COLUMN_NAME_FORMAT = "%08d";
}

0 comments on commit 2a5052e

Please sign in to comment.