CacheSPI<Object, Object> cacheB = createCache("B");
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cacheA, cacheB}, 60000);
final TransactionManager tm = cacheB.getTransactionManager();
tm.begin();
final Transaction tx = tm.getTransaction();
cacheB.put("/1/A", "1", "B");
cacheB.put("/1/A", "2", "B");
cacheB.put("/2/A", "1", "B");
cacheB.put("/2/A", "2", "B");
cacheB.put("/1/A/I", "1", "B");
cacheB.put("/1/A/I", "2", "B");
cacheB.put("/EXISTS", "KEY", "B");
Object monitor = new Object();
HangSync sync = new HangSync(monitor);
tx.registerSynchronization(sync);
Thread t = new Thread()
{
public void run()
{
try
{
tm.resume(tx);
tm.commit();
}
catch (Exception e)
{
}
}
};
synchronized (monitor)
{
t.start();
while (!sync.hung)
{
monitor.wait(500);
}
}
tm.suspend();
// Confirm that B's tx replicated
assertTrue(cacheA.peek(Fqn.fromString("/EXISTS"), false, false) != null);
cacheB.stop();