Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.OptimisticTransactionEntry


               randomSleep(minSleep, maxSleep);

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

               OptimisticTransactionEntry entry = (OptimisticTransactionEntry) cache.getTransactionTable().get(cache.getCurrentTransaction());
               assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one/two")) != null);
               mgr.commit();
               resetInvocationCtx(cache);
            }
            catch (Exception e)
            {
View Full Code Here


               mgr.setTransaction(tx);
               SamplePojo pojo = new SamplePojo(21, "test");

               setTransactionsInInvocationCtx(mgr, cache);
               cache.put("/one", "key1", pojo);
               OptimisticTransactionEntry entry = (OptimisticTransactionEntry) cache.getTransactionTable().get(cache.getCurrentTransaction());

               randomSleep(minSleep, maxSleep);

               cache.put("/one/two", "key2", pojo);
               assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one")) != null);
               assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one/two")) != null);
            }
            catch (Exception e)
            {
               e.printStackTrace();
            }
View Full Code Here

      assertEquals(null, dummy.getCalled());
      TransactionTable table = cache.getTransactionTable();

      GlobalTransaction gtx = table.get(tx);

      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

      @SuppressWarnings("unchecked")
      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      //assert we can see this with a key value get in the transaction
      assertEquals(1, cache.getNode("/one").getChildrenNames().size());
      mgr.commit();

      //assert what should be the results of our call
      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalled());

      //assert that we cannot see the change if we have not put it into the cache
      // we need to do this as we do not have the tx interceptor in this stack
View Full Code Here

      assertEquals(null, dummy.getCalled());
      TransactionTable table = cache.getTransactionTable();

      GlobalTransaction gtx = table.get(tx);

      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

      //assert we can see this with a key value get in the transaction
      assertEquals(0, cache.getRoot().getChildrenNames().size());
      mgr.commit();


      assertTrue(entry.getLocks().isEmpty());
      assertEquals(0, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalled());
   }
View Full Code Here

      assertEquals(null, dummy.getCalled());
      TransactionTable table = cache.getTransactionTable();

      GlobalTransaction gtx = table.get(tx);

      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

      @SuppressWarnings("unchecked")
      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      //assert we can see this
      assertEquals(1, cache.getNode("/one").getChildrenNames().size());

      try
      {
         for (Iterator<?> it = cache.getNode("/one").getChildrenNames().iterator(); it.hasNext();)
         {
            it.next();
            it.remove();
         }
         fail("Should not be allowed to modify elements in the set returned by getChildrenNames()");
      }
      catch (UnsupportedOperationException uoe)
      {
         // the returned set should be unmodifiable and a remove on the iterator should fail.
      }

      //assert the removal has had no effect
      assertEquals(1, cache.getNode("/one").getChildrenNames().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));

      mgr.commit();


      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalled());
   }
View Full Code Here

      assertEquals(null, dummy.getCalled());
      TransactionTable table = cache.getTransactionTable();

      GlobalTransaction gtx = table.get(tx);

      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

      @SuppressWarnings("unchecked")
      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      //assert we can see this with a key value get in the transaction
      assertEquals(pojo, cache.get("/one/two", "key1"));
      mgr.commit();

      //assert what should be the results of our call
      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalled());

      //assert that we cannot see the change if we have not put it into the cache
      // we need to do this as we do not have the tx interceptor in this stack
View Full Code Here

      assertEquals(null, dummy.getCalled());
      TransactionTable table = cache.getTransactionTable();

      GlobalTransaction gtx = table.get(tx);

      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

      @SuppressWarnings("unchecked")
      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
      assertEquals(pojo2, cache.get("/one/two", "key1"));
      mgr.commit();

      //assert what should be the results of our call
      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo2, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(2, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalled());
   }
View Full Code Here

      assertEquals(null, dummy.getCalled());
      TransactionTable table = cache.getTransactionTable();

      GlobalTransaction gtx = table.get(tx);

      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

      @SuppressWarnings("unchecked")
      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(null, cache.get("/one/two", "key1"));

      mgr.commit();
      //assert what should be the results of our call
      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(null, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(2, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalled());
   }
View Full Code Here

      TransactionTable table = cache.getTransactionTable();


      GlobalTransaction gtx = table.get(tx);

      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);

      @SuppressWarnings("unchecked")
      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      //resume the suspended transaction
      GlobalTransaction gtx2 = table.get(tx2);

      OptimisticTransactionEntry entry2 = (OptimisticTransactionEntry) table.get(gtx2);

      @SuppressWarnings("unchecked")
      TransactionWorkspace<Object, Object> workspace2 = entry2.getTransactionWorkSpace();

      //commit both tx
      mgr.commit();
      mgr.resume(tx);
      mgr.commit();

      //assert that our keys are in one space
      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(null, workspace.getNode(Fqn.fromString("/one/two")).get("key2"));
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());

      //assert that our keys are in one space
      assertEquals(3, workspace2.getNodes().size());
      assertNotNull(workspace2.getNode(Fqn.fromString("/one/two")));
      assertEquals(null, workspace2.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(pojo2, workspace2.getNode(Fqn.fromString("/one/two")).get("key2"));
      assertTrue(entry2.getLocks().isEmpty());
      assertEquals(1, entry2.getModifications().size());

      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalled());
   }
View Full Code Here

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

      GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
      TransactionTable table = cache.getTransactionTable();
      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
      assertEquals(tx, mgr.getTransaction());

      //now send the remote prepare

      GlobalTransaction remoteGtx = new GlobalTransaction();

      remoteGtx.setAddress(new DummyAddress());
      //hack the method call to make it have the remote gtx
      MethodCall meth = entry.getModifications().get(0);

      meth.getArgs()[0] = remoteGtx;
      //call our remote method
      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod_id, remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
      try
      {
         TestingUtil.getRemoteDelegate(cache)._replicate(prepareMethod);
      }
      catch (Throwable t)
View Full Code Here

TOP

Related Classes of org.jboss.cache.transaction.OptimisticTransactionEntry

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.