", threads:" + threads +
", repeat:" + repeat +
", wait:" + wait);
long start = System.currentTimeMillis();
/* Set half the bindings */
new ChunkedTask(txnScheduler, taskOwner) {
protected boolean runChunk() {
ManagedInteger remaining;
DummyManagedObject dummy;
try {
remaining =
(ManagedInteger) service.getBinding("remaining");
dummy = (DummyManagedObject) service.getBinding("dummy");
} catch (NameNotBoundException e) {
remaining = new ManagedInteger(bindings / 2);
service.setBinding("remaining", remaining);
dummy = new DummyManagedObject();
service.setBinding("dummy", dummy);
}
if (remaining.value == 0) {
service.removeBinding("remaining");
return true;
} else {
service.markForUpdate(remaining);
while (remaining.value > 0 &&
taskService.shouldContinue())
{
service.setBinding(
String.valueOf(--remaining.value), dummy);
}
return false;
}
} }.runAwaitDone(1000);
/* Random work */
CountDownLatch done = new CountDownLatch(threads);
AtomicReference<Throwable> failure = new AtomicReference<Throwable>();
for (int i = 0; i < threads; i++) {
txnScheduler.scheduleTask(
new RandomWorkTask(bindings, repeat, done, failure),
taskOwner);
}
assertTrue("Tasks not completed", done.await(wait, TimeUnit.SECONDS));
if (failure.get() != null) {
throw new RuntimeException(
"Unexpected exception: " + failure.get().getMessage(),
failure.get());
}
/* Remove all bindings */
new ChunkedTask(txnScheduler, taskOwner) {
protected boolean runChunk() {
ManagedInteger remaining;
try {
remaining = (ManagedInteger) service.getBinding("remaining");
} catch (NameNotBoundException e) {