Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.GlobalTransaction


      cache.put("/one/two", temp);

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
      //now let us do a prepare
      TestingUtil.replicateCommand(cache, prepareCommand);


      assertEquals(3, workspace.getNodes().size());
View Full Code Here


      cache.put("/one/two", temp);

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      //lets change one of the underlying version numbers
      workspace.getNode(Fqn.fromString("/one/two")).getNode().setVersion(new DefaultDataVersion(2));
      //now let us do a prepare
      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
      try
      {
         TestingUtil.replicateCommand(cache, prepareCommand);
         fail();
      }
View Full Code Here

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

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      //lets change one of the underlying version numbers
      //now let us do a prepare
      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
      try
      {
         TestingUtil.replicateCommand(cache, prepareCommand);
         fail();
      }
View Full Code Here

      cache.put("/one/two", temp);

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

      GlobalTransaction gtx = table.get(tx);

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

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

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      //lets change one of the underlying version numbers
      //now let us do a prepare
      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
      try
      {
         TestingUtil.replicateCommand(cache, prepareCommand);
         fail();
      }
View Full Code Here

      cache.put("/one/two", temp);

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();

      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());

      //lets change one of the underlying version numbers
      //now let us do a prepare
      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);

      try
      {
         TestingUtil.replicateCommand(cache, prepareCommand);
         fail();
View Full Code Here

      cache.put("/one/two", temp);

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();
View Full Code Here

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

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();
View Full Code Here

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

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();
View Full Code Here

   }

   private WorkspaceNode getWorkspaceNode(Fqn fqn) throws Exception
   {
      Transaction tx = cache.getTransactionManager().getTransaction();
      GlobalTransaction gtx = cache.getTransactionTable().get(tx);
      OptimisticTransactionContext te = (OptimisticTransactionContext) cache.getTransactionTable().get(gtx);
      TransactionWorkspace tw = te.getTransactionWorkSpace();
      return tw.getNode(fqn);
   }
View Full Code Here

   {
      InvocationContextContainer icc = getInvocationContextContainer();
      OwnableReentrantLock lock = new OwnableReentrantLock(icc);

      // create and set a gtx
      GlobalTransaction gtx = new GlobalTransaction();
      gtx.setId(10);
      icc.get().setGlobalTransaction(gtx);

      lock.lock(); // locked by current thread
      assert lock.getOwner().equals(gtx);
      assert lock.getHoldCount() == 1;
View Full Code Here

TOP

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

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.