client.deleteTable(creds, TABLE_TEST);
client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
WriterOptions writerOptions = new WriterOptions();
writerOptions.setLatencyMs(10000);
writerOptions.setMaxMemory(2);
writerOptions.setThreads(1);
writerOptions.setTimeoutMs(100000);
String batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
try {
client.flush(batchWriter);
fail("constraint did not fire");
} catch (MutationsRejectedException ex) {}
try {
client.closeWriter(batchWriter);
fail("constraint did not fire");
} catch (MutationsRejectedException e) {}
client.removeConstraint(creds, TABLE_TEST, 1);
UtilWaitThread.sleep(2000);
writerOptions = new WriterOptions();
writerOptions.setLatencyMs(10000);
writerOptions.setMaxMemory(3000);
writerOptions.setThreads(1);
writerOptions.setTimeoutMs(100000);
batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
client.flush(batchWriter);