6768697071727374757677
TransactionManager mgr = c.getTransactionManager(); try { mgr.begin(); c.put("/a", "k", "v"); Transaction t = mgr.suspend(); c.put("/a", "k2", "v2"); mgr.resume(t); mgr.commit(); assertTrue("Expecting a rollback exception!", false); }
343344345346347348349350351352353
TransactionManager mgr = c.getTransactionManager(); mgr.begin(); c.put(fqn, "key2", "value2"); Transaction tx = mgr.suspend(); // now remove the original node... c.removeNode(fqn); mgr.resume(tx);
376377378379380381382383384385386
TransactionManager mgr = c.getTransactionManager(); mgr.begin(); c.put(fqn, "key2", "value2"); Transaction tx = mgr.suspend(); // now change the original node... c.put(fqn, "key3", "value3"); mgr.resume(tx);
3637383940414243444546
assertEquals("value", cache.get("/a", "key")); assertEquals(0, cache.getNumberOfLocksHeld()); mgr.begin(); cache.put("/b", "key", "value"); Transaction tx1 = mgr.suspend(); mgr.begin(); cache.put("/b", "key", "value2"); mgr.commit();
232233234235236237238239240241242
SamplePojo pojo = new SamplePojo(21, "test"); cache.put("/one/two", "key1", pojo); mgr.suspend(); assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions()); assertEquals(1, cache.getTransactionTable().getNumLocalTransactions()); assertNull(mgr.getTransaction());
424425426427428429430431432433434
SamplePojo pojo = new SamplePojo(21, "test"); cache.put("/one/two", "key1", pojo); mgr.suspend(); assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions()); assertEquals(1, cache.getTransactionTable().getNumLocalTransactions()); GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
508509510511512513514515516517518
Transaction tx = mgr.getTransaction(); System.out.println("Current TX " + mgr.getTransaction()); assertEquals(pojo1, cache.get("/one/two", "key1")); // start another mgr.suspend(); mgr.begin(); System.out.println("Current TX " + mgr.getTransaction()); cache.put("/one/two", "key2", pojo2);
556557558559560561562563564565566
mgr.begin(); Transaction tx = mgr.getTransaction(); assertEquals(1, cache.getNode("/one/two").getKeys().size()); // start another mgr.suspend(); mgr.begin(); cache.put("/one/two", "key2", pojo); mgr.commit();
601602603604605606607608609610611
mgr.begin(); Transaction tx = mgr.getTransaction(); cache.put("/one/two", "key2", "val2");// version for this is 1 // start another mgr.suspend(); // Second TX mgr.begin(); cache.put("/one/two", "key3", "val3"); mgr.commit();// now version is 2, attrs are key1 and key3
540541542543544545546547548549550
cache.put("/a/b/c", null); tx.begin(); cache.removeNode("/a/b/c"); // this node should now be locked. TransactionManager tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager(); Transaction t = tm.suspend(); // start a new tx tm.begin(); try { cache.getNode("/a/b/c");// should fail