Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.OptimisticTransactionEntry


      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


      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

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

      GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
      TransactionTable table = cache.getTransactionTable();
      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
      assertNotNull(mgr.getTransaction());
      MethodCall meth = entry.getModifications().get(0);
      mgr.commit();

      //test local calls
      List<?> calls = dummy.getAllCalledIds();
      assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
      assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));

      assertNull(mgr.getTransaction());

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


      GlobalTransaction remoteGtx = new GlobalTransaction();

      remoteGtx.setAddress(new DummyAddress());

//      hack the method call to make it have the remote gtx

      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

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

      GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
      TransactionTable table = cache.getTransactionTable();
      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
      assertNotNull(mgr.getTransaction());
      MethodCall meth = entry.getModifications().get(0);
      mgr.commit();

      //test local calls
      List<?> calls = dummy.getAllCalledIds();
      assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
      assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));

      GlobalTransaction remoteGtx = new GlobalTransaction();

      remoteGtx.setAddress(new DummyAddress());

//      hack the method call to make it have the remote gtx

      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

      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/two").getKeys().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().getKeys().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);

      //assert we can see this with a key value get in the transaction
      assertEquals(1, cache.getNode("/one/two").getKeys().size());
      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(1, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());

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

      assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
      assertNull(mgr.getTransaction());

      mgr.begin();

      SamplePojo pojo2 = new SamplePojo(22, "test2");

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

      mgr.commit();

      // let async calls propagate
      TestingUtil.sleepThread((long) 1000);

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

      mgr.resume(tx);

      boolean fail = false;
      try
      {
         mgr.commit();
      }
      catch (Exception e)
      {
         fail = true;

      }

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

      assertEquals(0, entry.getTransactionWorkSpace().getNodes().size());

      assertTrue(cache.exists(Fqn.fromString("/one/two")));
      assertNotNull(cache.getNode("/one"));
      assertEquals(false, cache.getRoot().getLock().isLocked());
      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock().isLocked());
View Full Code Here

      cache.removeNode("/one/two");

      TransactionTable table = cache.getTransactionTable();
      GlobalTransaction gtx = table.get(tx);
      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
      TransactionWorkspace workspace = entry.getTransactionWorkSpace();

      mgr.commit();

      assert 2 == dummy.getAllCalled().size();
      assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
      assert dummy.getAllCalled().contains(MethodDeclarations.optimisticPrepareMethod);

      //assert what should be the results of our call
      assertEquals(0, workspace.getNodes().size());

      assertTrue(entry.getLocks().isEmpty());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(0, listener.getNodesAdded());
   }
View Full Code Here

      TransactionTable table = cache.getTransactionTable();

      GlobalTransaction gtx = table.get(tx);

      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) 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(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
      assertNotNull(workspace.getNode(Fqn.fromString("/one")));
      assertEquals(false, workspace.getNode(Fqn.fromString("/one")).isDeleted());
      List<Set<Fqn>> mergedChildren = workspace.getNode(Fqn.fromString("/one")).getMergedChildren();
      assertEquals(1, mergedChildren.get(1).size());
      System.out.println(entry.getModifications());
      assertTrue(!cache.exists("/one/two"));
   }
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.