Package javax.transaction

Examples of javax.transaction.TransactionManager


   }

   public void dataInconsistency() throws Exception
   {
      Fqn node = Fqn.fromString("/a");
      TransactionManager tm1 = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
      TransactionManager tm2 = cache2.getConfiguration().getRuntimeConfig().getTransactionManager();
      tm1.begin();
      cache1.put(node, "k", "v-older");
      Transaction t1 = tm1.suspend();

      tm2.begin();
      cache2.put(node, "k", "v-newer");
      tm2.commit();

      tm1.resume(t1);
      try
      {
         tm1.commit();
View Full Code Here


   }


   public void testPutAfterTxCommit() throws Exception
   {
      TransactionManager mgr = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
      mgr.begin();

      cache1.put(fqn, "key1", "val1");
      assertTrue(cache1.exists(fqn));
      mgr.commit();
      assertTrue(cache1.exists(fqn));
      cache1.put("/a/b/c", null);// should be run outside a TX !
      assertTrue(cache1.exists("/a/b/c"));
   }
View Full Code Here

      assertTrue(cache1.exists("/a/b/c"));
   }

   public void testPutAfterTxRollback() throws Exception
   {
      TransactionManager mgr = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
      mgr.begin();

      cache1.put(fqn, "key1", "val1");
      assertTrue(cache1.exists(fqn));
      mgr.rollback();
      assertFalse(cache1.getCacheLoaderManager().getCacheLoader().exists(fqn));
      assertFalse(cache1.exists(fqn));
      cache1.put("/a/b/c", null);// should be run outside a TX !
      assertTrue(cache1.exists("/a/b/c"));
   }
View Full Code Here

   }

   public void testPessimisticTransactionalWithCacheLoader() throws Exception
   {
      Fqn fqn = Fqn.fromString("/a/b");
      TransactionManager mgr = cache1.getTransactionManager();
      assertNull("Should be null", cache1.get(fqn, "key"));
      assertNull("Should be null", cache2.get(fqn, "key"));
      mgr.begin();
      cache1.put(fqn, "key", "value");
      assertEquals("value", cache1.get(fqn, "key"));
      mgr.commit();
      assertEquals("value", cache2.get(fqn, "key"));
      assertEquals("value", cache1.get(fqn, "key"));

      mgr.begin();
      cache1.put(fqn, "key2", "value2");
      assertEquals("value2", cache1.get(fqn, "key2"));
      mgr.rollback();
      assertEquals("value", cache2.get(fqn, "key"));
      assertEquals("value", cache1.get(fqn, "key"));
      assertNull("Should be null", cache1.get(fqn, "key2"));
      assertNull("Should be null", cache2.get(fqn, "key2"));
   }
View Full Code Here

         Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
         r2.registerContextClassLoader(clb);
      }

      if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
      TransactionManager tm = beginTransaction();
      cache1.put(Fqn.fromString("/aop/1"), "person", srtl.ben_);
      cache1.remove(Fqn.fromString("/aop/1"), "person");
      HashMap<Object, Object> map = new HashMap<Object, Object>();
      map.put("1", "1");
      map.put("2", "2");
      cache1.put(Fqn.fromString("/aop/2"), map);
      cache1.removeNode(Fqn.fromString("/aop/2"));
      tm.commit();

//      TestingUtil.sleepThread(1000);
      if (useMarshalledValues) resetContextClassLoader();
   }
View Full Code Here

      {
         Region r2 = cache2.getRegion(aop, false) == null ? cache2.getRegion(aop, true) : cache2.getRegion(aop, false);
         r2.registerContextClassLoader(clb);
      }

      TransactionManager tm = beginTransaction();
      if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
      cache1.put(aop, "person", srtl.ben_);
      tm.commit();
      if (useMarshalledValues) resetContextClassLoader();

      Object ben2;
      // Can't cast it to Person. CCE will resutl.
      if (useMarshalledValues) Thread.currentThread().setContextClassLoader(clb);
View Full Code Here

   private TransactionManager beginTransaction() throws SystemException, NotSupportedException
   {
      SyncReplTestTL srtl = threadLocal.get();
      CacheSPI<Object, Object> cache1 = srtl.cache1;

      TransactionManager mgr = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
      mgr.begin();
      return mgr;
   }
View Full Code Here

   {
      Cache<String, String> cache = null;
      try
      {
         cache = init(passivation);
         TransactionManager tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();

         tm.begin();
         assert cache.getNode(fqn.getParent().getParent()).getChildrenNames().size() == 1;
         assert cache.getNode(fqn.getParent()).getChildrenNames().size() == 1;
         tm.rollback();

         // in the fail scenario the rollback corrupts the parent node
         tm.begin();
         assert cache.getNode(fqn.getParent().getParent()).getChildrenNames().size() == 1;
         // watch here:
         int sz = cache.getNode(fqn.getParent()).getChildrenNames().size();
         assert sz == 1 : "Expecting 1, was " + sz;
         tm.commit();
      }
      finally
      {
         TestingUtil.killCaches(cache);
      }
View Full Code Here

@Test(groups = {"functional", "transaction"}, testName = "api.batch.BatchWithTM")
public class BatchWithTM extends AbstractBatchTest
{
   public void testBatchWithOngoingTM() throws Exception
   {
      TransactionManager tm = getTransactionManager(cache);
      tm.begin();
      cache.put("/a/b/c", "k", "v");
      cache.startBatch();
      cache.put("/a/b/c", "k2", "v2");
      tm.commit();

      assert "v".equals(cache.get("/a/b/c", "k"));
      assert "v2".equals(cache.get("/a/b/c", "k2"));

      cache.endBatch(false); // should be a no op
View Full Code Here

      cache1.start();
      cache2.start();

      TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);

      TransactionManager mgr = cache1.getTransactionManager();
      mgr.begin();

      cache1.put(Fqn.fromString("/replicate"), "k", "v");
      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      cache1.put(Fqn.fromString("/not-replicate"), "k", "v");

      mgr.commit();
      Thread.sleep(3000);

      assertEquals("v", cache1.get("/replicate", "k"));
      assertEquals("v", cache1.get("/not-replicate", "k"));
View Full Code Here

TOP

Related Classes of javax.transaction.TransactionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.