Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.OptimisticTransactionContext


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

               setTransactionsInInvocationCtx(mgr, cache);
               cache.put("/one", "key1", pojo);
               OptimisticTransactionContext entry = (OptimisticTransactionContext) 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.getCalledCommand());
      TransactionTable table = cache.getTransactionTable();

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();

      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.getCalledCommand());
   }
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

public class OptimisticContextFactory extends PessimisticContextFactory
{
   @Override
   public TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException
   {
      return new OptimisticTransactionContext(tx);
   }
View Full Code Here

      return v;
   }

   protected TransactionWorkspace getWorkspace(InvocationContext ctx)
   {
      OptimisticTransactionContext entry = (OptimisticTransactionContext) ctx.getTransactionContext();
      return entry.getTransactionWorkSpace();
   }
View Full Code Here

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();

      mgr.commit();

      //assert what should be the results of our call
      assertEquals(0, workspace.getNodes().size());
      assertNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(1, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalledCommand());
   }
View Full Code Here

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();

      mgr.commit();

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

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

      GlobalTransaction gtx = table.get(tx);

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

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();

      mgr.commit();

      //assert what should be the results of our call
      assertEquals(3, workspace.getNodes().size());
      assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
      assertNull(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.getCalledCommand());
   }
View Full Code Here

      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();

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

      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();

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

TOP

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

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.