tm1.begin();
cache1.putForExternalRead(key, value);
tm1.commit();
replListener2.waitForRpc();
final TransactionTable tt1 = TestingUtil.extractComponent(cache1, TransactionTable.class);
final TransactionTable tt2 = TestingUtil.extractComponent(cache2, TransactionTable.class);
eventually(new Condition() {
@Override
public boolean isSatisfied() throws Exception {
return tt1.getRemoteTxCount() == 0 && tt1.getLocalTxCount() == 0 &&
tt2.getRemoteTxCount() == 0 && tt2.getLocalTxCount() == 0;
}
});
replListener2.expectWithTx(PutKeyValueCommand.class);
tm1.begin();
assertEquals(tm1.getTransaction().getStatus(), Status.STATUS_ACTIVE);
cache1.putForExternalRead(key, value);
assertEquals(tm1.getTransaction().getStatus(), Status.STATUS_ACTIVE);
cache1.put(key, value);
assertEquals(tm1.getTransaction().getStatus(), Status.STATUS_ACTIVE);
log.info("Before commit!!");
tm1.commit();
eventually(new Condition() {
@Override
public boolean isSatisfied() throws Exception {
return (tt1.getRemoteTxCount() == 0) && (tt1.getLocalTxCount() == 0) && (tt2.getRemoteTxCount() == 0)
&& (tt2.getLocalTxCount() == 0);
}
});
replListener2.expectWithTx(PutKeyValueCommand.class);
tm1.begin();
cache1.put(key, value);
cache1.putForExternalRead(key, value);
tm1.commit();
eventually(new Condition() {
@Override
public boolean isSatisfied() throws Exception {
return (tt1.getRemoteTxCount() == 0) && (tt1.getLocalTxCount() == 0) && (tt2.getRemoteTxCount() == 0)
&& (tt2.getLocalTxCount() == 0);
}
});
replListener2.expectWithTx(PutKeyValueCommand.class, PutKeyValueCommand.class);
tm1.begin();
cache1.put(key, value);
cache1.putForExternalRead(key, value);
cache1.put(key, value);
tm1.commit();
eventually(new Condition() {
@Override
public boolean isSatisfied() throws Exception {
return (tt1.getRemoteTxCount() == 0) && (tt1.getLocalTxCount() == 0) && (tt2.getRemoteTxCount() == 0)
&& (tt2.getLocalTxCount() == 0);
}
});
}