Examples of TxInterceptor


Examples of org.infinispan.interceptors.TxInterceptor

        if (metric == null) {
            context.getFailureDescription().set(InfinispanLogger.ROOT_LOGGER.unknownMetric(name));
        } else {
            Cache<?, ?> cache = ServiceContainerHelper.findValue(context.getServiceRegistry(false), CacheService.getServiceName(containerName, cacheName));
            if (cache != null) {
                TxInterceptor interceptor = CacheMetric.findInterceptor(cache, TxInterceptor.class);
                context.getResult().set((interceptor != null) ? metric.getValue(interceptor) : new ModelNode(0));
            }
        }
        context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
    }
View Full Code Here

Examples of org.infinispan.interceptors.TxInterceptor

            super(0);
        }

        @Override
        protected ModelNode invokeCommand(Cache<?, ?> cache, ModelNode operation) throws Exception {
            TxInterceptor interceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache()
                    .getInterceptorChain(), TxInterceptor.class);
            if (interceptor != null) {
                interceptor.resetStatistics();
            }
            return null;
        }
View Full Code Here

Examples of org.infinispan.interceptors.TxInterceptor

                    break;
                case SUCCESS_RATIO:
                    result.set(((RpcManagerImpl) cache.getAdvancedCache().getRpcManager()).getSuccessRatioFloatingPoint());
                    break;
                case COMMITS: {
                    TxInterceptor txInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache()
                            .getInterceptorChain(), TxInterceptor.class);
                    result.set(txInterceptor != null ? txInterceptor.getCommits() : 0);
                    break;
                }
                case PREPARES: {
                    TxInterceptor txInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache()
                            .getInterceptorChain(), TxInterceptor.class);
                    result.set(txInterceptor != null ? txInterceptor.getPrepares() : 0);
                    break;
                }
                case ROLLBACKS: {
                    TxInterceptor txInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache()
                            .getInterceptorChain(), TxInterceptor.class);
                    result.set(txInterceptor != null ? txInterceptor.getRollbacks() : 0);
                    break;
                }
                case INVALIDATIONS: {
                    InvalidationInterceptor invInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache()
                            .getInterceptorChain(), InvalidationInterceptor.class);
View Full Code Here

Examples of org.infinispan.interceptors.TxInterceptor

                    break;
                case SUCCESS_RATIO:
                    result.set(rpcManager.getSuccessRatioFloatingPoint());
                    break;
                case COMMITS: {
                    TxInterceptor txInterceptor = getFirstInterceptorWhichExtends(interceptors, TxInterceptor.class);
                    result.set(txInterceptor != null ? txInterceptor.getCommits() : 0);
                    break;
                }
                case PREPARES: {
                    TxInterceptor txInterceptor = getFirstInterceptorWhichExtends(interceptors, TxInterceptor.class);
                    result.set(txInterceptor != null ? txInterceptor.getPrepares() : 0);
                    break;
                }
                case ROLLBACKS: {
                    TxInterceptor txInterceptor = getFirstInterceptorWhichExtends(interceptors, TxInterceptor.class);
                    result.set(txInterceptor != null ? txInterceptor.getRollbacks() : 0);
                    break;
                }
                case INVALIDATIONS: {
                    InvalidationInterceptor invInterceptor = getFirstInterceptorWhichExtends(interceptors, InvalidationInterceptor.class);
                    result.set(invInterceptor != null ? invInterceptor.getInvalidations() : 0);
View Full Code Here

Examples of org.jboss.cache.interceptors.TxInterceptor

      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

Examples of org.jboss.cache.interceptors.TxInterceptor

      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

Examples of org.jboss.cache.interceptors.TxInterceptor

      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

Examples of org.jboss.cache.interceptors.TxInterceptor

    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

Examples of org.jboss.cache.interceptors.TxInterceptor

    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

Examples of org.jboss.cache.interceptors.TxInterceptor

    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
TOP
Copyright © 2018 www.massapi.com. 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.