@Test
public void testCallbackWithContentionOneWriter() throws Exception {
final AtomicInteger count = new AtomicInteger(1);
new RunTask(serverNode) { public void run() {
DummyManagedObject dummy = new DummyManagedObject();
dummy.setValue(count.getAndIncrement());
dataService.setBinding("dummy", dummy);
System.err.println(
"Node " + nodeId + ": set dummy value: " + dummy.value);
} }.runTask();
final AtomicBoolean stop = new AtomicBoolean();
for (int i = 0; i < 2; i++) {
new RunTask(appNodes.get(0)) { public void run() {
if (stop.get()) {
return;
}
DummyManagedObject dummy =
(DummyManagedObject) dataService.getBinding("dummy");
System.err.println(
"Node " + nodeId + ": get dummy value: " + dummy.value);
txnScheduler.scheduleTask(this, taskOwner);
} }.runTask();
}
for (int i = 0; i < 10; i++) {
new RunTask(appNodes.get(1)) { public void run() {
DummyManagedObject dummy = (DummyManagedObject)
dataService.getBindingForUpdate("dummy");
dummy.setValue(count.getAndIncrement());
System.err.println(
"Node " + nodeId + ": set dummy value: " + dummy.value);
} }.runTask();
}
stop.set(true);