postExecutor.shutdown();
break;
}
final Locator locatorCapture = locator;
final Row<Locator, Long> row = rows.getRow(locator);
// send copy commands to the write thread pool.
destWriteExecutor.submit(new Runnable() {
public void run() {
// back out if we've processed our quota of rows.
if (processedKeys.get() >= keyLimit) {
return;
}
// copy the column.
MutationBatch batch = dstKeyspace.prepareMutationBatch();
ColumnListMutation<Long> mutation = batch.withRow(columnFamily, locatorCapture);
assert ttl != 0;
long colCount = 0;
for (Column<Long> c : row.getColumns()) {
mutation.putColumn(c.getName(), c.getByteBufferValue(), ttl);
colCount += 1;
}
columnsTransferred.addAndGet(colCount);
// save it, submit a log message to be shown later.
try {
batch.execute();
if (verify && random.nextFloat() < VERIFY_PERCENT) {
verifyExecutor.submit(new Runnable() {public void run() {
try {
ColumnList<Long> srcData = srcKeyspace.prepareQuery(columnFamily).getKey(locatorCapture)
.withColumnRange(range)
.execute()
.getResult();
ColumnList<Long> dstData = dstKeyspace.prepareQuery(columnFamily).getKey(locatorCapture)
.withColumnRange(range)
.execute()
.getResult();
checkSameResults(srcData, dstData);
postExecutor.submit(new Runnable() {public void run() {
out.println(String.format("verified %s", locatorCapture.toString()));
}});
} catch (ConnectionException ex) {
stopAll.set(true);
out.println("There was an error verifying data: " + ex.getMessage());
ex.printStackTrace(out);
} catch (Exception ex) {
stopAll.set(true);
out.println(ex.getMessage() + " " + locatorCapture.toString());
}
}});
}
final long fColCount = colCount;
postExecutor.submit(new Runnable() {
public void run() {
int rowIteration = processedKeys.incrementAndGet();
long colsPerSecond = columnsTransferred.get() / Math.max(1, (nowInSeconds() - startClockTime));
out.println(String.format("%d copied %d for %s (%d m/s), %d", rowIteration, fColCount, locatorCapture.toString(), colsPerSecond, columnsTransferred.get()));
heartbeat.set(System.currentTimeMillis());
}
});
// possibly throttle if we've sent a lot of columns.