Package org.infinispan.transaction

Examples of org.infinispan.transaction.TransactionTable


public class TransactionTableFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {

   @Override
   public <T> T construct(Class<T> componentType) {
      if (configuration.invocationBatching().enabled())
         return (T) new TransactionTable();

      if (!configuration.transaction().useSynchronization()) {
         if (configuration.transaction().recovery().enabled()) {
            return (T) new RecoveryAwareTransactionTable();
         } else {
            return (T) new XaTransactionTable();
         }
      } else return (T) new TransactionTable();

   }
View Full Code Here


         if (configuration.isTransactionRecoveryEnabled()) {
            return (T) new RecoveryAwareTransactionTable();
         } else {
            return (T) new XaTransactionTable();
         }
      } else return (T) new TransactionTable();

   }
View Full Code Here

         }
         return null;
      }

      private void completeTransaction(GlobalTransaction globalTransaction, boolean commit) throws Throwable {
         TransactionTable txTable = txTable();
         GlobalTransaction localTxId = remote2localTx.remove(globalTransaction);
         if (localTxId == null) {
            throw new CacheException("Couldn't find a local transaction corresponding to remote transaction " + globalTransaction);
         }
         LocalTransaction localTx = txTable.getLocalTransaction(localTxId);
         if (localTx == null) {
            throw new IllegalStateException("Local tx not found but present in the tx table!");
         }
         TransactionManager txManager = txManager();
         txManager.resume(localTx.getTransaction());
View Full Code Here

         if (configuration.isTransactionRecoveryEnabled()) {
            return (T) new RecoveryAwareTransactionTable();
         } else {
            return (T) new XaTransactionTable();
         }
      } else return (T) new TransactionTable();

   }
View Full Code Here


   private void assertNoLocksOrTxs(Object key, Cache<Object, String> cache) {
      assertNotLocked(originatorCache, key);

      final TransactionTable transactionTable = TestingUtil.extractComponent(cache, TransactionTable.class);

      eventually(new Condition() {
         @Override
         public boolean isSatisfied() throws Exception {
            return transactionTable.getLocalTxCount() == 0 && transactionTable.getRemoteTxCount() == 0;
         }
      });
   }
View Full Code Here

      createCluster(c, 2);
      waitForClusterToForm();
   }

   public void testMinViewId1() throws Exception {
      final TransactionTable tt0 = TestingUtil.getTransactionTable(cache(0));
      final TransactionTable tt1 = TestingUtil.getTransactionTable(cache(1));

      StateTransferManager stateTransferManager0 = TestingUtil.extractComponent(cache(0), StateTransferManager.class);
      final int topologyId = stateTransferManager0.getCacheTopology().getTopologyId();

      assertEquals(tt0.getMinTopologyId(), topologyId);
      assertEquals(tt1.getMinTopologyId(), topologyId);

      //add a new cache and check that min view is updated
      log.trace("Adding new node ..");
      addClusterEnabledCacheManager(c);
      waitForClusterToForm();
      log.trace("New node added.");

      final int topologyId2 = stateTransferManager0.getCacheTopology().getTopologyId();
      assertTrue(topologyId2 > topologyId);

      final TransactionTable tt2 = TestingUtil.getTransactionTable(cache(2));
      eventually(new Condition() {
         @Override
         public boolean isSatisfied() throws Exception {
            return tt0.getMinTopologyId() == topologyId2
                  && tt1.getMinTopologyId() == topologyId2
                  && tt2.getMinTopologyId() == topologyId2;
         }
      });
   }
View Full Code Here

         }
      });
   }

   public void testMinViewId2() throws Exception {
      final TransactionTable tt0 = TestingUtil.getTransactionTable(cache(0));
      final TransactionTable tt1 = TestingUtil.getTransactionTable(cache(1));

      StateTransferManager stateTransferManager0 = TestingUtil.extractComponent(cache(0), StateTransferManager.class);
      final int topologyId = stateTransferManager0.getCacheTopology().getTopologyId();

      tm(1).begin();
      cache(1).put(getKeyForCache(0),"v");
      final DummyTransaction t = (DummyTransaction) tm(1).getTransaction();
      t.runPrepare();
      tm(1).suspend();

      eventually(new Condition() {
         @Override
         public boolean isSatisfied() throws Exception {
            return checkTxCount(0, 0, 1);
         }
      });

      log.trace("Adding new node ..");
      //add a new cache and check that min view is updated
      addClusterEnabledCacheManager(c);
      waitForClusterToForm();
      log.trace("New node added.");

      final int topologyId2 = stateTransferManager0.getCacheTopology().getTopologyId();
      assertTrue(topologyId2 > topologyId);

      assertEquals(tt0.getMinTopologyId(), topologyId);
      assertEquals(tt1.getMinTopologyId(), topologyId);

      tm(1).resume(t);
      t.runCommitTx();

      eventually(new Condition() {
         @Override
         public boolean isSatisfied() throws Exception {
            return tt0.getMinTopologyId() == topologyId2 && tt1.getMinTopologyId() == topologyId2;
         }
      });
   }
View Full Code Here

      Thread.sleep(100);
   }

   private synchronized int completedLocalTransactions() {
      int count = 0;
      TransactionTable transactionTable = getTransactionTable();
      for (GlobalTransaction tx : localTransactionsSeen) {
         if (!transactionTable.containsLocalTx(tx)) {
            count++;
         }
      }
      return count;
   }
View Full Code Here

      return count;
   }

   private synchronized int completedRemoteTransactions() {
      int count = 0;
      TransactionTable transactionTable = getTransactionTable();
      for (GlobalTransaction tx : remoteTransactionsSeen) {
         if (!transactionTable.containRemoteTx(tx)) {
            count++;
         }
      }
      return count;
   }
View Full Code Here

            }
         }
      };

      //not too nice: replace the rpc manager in the class that builds the Sync objects
      final TransactionTable transactionTable = TestingUtil.getTransactionTable(cache(1));
      TestingUtil.replaceField(rpcManager, "rpcManager", transactionTable, TransactionTable.class);

      TxControlInterceptor txControlInterceptor = new TxControlInterceptor();
      txControlInterceptor.prepareProgress.countDown();
      txControlInterceptor.commitProgress.countDown();
View Full Code Here

TOP

Related Classes of org.infinispan.transaction.TransactionTable

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.