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);
dummy.setNext(new DummyManagedObject());
}}, taskOwner);
final Semaphore mainFlag = new Semaphore(0);
final Semaphore threadFlag = new Semaphore(0);
// Semaphore to let us know when we are done; both threads must release
final Semaphore doneFlag = new Semaphore(2);
doneFlag.acquire(2);
final AtomicReference<Throwable> error =
new AtomicReference<Throwable>();
txnScheduler.scheduleTask(new TestAbstractKernelRunnable() {
public void run() throws Exception {
try {
dummy = (DummyManagedObject) service.getBinding("dummy");
dummy.getNext();
assertTrue(threadFlag.tryAcquire(100, TimeUnit.MILLISECONDS));
mainFlag.release();
assertFalse(threadFlag.tryAcquire(100, TimeUnit.MILLISECONDS));
doneFlag.release();
} catch (Throwable t) {
// We don't expect any non-retryable throwables
if (!isRetryable(t)) {
doneFlag.release();
error.set(t);
}
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");
threadFlag.release();
assertTrue(mainFlag.tryAcquire(1, TimeUnit.SECONDS));
dummy2.getNextForUpdate();
threadFlag.release();
doneFlag.release();
} catch (Throwable t) {
// We don't expect any non-retryable throwables
if (!isRetryable(t)) {