Examples of CacheMgmtInterceptor


Examples of org.infinispan.interceptors.CacheMgmtInterceptor

            super(0);
        }

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

Examples of org.infinispan.interceptors.CacheMgmtInterceptor

                    break;
                case NUMBER_OF_LOCKS_HELD:
                    result.set(((LockManagerImpl) cache.getAdvancedCache().getLockManager()).getNumberOfLocksHeld());
                    break;
                case AVERAGE_READ_TIME: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getAverageReadTime() : 0);
                    break;
                }
                case AVERAGE_WRITE_TIME: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getAverageWriteTime() : 0);
                    break;
                }
                case ELAPSED_TIME: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getElapsedTime() : 0);
                    break;
                }
                case EVICTIONS: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getEvictions() : 0);
                    break;
                }
                case HIT_RATIO: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getHitRatio() : 0);
                    break;
                }
                case HITS: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getHits() : 0);
                    break;
                }
                case MISSES: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getMisses() : 0);
                    break;
                }
                case NUMBER_OF_ENTRIES: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getNumberOfEntries() : 0);
                    break;
                }
                case READ_WRITE_RATIO: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getReadWriteRatio() : 0);
                    break;
                }
                case REMOVE_HITS: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getRemoveHits() : 0);
                    break;
                }
                case REMOVE_MISSES: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getRemoveMisses() : 0);
                    break;
                }
                case STORES: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getStores() : 0);
                    break;
                }
                case TIME_SINCE_RESET: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(cache.getAdvancedCache().getInterceptorChain(), CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getTimeSinceReset() : 0);
                    break;
                }
                case AVERAGE_REPLICATION_TIME: {
                    result.set(((RpcManagerImpl) cache.getAdvancedCache().getRpcManager()).getAverageReplicationTime());
                    break;
View Full Code Here

Examples of org.infinispan.interceptors.CacheMgmtInterceptor

   final long evictions;
  
   public StatsImpl(InterceptorChain chain) {
      List<CommandInterceptor> interceptors = chain.getInterceptorsWhichExtend(CacheMgmtInterceptor.class);
      if (!interceptors.isEmpty()) {
         CacheMgmtInterceptor mgmtInterceptor = (CacheMgmtInterceptor) interceptors.get(0);
         timeSinceStart = mgmtInterceptor.getElapsedTime();
         currentNumberOfEntries = mgmtInterceptor.getNumberOfEntries();
         totalNumberOfEntries = mgmtInterceptor.getStores();
         retrievals = mgmtInterceptor.getHits() + mgmtInterceptor.getMisses();
         stores = mgmtInterceptor.getStores();
         hits = mgmtInterceptor.getHits();
         misses = mgmtInterceptor.getMisses();
         removeHits = mgmtInterceptor.getRemoveHits();
         removeMisses = mgmtInterceptor.getRemoveMisses();
         evictions = mgmtInterceptor.getEvictions();
      } else {
         timeSinceStart = -1;
         currentNumberOfEntries = -1;
         totalNumberOfEntries = -1;
         retrievals = -1;
View Full Code Here

Examples of org.infinispan.interceptors.CacheMgmtInterceptor

                    break;
                case NUMBER_OF_LOCKS_HELD:
                    result.set(lockManager.getNumberOfLocksHeld());
                    break;
                case AVERAGE_READ_TIME: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getAverageReadTime() : 0);
                    break;
                }
                case AVERAGE_WRITE_TIME: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getAverageWriteTime() : 0);
                    break;
                }
                case AVERAGE_REMOVE_TIME: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getAverageRemoveTime() : 0);
                    break;
                }
                case ELAPSED_TIME: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getElapsedTime() : 0);
                    break;
                }
                case EVICTIONS: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getEvictions() : 0);
                    break;
                }
                case HIT_RATIO: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getHitRatio() : 0);
                    break;
                }
                case HITS: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getHits() : 0);
                    break;
                }
                case MISSES: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getMisses() : 0);
                    break;
                }
                case NUMBER_OF_ENTRIES: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getNumberOfEntries() : 0);
                    break;
                }
                case READ_WRITE_RATIO: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getReadWriteRatio() : 0);
                    break;
                }
                case REMOVE_HITS: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getRemoveHits() : 0);
                    break;
                }
                case REMOVE_MISSES: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getRemoveMisses() : 0);
                    break;
                }
                case STORES: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getStores() : 0);
                    break;
                }
                case TIME_SINCE_RESET: {
                    CacheMgmtInterceptor cacheMgmtInterceptor = getFirstInterceptorWhichExtends(interceptors, CacheMgmtInterceptor.class);
                    result.set(cacheMgmtInterceptor != null ? cacheMgmtInterceptor.getTimeSinceReset() : 0);
                    break;
                }
                case AVERAGE_REPLICATION_TIME: {
                    result.set(rpcManager.getAverageReplicationTime());
                    break;
View Full Code Here

Examples of org.infinispan.interceptors.CacheMgmtInterceptor

   final long evictions;
  
   public StatsImpl(InterceptorChain chain) {
      List<CommandInterceptor> interceptors = chain.getInterceptorsWhichExtend(CacheMgmtInterceptor.class);
      if (!interceptors.isEmpty()) {
         CacheMgmtInterceptor mgmtInterceptor = (CacheMgmtInterceptor) interceptors.get(0);
         timeSinceStart = mgmtInterceptor.getElapsedTime();
         currentNumberOfEntries = mgmtInterceptor.getNumberOfEntries();
         totalNumberOfEntries = mgmtInterceptor.getStores();
         retrievals = mgmtInterceptor.getHits() + mgmtInterceptor.getMisses();
         stores = mgmtInterceptor.getStores();
         hits = mgmtInterceptor.getHits();
         misses = mgmtInterceptor.getMisses();
         removeHits = mgmtInterceptor.getRemoveHits();
         removeMisses = mgmtInterceptor.getRemoveMisses();
         evictions = mgmtInterceptor.getEvictions();
      } else {
         timeSinceStart = -1;
         currentNumberOfEntries = -1;
         totalNumberOfEntries = -1;
         retrievals = -1;
View Full Code Here

Examples of org.infinispan.interceptors.CacheMgmtInterceptor

   final long evictions;
  
   public StatsImpl(InterceptorChain chain) {
      List<CommandInterceptor> interceptors = chain.getInterceptorsWhichExtend(CacheMgmtInterceptor.class);
      if (!interceptors.isEmpty()) {
         CacheMgmtInterceptor mgmtInterceptor = (CacheMgmtInterceptor) interceptors.get(0);
         timeSinceStart = mgmtInterceptor.getElapsedTime();
         currentNumberOfEntries = mgmtInterceptor.getNumberOfEntries();
         totalNumberOfEntries = mgmtInterceptor.getStores();
         retrievals = mgmtInterceptor.getHits() + mgmtInterceptor.getMisses();
         stores = mgmtInterceptor.getStores();
         hits = mgmtInterceptor.getHits();
         misses = mgmtInterceptor.getMisses();
         removeHits = mgmtInterceptor.getRemoveHits();
         removeMisses = mgmtInterceptor.getRemoveMisses();
         evictions = mgmtInterceptor.getEvictions();
      } else {
         timeSinceStart = -1;
         currentNumberOfEntries = -1;
         totalNumberOfEntries = -1;
         retrievals = -1;
View Full Code Here

Examples of org.jboss.cache.interceptors.CacheMgmtInterceptor

      loadCacheData();

      // 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.
      CacheMgmtInterceptor mgmt = getCacheMgmtInterceptor();
      assertNotNull("CacheMgmtInterceptor not found.", mgmt);

      // try some successful retrievals - fail if they miss since this shouldn't occur
      Fqn key = Fqn.fromString("Europe/Austria");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/England");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/France");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Germany");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Italy");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Switzerland");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));

      // try some unsuccessful retrievals - fail if they hit since this shouldn't occur
      key = Fqn.fromString("Europe/Austria");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/England");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/France");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Germany");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Italy");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Switzerland");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));

      // verify basic statistics for entries loaded into cache
      assertEquals("NumberOfNodes count error: ", new Integer(13), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error: ", new Integer(40), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error: ", new Long(40), new Long(mgmt.getStores()));
      assertEquals("Evictions count error: ", new Long(0), new Long(mgmt.getEvictions()));
      assertEquals("Hits count error: ", new Long(18), new Long(mgmt.getHits()));
      assertEquals("Misses count error: ", new Long(6), new Long(mgmt.getMisses()));
      assertEquals("HitMissRatio error: ", 0.75, mgmt.getHitMissRatio());
      assertEquals("ReadWriteRatio error: ", 0.60, mgmt.getReadWriteRatio());

      // now evict some nodes (each node has 3 attributes)
      cache.evict(Fqn.fromString("Europe/Czech Republic"));
      cache.evict(Fqn.fromString("Europe/Poland"));
      assertEquals("NumberOfNodes count error after evictions: ", new Integer(11), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error after evictions: ", new Integer(34), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error: ", new Long(40), new Long(mgmt.getStores()));
      assertEquals("Evictions count error: ", new Long(2), new Long(mgmt.getEvictions()));

      // time is measured in seconds so add a delay to ensure it's not rounded to zero
      Thread.sleep(1000);
      long t1 = mgmt.getElapsedTime();
      if (t1 < 1)
      {
         fail("ElapsedTime should be greater than 0 seconds.");
      }
      t1 = mgmt.getTimeSinceReset();
      if (t1 < 1)
      {
         fail("TimeSinceReset should be greater than 0 seconds.");
      }
      Thread.sleep(1000);

      // now reset the statistics (node count and attribute count aren't affected)
      mgmt.resetStatistics();

      // check times again
      t1 = mgmt.getElapsedTime();
      if (t1 < 2)
      {
         fail("ElapsedTime after reset should be greater than 1 second.");
      }
      t1 = mgmt.getTimeSinceReset();
      if (t1 > 1)// assumes that reset takes less than 2 seconds
      {
         fail("TimeSinceReset after reset should be less than 2 seconds.");
      }

      // check other statistics
      assertEquals("NumberOfNodes count error after reset: ", new Integer(11), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error after reset: ", new Integer(34), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error after reset: ", new Long(0), new Long(mgmt.getStores()));
      assertEquals("Evictions count error after reset: ", new Long(0), new Long(mgmt.getEvictions()));
      assertEquals("Hits count error after reset: ", new Long(0), new Long(mgmt.getHits()));
      assertEquals("Misses count error after reset: ", new Long(0), new Long(mgmt.getMisses()));
   }
View Full Code Here

Examples of org.jboss.cache.interceptors.CacheMgmtInterceptor

      loadCacheData();

      // 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.
      CacheMgmtInterceptor mgmt = getCacheMgmtInterceptor();
      assertNotNull("CacheMgmtInterceptor not found.", mgmt);

      // try some successful retrievals - fail if they miss since this shouldn't occur
      Fqn key = Fqn.fromString("Europe/Austria");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/England");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/France");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Germany");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Italy");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Switzerland");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));

      // try some unsuccessful retrievals - fail if they hit since this shouldn't occur
      key = Fqn.fromString("Europe/Austria");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/England");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/France");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Germany");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Italy");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Switzerland");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));

      // verify basic statistics for entries loaded into cache
      assertEquals("NumberOfNodes count error: ", new Integer(13), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error: ", new Integer(40), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error: ", new Long(40), new Long(mgmt.getStores()));
      assertEquals("Evictions count error: ", new Long(0), new Long(mgmt.getEvictions()));
      assertEquals("Hits count error: ", new Long(18), new Long(mgmt.getHits()));
      assertEquals("Misses count error: ", new Long(6), new Long(mgmt.getMisses()));
      assertEquals("HitMissRatio error: ", 0.75, mgmt.getHitMissRatio());
      assertEquals("ReadWriteRatio error: ", 0.60, mgmt.getReadWriteRatio());

      // now evict some nodes (each node has 3 attributes)
      cache.evict(Fqn.fromString("Europe/Czech Republic"));
      cache.evict(Fqn.fromString("Europe/Poland"));
      assertEquals("NumberOfNodes count error after evictions: ", new Integer(11), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error after evictions: ", new Integer(34), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error: ", new Long(40), new Long(mgmt.getStores()));
      assertEquals("Evictions count error: ", new Long(2), new Long(mgmt.getEvictions()));

      // time is measured in seconds so add a delay to ensure it's not rounded to zero
      Thread.sleep(1000);
      long t1 = mgmt.getElapsedTime();
      if (t1 < 1)
      {
         fail("ElapsedTime should be greater than 0 seconds.");
      }
      t1 = mgmt.getTimeSinceReset();
      if (t1 < 1)
      {
         fail("TimeSinceReset should be greater than 0 seconds.");
      }
      Thread.sleep(1000);

      // now reset the statistics (node count and attribute count aren't affected)
      mgmt.resetStatistics();

      // check times again
      t1 = mgmt.getElapsedTime();
      if (t1 < 2)
      {
         fail("ElapsedTime after reset should be greater than 1 second.");
      }
      t1 = mgmt.getTimeSinceReset();
      if (t1 > 1)// assumes that reset takes less than 2 seconds
      {
         fail("TimeSinceReset after reset should be less than 2 seconds.");
      }

      // check other statistics
      assertEquals("NumberOfNodes count error after reset: ", new Integer(11), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error after reset: ", new Integer(34), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error after reset: ", new Long(0), new Long(mgmt.getStores()));
      assertEquals("Evictions count error after reset: ", new Long(0), new Long(mgmt.getEvictions()));
      assertEquals("Hits count error after reset: ", new Long(0), new Long(mgmt.getHits()));
      assertEquals("Misses count error after reset: ", new Long(0), new Long(mgmt.getMisses()));
   }
View Full Code Here

Examples of org.jboss.cache.interceptors.CacheMgmtInterceptor

      loadCacheData();

      // 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.
      CacheMgmtInterceptor mgmt = getCacheMgmtInterceptor();
      assertNotNull("CacheMgmtInterceptor not found.", mgmt);
     
      // try some successful retrievals - fail if they miss since this shouldn't occur
      Fqn key = Fqn.fromString("Europe/Austria");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/England");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/France");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Germany");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Italy");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Switzerland");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
     
      // try some unsuccessful retrievals - fail if they hit since this shouldn't occur
      key = Fqn.fromString("Europe/Austria");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/England");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/France");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Germany");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Italy");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Switzerland");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
     
      // verify basic statistics for entries loaded into cache
      assertEquals("NumberOfNodes count error: ", new Integer(13), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error: ", new Integer(40), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error: ", new Long(40), new Long(mgmt.getStores()));
      assertEquals("Evictions count error: ", new Long(0), new Long(mgmt.getEvictions()));
      assertEquals("Hits count error: ", new Long(18), new Long(mgmt.getHits()));
      assertEquals("Misses count error: ", new Long(6), new Long(mgmt.getMisses()));
      assertEquals("HitMissRatio error: ", new Double(0.75), new Double(mgmt.getHitMissRatio()));
      assertEquals("ReadWriteRatio error: ", new Double(0.60), new Double(mgmt.getReadWriteRatio()));
     
      // now evict some nodes (each node has 3 attributes)
      cache.evict(Fqn.fromString("Europe/Czech Republic"));
      cache.evict(Fqn.fromString("Europe/Poland"));
      assertEquals("NumberOfNodes count error after evictions: ", new Integer(11), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error after evictions: ", new Integer(34), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error: ", new Long(40), new Long(mgmt.getStores()));
      assertEquals("Evictions count error: ", new Long(2), new Long(mgmt.getEvictions()));
     
      // time is measured in seconds so add a delay to ensure it's not rounded to zero
      Thread.sleep(1000);
      long t1 = mgmt.getElapsedTime();
      if (t1 < 1)
         fail("ElapsedTime should be greater than 0 seconds.");     
      t1 = mgmt.getTimeSinceReset();
      if (t1 < 1)
         fail("TimeSinceReset should be greater than 0 seconds.");
      Thread.sleep(1000);
    
      // now reset the statistics (node count and attribute count aren't affected)
      mgmt.resetStatistics();
     
      // check times again
      t1 = mgmt.getElapsedTime();
      if (t1 < 2)
         fail("ElapsedTime after reset should be greater than 1 second.");     
      t1 = mgmt.getTimeSinceReset();
      if (t1 > 1// assumes that reset takes less than 2 seconds
         fail("TimeSinceReset after reset should be less than 2 seconds.");
     
      // check other statistics
      assertEquals("NumberOfNodes count error after reset: ", new Integer(11), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error after reset: ", new Integer(34), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error after reset: ", new Long(0), new Long(mgmt.getStores()));
      assertEquals("Evictions count error after reset: ", new Long(0), new Long(mgmt.getEvictions()));
      assertEquals("Hits count error after reset: ", new Long(0), new Long(mgmt.getHits()));
      assertEquals("Misses count error after reset: ", new Long(0), new Long(mgmt.getMisses()));
   }
View Full Code Here

Examples of org.jboss.cache.interceptors.CacheMgmtInterceptor

      loadCacheData();

      // 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.
      CacheMgmtInterceptor mgmt = getCacheMgmtInterceptor();
      assertNotNull("CacheMgmtInterceptor not found.", mgmt);

      // try some successful retrievals - fail if they miss since this shouldn't occur
      Fqn key = Fqn.fromString("Europe/Austria");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/England");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/France");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Germany");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Italy");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));
      key = Fqn.fromString("Europe/Switzerland");
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + key, cache.get(key, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + key, cache.get(key, CURRENCY));
      assertNotNull("Retrieval error: expected to retrieve " + POPULATION + " for " + key, cache.get(key, POPULATION));

      // try some unsuccessful retrievals - fail if they hit since this shouldn't occur
      key = Fqn.fromString("Europe/Austria");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/England");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/France");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Germany");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Italy");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));
      key = Fqn.fromString("Europe/Switzerland");
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + key, cache.get(key, AREA));

      // verify basic statistics for entries loaded into cache
      assertEquals("NumberOfNodes count error: ", new Integer(13), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error: ", new Integer(40), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error: ", new Long(40), new Long(mgmt.getStores()));
      assertEquals("Evictions count error: ", new Long(0), new Long(mgmt.getEvictions()));
      assertEquals("Hits count error: ", new Long(18), new Long(mgmt.getHits()));
      assertEquals("Misses count error: ", new Long(6), new Long(mgmt.getMisses()));
      assertEquals("HitMissRatio error: ", 0.75, mgmt.getHitMissRatio());
      assertEquals("ReadWriteRatio error: ", 0.60, mgmt.getReadWriteRatio());

      // now evict some nodes (each node has 3 attributes)
      cache.evict(Fqn.fromString("Europe/Czech Republic"));
      cache.evict(Fqn.fromString("Europe/Poland"));
      assertEquals("NumberOfNodes count error after evictions: ", new Integer(11), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error after evictions: ", new Integer(34), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error: ", new Long(40), new Long(mgmt.getStores()));
      assertEquals("Evictions count error: ", new Long(2), new Long(mgmt.getEvictions()));

      // time is measured in seconds so add a delay to ensure it's not rounded to zero
      Thread.sleep(1000);
      long t1 = mgmt.getElapsedTime();
      if (t1 < 1)
      {
         fail("ElapsedTime should be greater than 0 seconds.");
      }
      t1 = mgmt.getTimeSinceReset();
      if (t1 < 1)
      {
         fail("TimeSinceReset should be greater than 0 seconds.");
      }
      Thread.sleep(1000);

      // now reset the statistics (node count and attribute count aren't affected)
      mgmt.resetStatistics();

      // check times again
      t1 = mgmt.getElapsedTime();
      if (t1 < 2)
      {
         fail("ElapsedTime after reset should be greater than 1 second.");
      }
      t1 = mgmt.getTimeSinceReset();
      if (t1 > 1)// assumes that reset takes less than 2 seconds
      {
         fail("TimeSinceReset after reset should be less than 2 seconds.");
      }

      // check other statistics
      assertEquals("NumberOfNodes count error after reset: ", new Integer(11), new Integer(mgmt.getNumberOfNodes()));
      assertEquals("NumberOfAttributes count error after reset: ", new Integer(34), new Integer(mgmt.getNumberOfAttributes()));
      assertEquals("Stores count error after reset: ", new Long(0), new Long(mgmt.getStores()));
      assertEquals("Evictions count error after reset: ", new Long(0), new Long(mgmt.getEvictions()));
      assertEquals("Hits count error after reset: ", new Long(0), new Long(mgmt.getHits()));
      assertEquals("Misses count error after reset: ", new Long(0), new Long(mgmt.getMisses()));
   }
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.