.setConcurrencyLevel(1) // one execution thread for fetching portion of rows .setExceptionCallback(new ExceptionCallback() { private int retries = 0;
@Test public void getAllWithCallback() throws Exception { final AtomicLong counter = new AtomicLong(); keyspace.prepareQuery(CF_ALL_ROWS).getAllRows() .setRowLimit(30) .setRepeatLastToken(false) .setConcurrencyLevel(2) //.withColumnRange(new RangeBuilder().setLimit(2).build()) .executeWithCallback(new RowCallback<String, String>() { @Override public void success(Rows<String, String> rows) { for (Row<String, String> row : rows) { LOG.info("ROW: " + row.getKey() + " " + row.getColumns().size()); counter.incrementAndGet(); } } @Override public boolean failure(ConnectionException e) { LOG.error(e.getMessage(), e); return false; } }); LOG.info("Read " + counter.get() + " keys"); Assert.assertEquals(26, counter.get()); }
@Test public void getAll() throws Exception { AtomicLong counter = new AtomicLong(0); OperationResult<Rows<String, String>> rows = keyspace .prepareQuery(CF_ALL_ROWS).getAllRows().setConcurrencyLevel(2).setRowLimit(30) //.withColumnRange(new RangeBuilder().setLimit(0).build()) .setExceptionCallback(new ExceptionCallback() { @Override public boolean onException(ConnectionException e) { Assert.fail(e.getMessage()); return true; } }).execute(); for (Row<String, String> row : rows.getResult()) { counter.incrementAndGet(); LOG.info("ROW: " + row.getKey() + " " + row.getColumns().size()); } LOG.info("Read " + counter.get() + " keys"); Assert.assertEquals(26, counter.get()); } }
.setConcurrencyLevel(1) // one execution thread for fetching portion of rows .setExceptionCallback(new ExceptionCallback() { private int retries = 0;
.setConcurrencyLevel(1) // one execution thread for fetching portion of rows .setExceptionCallback(new ExceptionCallback() { private int retries = 0;