@Test
public void testGetAllWithCallbackThreadsAndCheckpoints() throws Exception {
try {
final AtomicLong counter = new AtomicLong();
final CheckpointManager manager = new AstyanaxCheckpointManager(keyspace, CF_CHECKPOINTS.getName(), 123L);
// Read rows in 4 threads
keyspace.prepareQuery(CF_LOTS_OF_ROWS)
.getAllRows()
.setRowLimit(10)
.setRepeatLastToken(true)
.setConcurrencyLevel(4)
.setCheckpointManager(manager)
.executeWithCallback(new RowCallback<Long, String>() {
@Override
public void success(Rows<Long, String> rows) {
try {
LOG.info("Checkpoint: " + manager.getCheckpoints());
} catch (Exception e) {
e.printStackTrace();
}
LOG.info(Thread.currentThread().getName());
for (Row<Long, String> row : rows) {
LOG.info(Thread.currentThread().getName() + " " + row.getKey());
counter.incrementAndGet();
}
}
@Override
public boolean failure(ConnectionException e) {
LOG.error(e.getMessage(), e);
return false;
}
});
Assert.assertEquals(LOTS_OF_ROWS_COUNT, counter.get());
LOG.info("Read " + counter.get() + " keys");
LOG.info(manager.getCheckpoints().toString());
keyspace.prepareQuery(CF_LOTS_OF_ROWS)
.getAllRows()
.setRowLimit(10)
.setRepeatLastToken(true)