Package org.jboss.cache.interceptors

Examples of org.jboss.cache.interceptors.TxInterceptor$LocalSynchronizationHandler


      assertNotNull("Cache2 is null.", cache2);

      // Note: because these tests are normally executed without a server, the interceptor
      // MBeans are usually not available for use in the tests.  Consequently it's necessary
      // to obtain a reference to the interceptor and work with it directly.
      TxInterceptor tx1 = getTxInterceptor(cache1);
      assertNotNull("Cache1 InvalidationInterceptor not found.", tx1);
      TxInterceptor tx2 = getTxInterceptor(cache2);
      assertNotNull("Cache2 InvalidationInterceptor not found.", tx2);

      TransactionManager tm1 = cache1.getTransactionManager();
      assertNotNull("TransactionManager is null.", tm1);

      // populate cache1 with test data - no transaction
      loadCacheNoTx(cache1);

      // confirm that data is in cache1 and in cache2
      Fqn key = Fqn.fromString("Europe/Austria");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      key = Fqn.fromString("Europe/Albania");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));

      // verify basic statistics for entries loaded into cache
      assertEquals("Cache1 Tx Prepares error after reset: ", new Long(0), new Long(tx1.getPrepares()));
      assertEquals("Cache1 Tx Commits error after reset: ", new Long(0), new Long(tx1.getCommits()));
      assertEquals("Cache1 Tx Rollbacks error after reset: ", new Long(0), new Long(tx1.getRollbacks()));
      assertEquals("Cache2 Tx Prepares error after reset: ", new Long(0), new Long(tx2.getPrepares()));
      assertEquals("Cache2 Tx Commits error after reset: ", new Long(0), new Long(tx2.getCommits()));
      assertEquals("Cache2 Tx Rollbacks error after reset: ", new Long(0), new Long(tx2.getRollbacks()));

      // populate cache1 with test data - then transaction commit
      loadCacheTxCommit(cache1, tm1);
      loadCacheTxCommit2(cache1, tm1);

      // confirm that committed data is in cache1 and in cache2
      key = Fqn.fromString("Europe/England");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      key = Fqn.fromString("Europe/Hungary");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));

      // populate cache1 with test data - then transaction rollback
      loadCacheTxRollback(cache1, tm1);

      // confirm that rolled back data is not in cache1 or cache2
      key = Fqn.fromString("Europe/France");
      assertNull("Cache1 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNull("Cache2 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      key = Fqn.fromString("Europe/Germany");
      assertNull("Cache1 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNull("Cache2 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));

      // check the statistics - transactions are only handled by JBoss Cache on the remote node (i.e., node2)
      assertEquals("Cache1 Tx Prepares error after reset: ", new Long(0), new Long(tx1.getPrepares()));
      assertEquals("Cache1 Tx Commits error after reset: ", new Long(0), new Long(tx1.getCommits()));
      assertEquals("Cache1 Tx Rollbacks error after reset: ", new Long(0), new Long(tx1.getRollbacks()));
      assertEquals("Cache2 Tx Prepares error after reset: ", new Long(2), new Long(tx2.getPrepares()));
      assertEquals("Cache2 Tx Commits error after reset: ", new Long(2), new Long(tx2.getCommits()));
      // rollbacks don't currently get propagated so the counter will be 0, not 1
      assertEquals("Cache2 Tx Rollbacks error after reset: ", new Long(0), new Long(tx2.getRollbacks()));

      // reset statistics
      tx1.resetStatistics();
      tx2.resetStatistics();

      // check the statistics again
      assertEquals("Cache1 Tx Prepares error after reset: ", new Long(0), new Long(tx1.getPrepares()));
      assertEquals("Cache1 Tx Commits error after reset: ", new Long(0), new Long(tx1.getCommits()));
      assertEquals("Cache1 Tx Rollbacks error after reset: ", new Long(0), new Long(tx1.getRollbacks()));
      assertEquals("Cache2 Tx Prepares error after reset: ", new Long(0), new Long(tx2.getPrepares()));
      assertEquals("Cache2 Tx Commits error after reset: ", new Long(0), new Long(tx2.getCommits()));
      assertEquals("Cache2 Tx Rollbacks error after reset: ", new Long(0), new Long(tx2.getRollbacks()));
   }
View Full Code Here


      assertNotNull("Cache2 is null.", cache2);

      // Note: because these tests are normally executed without a server, the interceptor
      // MBeans are usually not available for use in the tests.  Consequently it's necessary
      // to obtain a reference to the interceptor and work with it directly.
      TxInterceptor tx1 = getTxInterceptor(cache1);
      assertNotNull("Cache1 InvalidationInterceptor not found.", tx1);
      TxInterceptor tx2 = getTxInterceptor(cache2);
      assertNotNull("Cache2 InvalidationInterceptor not found.", tx2);

      TransactionManager tm1 = cache1.getTransactionManager();
      assertNotNull("TransactionManager is null.", tm1);

      // populate cache1 with test data - no transaction
      loadCacheNoTx(cache1);

      // confirm that data is in cache1 and in cache2
      Fqn key = Fqn.fromString("Europe/Austria");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      key = Fqn.fromString("Europe/Albania");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));

      // verify basic statistics for entries loaded into cache
      assertEquals("Cache1 Tx Prepares error after reset: ", new Long(0), new Long(tx1.getPrepares()));
      assertEquals("Cache1 Tx Commits error after reset: ", new Long(0), new Long(tx1.getCommits()));
      assertEquals("Cache1 Tx Rollbacks error after reset: ", new Long(0), new Long(tx1.getRollbacks()));
      assertEquals("Cache2 Tx Prepares error after reset: ", new Long(0), new Long(tx2.getPrepares()));
      assertEquals("Cache2 Tx Commits error after reset: ", new Long(0), new Long(tx2.getCommits()));
      assertEquals("Cache2 Tx Rollbacks error after reset: ", new Long(0), new Long(tx2.getRollbacks()));

      // populate cache1 with test data - then transaction commit
      loadCacheTxCommit(cache1, tm1);
      loadCacheTxCommit2(cache1, tm1);

      // confirm that committed data is in cache1 and in cache2
      key = Fqn.fromString("Europe/England");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      key = Fqn.fromString("Europe/Hungary");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));

      // populate cache1 with test data - then transaction rollback
      loadCacheTxRollback(cache1, tm1);

      // confirm that rolled back data is not in cache1 or cache2
      key = Fqn.fromString("Europe/France");
      assertNull("Cache1 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNull("Cache2 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      key = Fqn.fromString("Europe/Germany");
      assertNull("Cache1 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNull("Cache2 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));

      // check the statistics - transactions are only handled by JBoss Cache on the remote node (i.e., node2)
      assertEquals("Cache1 Tx Prepares error after reset: ", new Long(0), new Long(tx1.getPrepares()));
      assertEquals("Cache1 Tx Commits error after reset: ", new Long(0), new Long(tx1.getCommits()));
      assertEquals("Cache1 Tx Rollbacks error after reset: ", new Long(0), new Long(tx1.getRollbacks()));
      assertEquals("Cache2 Tx Prepares error after reset: ", new Long(2), new Long(tx2.getPrepares()));
      assertEquals("Cache2 Tx Commits error after reset: ", new Long(2), new Long(tx2.getCommits()));
      // rollbacks don't currently get propagated so the counter will be 0, not 1
      assertEquals("Cache2 Tx Rollbacks error after reset: ", new Long(0), new Long(tx2.getRollbacks()));

      // reset statistics
      tx1.resetStatistics();
      tx2.resetStatistics();

      // check the statistics again
      assertEquals("Cache1 Tx Prepares error after reset: ", new Long(0), new Long(tx1.getPrepares()));
      assertEquals("Cache1 Tx Commits error after reset: ", new Long(0), new Long(tx1.getCommits()));
      assertEquals("Cache1 Tx Rollbacks error after reset: ", new Long(0), new Long(tx1.getRollbacks()));
      assertEquals("Cache2 Tx Prepares error after reset: ", new Long(0), new Long(tx2.getPrepares()));
      assertEquals("Cache2 Tx Commits error after reset: ", new Long(0), new Long(tx2.getCommits()));
      assertEquals("Cache2 Tx Rollbacks error after reset: ", new Long(0), new Long(tx2.getRollbacks()));
   }
View Full Code Here

      assertNotNull("Cache2 is null.", cache2);
     
      // Note: because these tests are normally executed without a server, the interceptor
      // MBeans are usually not available for use in the tests.  Consequently it's necessary
      // to obtain a reference to the interceptor and work with it directly.
      TxInterceptor tx1 = getTxInterceptor(cache1);
      assertNotNull("Cache1 InvalidationInterceptor not found.", tx1);
      TxInterceptor tx2 = getTxInterceptor(cache2);
      assertNotNull("Cache2 InvalidationInterceptor not found.", tx2)
     
      TransactionManager tm1 = cache1.getTransactionManager();
      assertNotNull("TransactionManager is null.", tm1);
     
      // populate cache1 with test data - no transaction
      loadCacheNoTx(cache1);
     
      // confirm that data is in cache1 and in cache2
      Fqn key = Fqn.fromString("Europe/Austria");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      key = Fqn.fromString("Europe/Albania");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
     
      // verify basic statistics for entries loaded into cache
      assertEquals("Cache1 Tx Prepares error after reset: ", new Long(0), new Long(tx1.getPrepares()));
      assertEquals("Cache1 Tx Commits error after reset: ", new Long(0), new Long(tx1.getCommits()));
      assertEquals("Cache1 Tx Rollbacks error after reset: ", new Long(0), new Long(tx1.getRollbacks()));
      assertEquals("Cache2 Tx Prepares error after reset: ", new Long(0), new Long(tx2.getPrepares()));
      assertEquals("Cache2 Tx Commits error after reset: ", new Long(0), new Long(tx2.getCommits()));
      assertEquals("Cache2 Tx Rollbacks error after reset: ", new Long(0), new Long(tx2.getRollbacks()));
     
      // populate cache1 with test data - then transaction commit
      loadCacheTxCommit(cache1, tm1);
      loadCacheTxCommit2(cache1, tm1);
     
      // confirm that committed data is in cache1 and in cache2
      key = Fqn.fromString("Europe/England");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      key = Fqn.fromString("Europe/Hungary");
      assertNotNull("Cache1 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNotNull("Cache2 retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      // populate cache1 with test data - then transaction rollback
      loadCacheTxRollback(cache1, tm1);
     
      // confirm that rolled back data is not in cache1 or cache2
      key = Fqn.fromString("Europe/France");
      assertNull("Cache1 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNull("Cache2 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
      key = Fqn.fromString("Europe/Germany");
      assertNull("Cache1 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache1.get(key, CAPITAL));
      assertNull("Cache2 retrieval error: did not expect to retrieve " + CAPITAL + " for " + key, cache2.get(key, CAPITAL));
     
      // check the statistics - transactions are only handled by JBoss Cache on the remote node (i.e., node2)
      assertEquals("Cache1 Tx Prepares error after reset: ", new Long(0), new Long(tx1.getPrepares()));
      assertEquals("Cache1 Tx Commits error after reset: ", new Long(0), new Long(tx1.getCommits()));
      assertEquals("Cache1 Tx Rollbacks error after reset: ", new Long(0), new Long(tx1.getRollbacks()));
      assertEquals("Cache2 Tx Prepares error after reset: ", new Long(2), new Long(tx2.getPrepares()));
      assertEquals("Cache2 Tx Commits error after reset: ", new Long(2), new Long(tx2.getCommits()));
      // rollbacks don't currently get propagated so the counter will be 0, not 1
      assertEquals("Cache2 Tx Rollbacks error after reset: ", new Long(0), new Long(tx2.getRollbacks()));
     
      // reset statistics
      tx1.resetStatistics();
      tx2.resetStatistics();
    
      // check the statistics again
      assertEquals("Cache1 Tx Prepares error after reset: ", new Long(0), new Long(tx1.getPrepares()));
      assertEquals("Cache1 Tx Commits error after reset: ", new Long(0), new Long(tx1.getCommits()));
      assertEquals("Cache1 Tx Rollbacks error after reset: ", new Long(0), new Long(tx1.getRollbacks()));
      assertEquals("Cache2 Tx Prepares error after reset: ", new Long(0), new Long(tx2.getPrepares()));
      assertEquals("Cache2 Tx Commits error after reset: ", new Long(0), new Long(tx2.getCommits()));
      assertEquals("Cache2 Tx Rollbacks error after reset: ", new Long(0), new Long(tx2.getRollbacks()));
   }
View Full Code Here

    public void testNoTransaction() throws Exception
    {

        TreeCache cache = createCache();

        Interceptor txInterceptor = new TxInterceptor();
        txInterceptor.setCache(cache);
        Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
        createInterceptor.setCache(cache);
        Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
        nodeInterceptor.setCache(cache);
        MockInterceptor dummy = new MockInterceptor();
        dummy.setCache(cache);

        txInterceptor.setNext(createInterceptor);
        createInterceptor.setNext(nodeInterceptor);
        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(txInterceptor);
        DummyTransactionManager mgr = DummyTransactionManager.getInstance();
View Full Code Here

    public void testLocalTransactionExists() throws Exception
    {

        TreeCache cache = createCache();
        Interceptor txInterceptor = new TxInterceptor();
        txInterceptor.setCache(cache);
        Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
        createInterceptor.setCache(cache);
        Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
        nodeInterceptor.setCache(cache);
        MockInterceptor dummy = new MockInterceptor();
        dummy.setCache(cache);

        txInterceptor.setNext(createInterceptor);
        createInterceptor.setNext(nodeInterceptor);
        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(txInterceptor);
View Full Code Here

    public void testRollbackTransaction() throws Exception
    {

        TreeCache cache = createCache();
        Interceptor txInterceptor = new TxInterceptor();
        txInterceptor.setCache(cache);
        Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
        createInterceptor.setCache(cache);
        Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
        nodeInterceptor.setCache(cache);
        MockInterceptor dummy = new MockInterceptor();
        dummy.setCache(cache);

        txInterceptor.setNext(createInterceptor);
        createInterceptor.setNext(nodeInterceptor);
        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(txInterceptor);
View Full Code Here

    }

    public void testEmptyLocalTransaction() throws Exception
    {
        TreeCache cache = createCache();
        Interceptor txInterceptor = new TxInterceptor();
        txInterceptor.setCache(cache);
        Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
        createInterceptor.setCache(cache);
        Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
        nodeInterceptor.setCache(cache);
        MockInterceptor dummy = new MockInterceptor();
        dummy.setCache(cache);

        txInterceptor.setNext(createInterceptor);
        createInterceptor.setNext(nodeInterceptor);
        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(txInterceptor);
View Full Code Here

    public void testEmptyRollbackLocalTransaction() throws Exception
    {

        TreeCache cache = createCache();
        Interceptor txInterceptor = new TxInterceptor();
        txInterceptor.setCache(cache);
        Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
        createInterceptor.setCache(cache);
        Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
        nodeInterceptor.setCache(cache);
        MockInterceptor dummy = new MockInterceptor();
        dummy.setCache(cache);

        txInterceptor.setNext(createInterceptor);
        createInterceptor.setNext(nodeInterceptor);
        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(txInterceptor);
View Full Code Here

    public void testLocalRollbackAftercommitTransaction() throws Exception
    {

        TreeCache cache = createCache();
        Interceptor txInterceptor = new TxInterceptor();
        txInterceptor.setCache(cache);
        Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
        createInterceptor.setCache(cache);
        Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
        nodeInterceptor.setCache(cache);
        MockInterceptor dummy = new MockInterceptor();
        dummy.setCache(cache);

        txInterceptor.setNext(createInterceptor);
        createInterceptor.setNext(nodeInterceptor);
        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(txInterceptor);
View Full Code Here


    public void testgtxTransactionExists() throws Exception
    {
        TreeCache cache = createCache();
        Interceptor txInterceptor = new TxInterceptor();
        txInterceptor.setCache(cache);
        Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
        createInterceptor.setCache(cache);
        Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
        nodeInterceptor.setCache(cache);
        MockInterceptor dummy = new MockInterceptor();
        dummy.setCache(cache);

        txInterceptor.setNext(createInterceptor);
        createInterceptor.setNext(nodeInterceptor);
        nodeInterceptor.setNext(dummy);

        cache.setInterceptorChain(txInterceptor);
View Full Code Here

TOP

Related Classes of org.jboss.cache.interceptors.TxInterceptor$LocalSynchronizationHandler

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.