Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.OptimisticTransactionEntry


      c.put("/one/two", "key1", "value");

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

      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);
      TestingUtil.getRemoteDelegate(c)._replicate(prepareMethod);

      //our thread should be null
      assertNull(mgr.getTransaction());

      //   there should be a registration for the remote gtx
      assertNotNull(table.get(remoteGtx));
      assertNotNull(table.getLocalTransaction(remoteGtx));
      //assert that this is populated
      //assert that the remote prepare has populated the local workspace
      assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
      List<?> calls = dummy.getAllCalled();
      assertEquals(MethodDeclarations.optimisticPrepareMethod, calls.get(2));

      assertEquals(1, c.getTransactionTable().getNumGlobalTransactions());
      assertEquals(1, c.getTransactionTable().getNumLocalTransactions());
View Full Code Here


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

         gtx = GlobalTransaction.create(addr);
         transactionTable.put(tx, gtx);
         TransactionEntry ent = null;
         try
         {
            ent = configuration.isNodeLockingOptimistic() ? new OptimisticTransactionEntry(tx) : new TransactionEntry(tx);
         }
         catch (Exception e)
         {
            throw new CacheException("Unable to create a transaction entry!", e);
         }
View Full Code Here

      assertEquals(null, dummy.getCalled());
      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(0, workspace.getNodes().size());
      assertNull(workspace.getNode(Fqn.fromString("/one/two")));
      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);

      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"));
      assertEquals(0, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      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);

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());

      cache.getNode("/one/two").clearData();

      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"));
      assertEquals(0, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      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);

      TransactionWorkspace workspace = entry.getTransactionWorkSpace();
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());

      cache.getNode("/one").clearData();

      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"));
      assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
      assertTrue(entry.getLocks().isEmpty());
      assertEquals(2, entry.getModifications().size());
      assertTrue(!cache.exists("/one/two"));
      assertEquals(null, dummy.getCalled());
   }
View Full Code Here

      }
   }

   protected TransactionWorkspace getTransactionWorkspace(GlobalTransaction gtx) throws CacheException
   {
      OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) cache.getTransactionTable().get(gtx);

      if (transactionEntry == null)
      {
         throw new CacheException("unable to map global transaction " + gtx + " to transaction entry");
      }

      // try and get the workspace from the transaction
      return transactionEntry.getTransactionWorkSpace();
   }
View Full Code Here

         TransactionEntry entry;
         if (txTable.get(gtx) == null)
         {
            // create a new transaction entry

            entry = configuration.isNodeLockingOptimistic() ? new OptimisticTransactionEntry(ltx) : new TransactionEntry(ltx);
            log.debug("creating new tx entry");
            txTable.put(gtx, entry);
            if (trace) log.trace("TxTable contents: " + txTable);
         }
         else
View Full Code Here

      for (Fqn fqn : modifiedFqns) invalidateAcrossCluster(fqn, workspace, synchronous, ctx);
   }

   protected TransactionWorkspace getWorkspace(GlobalTransaction gtx)
   {
      OptimisticTransactionEntry entry = (OptimisticTransactionEntry) txTable.get(gtx);
      return entry.getTransactionWorkSpace();
   }
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.