Package org.infinispan.transaction.impl

Examples of org.infinispan.transaction.impl.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


         }
         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

      }
   }

   protected boolean isNodeLocked(Fqn fqn, boolean includeData) {
      TransactionManager tm = cache.getAdvancedCache().getTransactionManager();
      TransactionTable tt = cache.getAdvancedCache().getComponentRegistry().getComponent(TransactionTable.class);
      CacheEntry structure = lookupEntryFromCurrentTransaction(tt, tm, new NodeKey(fqn, NodeKey.Type.STRUCTURE));
      CacheEntry data = lookupEntryFromCurrentTransaction(tt, tm, new NodeKey(fqn, NodeKey.Type.DATA));
      return structure != null && data != null && structure.isChanged() && (!includeData || data.isChanged());
   }
View Full Code Here

      TestingUtil.waitForRehashToComplete(caches(CACHE_NAME));
      assertEquals(finalTopologyId, stm0.getCacheTopology().getTopologyId());

      // Check for stale locks
      final TransactionTable tt0 = TestingUtil.extractComponent(cache0, TransactionTable.class);
      final TransactionTable tt1 = TestingUtil.extractComponent(cache1, TransactionTable.class);
      eventually(new Condition() {
         @Override
         public boolean isSatisfied() throws Exception {
            return tt0.getLocalTxCount() == 0 && tt1.getRemoteTxCount() == 0;
         }
      });

      sequencer.stop();
   }
View Full Code Here

   }

   public void testTxCleanupWithKeySet() throws Exception {
      tm().begin();
      assert cache.keySet().size() == 0;
      TransactionTable txTable = getTransactionTable(cache);
      assert txTable.getLocalTransactions().size() == 1;
      tm().commit();
      assert txTable.getLocalTransactions().size() == 0;
   }
View Full Code Here

   }

   public void testTxCleanupWithEntrySet() throws Exception {
      tm().begin();
      assert cache.entrySet().size() == 0;
      TransactionTable txTable = getTransactionTable(cache);
      assert txTable.getLocalTransactions().size() == 1;
      tm().commit();
      assert txTable.getLocalTransactions().size() == 0;
   }
View Full Code Here

   }

   public void testTxCleanupWithValues() throws Exception {
      tm().begin();
      assert cache.values().size() == 0;
      TransactionTable txTable = getTransactionTable(cache);
      assert txTable.getLocalTransactions().size() == 1;
      tm().commit();
      assert txTable.getLocalTransactions().size() == 0;
   }
View Full Code Here

         assertEquals("v" + i, dataContainer0.get("testkey" + i).getValue());
         assertEquals("v" + i, dataContainer1.get("testkey" + i).getValue());
      }

      // Check for stale locks
      final TransactionTable tt0 = TestingUtil.extractComponent(cache0, TransactionTable.class);
      final TransactionTable tt1 = TestingUtil.extractComponent(cache1, TransactionTable.class);
      eventually(new Condition() {
         @Override
         public boolean isSatisfied() throws Exception {
            return tt0.getLocalTxCount() == 0 && tt1.getRemoteTxCount() == 0;
         }
      });
   }
View Full Code Here

         assertEquals("Cache '" + address(cache) + "' has wrong value!", VALUE, entry.getValue());
      }
   }

   private void checkIfTransactionExists(Cache<Object, Object> cache) {
      TransactionTable table = TestingUtil.extractComponent(cache, TransactionTable.class);
      assertFalse("Expected a remote transaction.", table.getRemoteTransactions().isEmpty());
   }
View Full Code Here

      tm(c1).begin();
      c1.put(k1, "v1");
      c1.put(k2, "v2");

      // We split the transaction commit in two phases by calling the TransactionCoordinator methods directly
      TransactionTable txTable = TestingUtil.extractComponent(c1, TransactionTable.class);
      TransactionCoordinator txCoordinator = TestingUtil.extractComponent(c1, TransactionCoordinator.class);

      // Execute the prepare on both nodes
      LocalTransaction localTx = txTable.getLocalTransaction(tm(c1).getTransaction());
      txCoordinator.prepare(localTx);

      final CountDownLatch commitLatch = new CountDownLatch(1);
      Thread worker = new Thread("RehasherSim,StaleLocksWithCommitDuringStateTransferTest") {
         @Override
View Full Code Here

TOP

Related Classes of org.infinispan.transaction.impl.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.