Examples of TransactionManager


Examples of javax.transaction.TransactionManager

   {
      DataVersion version = new DefaultDataVersion(200);
      cache[0].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      version = new DefaultDataVersion(100);
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[1].put(fqn, key, "value2");
      try
      {
         // this call will use implicit versioning and will hence fail.
         mgr.commit();
         assertTrue("expected to fail", false);
      }
      catch (Exception e)
      {
         // should fail.
View Full Code Here

Examples of javax.transaction.TransactionManager

   public void testLocalTransaction() throws Exception
   {

      CacheSPI<Object, Object> cache = createCacheWithListener();

      TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      assertNull(mgr.getTransaction());

      mgr.begin();

      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      SamplePojo pojo = new SamplePojo(21, "test");

      cache.put("/one/two", "key1", pojo);

      mgr.commit();

      assertNull(mgr.getTransaction());
      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      assertTrue(cache.exists(Fqn.fromString("/one/two")));
      assertNotNull(cache.getRoot().getChild("one"));
View Full Code Here

Examples of javax.transaction.TransactionManager

      TestListener listener = new TestListener();

      CacheSPI<Object, Object> cache = createCacheWithListener(listener);
      LockManager lockManager = TestingUtil.extractLockManager(cache);

      TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      assertNull(mgr.getTransaction());

      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      SamplePojo pojo = new SamplePojo(21, "test");

      cache.put("/one/two", "key1", pojo);

      assertNull(mgr.getTransaction());
      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      assertTrue(cache.exists(Fqn.fromString("/one/two")));
      assertNotNull(cache.getRoot().getChild("one"));
View Full Code Here

Examples of javax.transaction.TransactionManager

   {
      groupIncreaser++;
      CacheSPI<Object, Object> cache = createCacheWithListener();
      LockManager lockManager = TestingUtil.extractLockManager(cache);

      TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      assertNull(mgr.getTransaction());

      mgr.begin();

      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      SamplePojo pojo = new SamplePojo(21, "test");

      cache.put("/one/two", "key1", pojo);

      mgr.commit();

      assertNull(mgr.getTransaction());
      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      assertTrue(cache.exists(Fqn.fromString("/one/two")));
      assertNotNull(cache.getRoot().getChild("one"));
View Full Code Here

Examples of javax.transaction.TransactionManager

      Configuration c = new Configuration();
      c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
      CacheSPI<String, String> cache = (CacheSPI<String, String>) new UnitTestCacheFactory<String, String>().createCache(c, MarkAsRollbackTest.class);
      try
      {
         TransactionManager tm = cache.getTransactionManager();
         assert tm != null;
         tm.begin();
         cache.put(fqn, "k", "v");
         assert cache.get(fqn, "k").equals("v");
         assert cache.getRoot().getChildren().size() == 1;
         tm.setRollbackOnly();
         try
         {
            tm.commit();
            assert false : "Should have rolled back";
         }
         catch (RollbackException expected)
         {
         }

         assert tm.getTransaction() == null : "There should be no transaction in scope anymore!";
         assert cache.get(fqn, "k") == null : "Expected a null but was " + cache.get(fqn, "k");
         assert cache.getRoot().getChildren().size() == 0;
      }
      finally
      {
View Full Code Here

Examples of javax.transaction.TransactionManager

      Configuration c = new Configuration();
      c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
      CacheSPI<String, String> cache = (CacheSPI<String, String>) new UnitTestCacheFactory<String, String>().createCache(c, MarkAsRollbackTest.class);
      try
      {
         TransactionManager tm = cache.getTransactionManager();
         assert tm != null;
         tm.begin();
         tm.setRollbackOnly();
         try
         {
            cache.put(fqn, "k", "v");
            assert false : "Should have failed";
         }
         catch (CacheException expected)
         {
           assert expected.getCause() instanceof RollbackException : "exception wrapped and thrown should be RollbackException. Exception class "+expected.getCause().getClass();
         }
         try
         {
            tm.commit();
            assert false : "Should have rolled back";
         }
         catch (RollbackException expected)
         {

         }

         assert tm.getTransaction() == null : "There should be no transaction in scope anymore!";
         assert cache.get(fqn, "k") == null : "Expected a null but was " + cache.get(fqn, "k");
         assert cache.getRoot().getChildren().size() == 0;
      }
      finally
      {
View Full Code Here

Examples of javax.transaction.TransactionManager

   public void setUp()
   {
      icc = new InvocationContextContainer();
      icc.injectContextFactory(new MVCCContextFactory());
      lm = new MVCCLockManager();
      TransactionManager tm = getTransactionManager();
      lm.injectConfiguration(new Configuration());
      lm.injectDependencies(null, null, tm, icc);
      lm.startLockManager();
   }
View Full Code Here

Examples of javax.transaction.TransactionManager

      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();
View Full Code Here

Examples of javax.transaction.TransactionManager

      {
         public void run()
         {
            try
            {
               TransactionManager tx = startTransaction();

               // change VALUE in a transaction
               cache.removeNode(FQN);

               // notify the reading thread
               readerCanRead.countDown();

               readerDone.await();

               tx.commit();
            }
            catch (AssertionError e)
            {
               writerError = e;
            }
View Full Code Here

Examples of javax.transaction.TransactionManager

   }

   private TransactionManager startTransaction() throws SystemException, NotSupportedException
   {
      TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      mgr.begin();
      return mgr;
   }
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.