properties.setProperty("com.sun.sgs.txn.timeout", "1000");
serverNodeRestart(properties, true);
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() {
dummy = new DummyManagedObject();
dummy.setValue("a");
service.setBinding("dummy", dummy);
}}, taskOwner);
final CountDownLatch readDummy = new CountDownLatch(2);
final CountDownLatch completedMarkForUpdate = new CountDownLatch(1);
final CountDownLatch threadsDone = new CountDownLatch(2);
final AtomicReference<Throwable> error =
new AtomicReference<Throwable>();
txnScheduler.scheduleTask(new TestAbstractKernelRunnable() {
public void run() throws Exception {
try {
dummy = (DummyManagedObject) service.getBinding("dummy");
assertEquals("a", dummy.value);
readDummy.countDown();
assertTrue(readDummy.await(500, TimeUnit.MILLISECONDS));
assertFalse(
completedMarkForUpdate.await(
100, TimeUnit.MILLISECONDS));
threadsDone.countDown();
} catch (Throwable t) {
if (!isRetryable(t)) {
error.set(t);
threadsDone.countDown();
}
if (t instanceof Exception) {
throw (Exception) t;
} else {
throw (Error) t;
}
}
}}, taskOwner);
txnScheduler.scheduleTask(new TestAbstractKernelRunnable() {
public void run() throws Exception {
try {
DummyManagedObject dummy2 =
(DummyManagedObject) service.getBinding("dummy");
assertEquals("a", dummy2.value);
readDummy.countDown();
assertTrue(readDummy.await(1, TimeUnit.SECONDS));
service.markForUpdate(dummy2);