Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.GlobalTransaction


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

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

      GlobalTransaction gtx2 = new GlobalTransaction();
      gtx2.setId(10);

      assert gtx != gtx2;

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


   public void testThreadLockedByGtx() throws InterruptedException
   {
      InvocationContextContainer icc = getInvocationContextContainer();
      final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
      GlobalTransaction gtx = new GlobalTransaction();
      gtx.setId(10);
      icc.get().setGlobalTransaction(gtx);
      final AtomicBoolean acquired = new AtomicBoolean(false);
      final AtomicBoolean threwExceptionOnRelease = new AtomicBoolean(false);

      lock.lock();
View Full Code Here

      {
         public void run()
         {
            try
            {
               GlobalTransaction gtx = new GlobalTransaction();
               gtx.setId(10);
               icc.get().setGlobalTransaction(gtx);
               acquired.set(lock.tryLock(10, TimeUnit.MILLISECONDS));
            }
            catch (InterruptedException e)
            {
View Full Code Here

   {
      final InvocationContextContainer icc = getInvocationContextContainer();
      final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
      final AtomicBoolean acquired = new AtomicBoolean(false);
      final AtomicBoolean threwExceptionOnRelease = new AtomicBoolean(false);
      GlobalTransaction gtx = new GlobalTransaction();
      gtx.setId(10);
      icc.get().setGlobalTransaction(gtx);

      lock.lock();
      assert lock.getOwner().equals(gtx);
      assert lock.getHoldCount() == 1;

      Thread t = new Thread()
      {
         public void run()
         {
            try
            {
               GlobalTransaction gtx = new GlobalTransaction();
               gtx.setId(20);
               icc.get().setGlobalTransaction(gtx);
               acquired.set(lock.tryLock(10, TimeUnit.MILLISECONDS));
            }
            catch (InterruptedException e)
            {
View Full Code Here

   public void testGtxLockedByGtxSuccess() throws InterruptedException
   {
      final InvocationContextContainer icc = getInvocationContextContainer();
      final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
      final AtomicBoolean acquired = new AtomicBoolean(false);
      GlobalTransaction gtx = new GlobalTransaction();
      gtx.setId(10);
      icc.get().setGlobalTransaction(gtx);

      lock.lock();
      assert lock.getOwner().equals(gtx);
      assert lock.getHoldCount() == 1;

      Thread t = new Thread()
      {
         public void run()
         {
            try
            {
               GlobalTransaction gtx = new GlobalTransaction();
               gtx.setId(10);
               icc.get().setGlobalTransaction(gtx);
               acquired.set(lock.tryLock(10, TimeUnit.MILLISECONDS));
            }
            catch (InterruptedException e)
            {
View Full Code Here

   {
      control = createStrictControl();
      container = control.createMock(DataContainer.class);
      notifier = control.createMock(Notifier.class);
      nodes = new MockNodesFixture();
      globalTransaction = new GlobalTransaction();
      dataVersion = new DefaultDataVersion(10);
      ctx = createLegacyInvocationContext(container);

      AbstractVersionedDataCommand command = moreSetUp();
      command.initialize(notifier, container);
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

   /**
    * @return a GlobalTransaction instance if the current call is participating in a transaction, or the current thread otherwise.
    */
   protected final Object currentRequestor()
   {
      GlobalTransaction gtx;
      return (gtx = invocationContextContainer.get().getGlobalTransaction()) == null ? Thread.currentThread() : gtx;
   }
View Full Code Here

      }
      else
      {
         InvocationContext ctx = invocationContextContainer.get();
         cacheStatusCheck(ctx);
         GlobalTransaction tx = transactionTable.getCurrentTransaction();
         RemoveNodeCommand command = commandsFactory.buildRemoveNodeCommand(tx, fqn);
         Object retval = invoker.invoke(ctx, command);
         return retval != null && (Boolean) retval;
      }
   }
View Full Code Here

   @SuppressWarnings("unchecked")
   public V remove(Fqn fqn, K key) throws CacheException
   {
      InvocationContext ctx = invocationContextContainer.get();
      cacheStatusCheck(ctx);
      GlobalTransaction tx = transactionTable.getCurrentTransaction();
      RemoveKeyCommand command = commandsFactory.buildRemoveKeyCommand(tx, fqn, key);
      return (V) invoker.invoke(ctx, command);
   }
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.