Examples of TransactionManager


Examples of javax.transaction.TransactionManager

   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

Examples of javax.transaction.TransactionManager

   {
      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

Examples of javax.transaction.TransactionManager

@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

Examples of javax.transaction.TransactionManager

      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

Examples of javax.transaction.TransactionManager

      */
   }

   private TransactionManager beginTransaction() throws SystemException, NotSupportedException
   {
      TransactionManager mgr = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
      mgr.begin();
      return mgr;
   }
View Full Code Here

Examples of javax.transaction.TransactionManager

      }
   }

   public void testNonSerializableReplWithTx() throws Exception
   {
      TransactionManager tm;

      try
      {
         initCaches(Configuration.CacheMode.REPL_SYNC);

         tm = beginTransaction();
         cache1.put("/a/b/c", "test", new ContainerData());
         tm.commit();

         // We should not come here.
         assertNotNull("NonSerializableData should not be null on cache2", cache2.get("/a/b/c", "test"));
      }
      catch (RollbackException rollback)
View Full Code Here

Examples of javax.transaction.TransactionManager

//      wrapper.setManageCacheLifecycle(true);
      wrapper.create();
      wrapper.start();

      TransactionManager tm = config.getRuntimeConfig().getTransactionManager();

      tm.begin();
      try
      {
         Fqn fqn = Fqn.fromString("/testing/jmx");
         cache.put(fqn, "foobar", "barfoo");

         String locks = html ? wrapper.printLockInfoAsHtml() : wrapper.printLockInfo();

         assertTrue("Details include testing", locks.contains("testing"));
         assertTrue("Details include jmx", locks.contains("jmx"));

         return locks;
      }
      catch (Exception e)
      {
         tm.setRollbackOnly();
         throw e;
      }
      finally
      {
         tm.commit();
      }

   }
View Full Code Here

Examples of javax.transaction.TransactionManager

      m = null;
   }

   public void testSuppressionOfWriteLocks() throws Exception
   {
      TransactionManager m = cache.getTransactionManager();

      m.begin();
      assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
      cache.put(fqn, "x", "1");
      assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
      assertEquals(2, cache.getNumberOfLocksHeld());
      m.commit();
      assertEquals(0, cache.getNumberOfLocksHeld());

      cache.removeNode(fqn);

      m.begin();
      cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
      assertTrue(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
      cache.put(fqn, "x", "2");
      assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
      assertEquals(0, cache.getNumberOfLocksHeld());
      m.commit();
      assertEquals(0, cache.getNumberOfLocksHeld());

      // test normal operation again
      cache.removeNode(fqn);

      m.begin();
      assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
      cache.put(fqn, "x", "3");
      assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
      assertEquals(2, cache.getNumberOfLocksHeld());
      m.commit();
      assertEquals(0, cache.getNumberOfLocksHeld());
   }
View Full Code Here

Examples of javax.transaction.TransactionManager

    *
    * @throws Exception
    */
   public void testSuppressionOf2WriteLocks() throws Exception
   {
      TransactionManager m = cache.getTransactionManager();

      m.begin();
      cache.put(fqn, "x", "1");
      assertEquals(2, cache.getNumberOfLocksHeld());
      m.commit();
      assertEquals(0, cache.getNumberOfLocksHeld());

      cache.removeNode(fqn);

      m.begin();
      cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
      cache.put(fqn, "x", "2");
      cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
      cache.put(fqn1, "y", "3");
      assertEquals(0, cache.getNumberOfLocksHeld());
      m.commit();
      assertEquals(0, cache.getNumberOfLocksHeld());

      Map<String, String> map = new HashMap<String, String>();
      map.put("x", "1");
      m.begin();
      cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
      cache.put(fqn, map);
      cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
      cache.put(fqn1, map);
      assertEquals(0, cache.getNumberOfLocksHeld());
      m.commit();
      assertEquals(0, cache.getNumberOfLocksHeld());

      // test normal operation again
      cache.removeNode(fqn);

      m.begin();
      cache.put(fqn, "x", "3");
      assertEquals(2, cache.getNumberOfLocksHeld());
      m.commit();
      assertEquals(0, cache.getNumberOfLocksHeld());
   }
View Full Code Here

Examples of javax.transaction.TransactionManager

      cache2.start();

      TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);

      // get a lock on cache 2 and hold on to it.
      TransactionManager tm = cache2.getConfiguration().getRuntimeConfig().getTransactionManager();
      tm.begin();
      cache2.put(fqn, "block", "block");
      Transaction t = tm.suspend();

      cache1.put(fqn, "k", "v");
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.