in src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/BatchWrite.java [42:73]
public void visit(State state, RandWalkEnv env, Properties props) throws Exception {
AccumuloClient client = env.getAccumuloClient();
Random rand = state.getRandom();
String tableName = state.getRandomTableName();
try (BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig())) {
int numRows = rand.nextInt(100000);
for (int i = 0; i < numRows; i++) {
Mutation m = new Mutation(String.format("%016x", rand.nextLong() & 0x7fffffffffffffffL));
long val = rand.nextLong() & 0x7fffffffffffffffL;
for (int j = 0; j < 10; j++) {
m.put("cf", "cq" + j, new Value(String.format("%016x", val).getBytes(UTF_8)));
}
bw.addMutation(m);
}
log.debug("Wrote to " + tableName);
} catch (TableNotFoundException e) {
log.debug("BatchWrite " + tableName + " failed, table doesn't exist");
} catch (TableOfflineException e) {
log.debug("BatchWrite " + tableName + " failed, table offline");
} catch (MutationsRejectedException mre) {
if (mre.getCause() instanceof TableDeletedException)
log.debug("BatchWrite " + tableName + " failed, table deleted");
else if (mre.getCause() instanceof TableOfflineException)
log.debug("BatchWrite " + tableName + " failed, table offline");
else
throw mre;
}
}