/** {@inheritDoc} */ @Override public long getCacheRemovals() { return cache.clusterMetrics().getCacheRemovals(); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> applyx(IgniteInternalCache<Object, Object> c, GridKernalContext ctx) { CacheMetrics metrics = c.cache().localMetrics(); assert metrics != null; return new GridFinishedFuture<Object>(new GridCacheRestMetrics( (int)metrics.getCacheGets(), (int)(metrics.getCacheRemovals() + metrics.getCachePuts()), (int)metrics.getCacheHits(), (int)metrics.getCacheMisses()) ); } }
/** * @throws Exception If failed. */ @Test public void testRemoves() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); cache.put(1, 1); // +1 remove cache.remove(1); assertEquals(1L, cache.localMetrics().getCacheRemovals()); }
/** * @throws Exception If failed. */ @Test public void testCacheStatistics() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); cache.put(1, 10); assertEquals(0, cache.localMetrics().getCacheRemovals()); assertEquals(1, cache.localMetrics().getCachePuts()); cache.remove(1); assertEquals(0, cache.localMetrics().getCacheHits()); assertEquals(1, cache.localMetrics().getCacheRemovals()); assertEquals(1, cache.localMetrics().getCachePuts()); cache.remove(1); assertEquals(0, cache.localMetrics().getCacheHits()); assertEquals(0, cache.localMetrics().getCacheMisses()); assertEquals(1, cache.localMetrics().getCacheRemovals()); assertEquals(1, cache.localMetrics().getCachePuts()); cache.put(1, 10); assertTrue(cache.remove(1, 10)); assertEquals(1, cache.localMetrics().getCacheHits()); assertEquals(0, cache.localMetrics().getCacheMisses()); assertEquals(2, cache.localMetrics().getCacheRemovals()); assertEquals(2, cache.localMetrics().getCachePuts()); assertFalse(cache.remove(1, 10)); assertEquals(1, cache.localMetrics().getCacheHits()); assertEquals(1, cache.localMetrics().getCacheMisses()); assertEquals(2, cache.localMetrics().getCacheRemovals()); assertEquals(2, cache.localMetrics().getCachePuts()); }
/** * @throws Exception If failed. */ @Test public void testCacheStatistics() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); cache.put(1, 10); assertEquals(0, cache.localMetrics().getCacheRemovals()); assertEquals(1, cache.localMetrics().getCachePuts()); cache.remove(1); assertEquals(0, cache.localMetrics().getCacheHits()); assertEquals(1, cache.localMetrics().getCacheRemovals()); assertEquals(1, cache.localMetrics().getCachePuts()); cache.remove(1); assertEquals(0, cache.localMetrics().getCacheHits()); assertEquals(0, cache.localMetrics().getCacheMisses()); assertEquals(1, cache.localMetrics().getCacheRemovals()); assertEquals(1, cache.localMetrics().getCachePuts()); cache.put(1, 10); assertTrue(cache.remove(1, 10)); assertEquals(1, cache.localMetrics().getCacheHits()); assertEquals(0, cache.localMetrics().getCacheMisses()); assertEquals(2, cache.localMetrics().getCacheRemovals()); assertEquals(2, cache.localMetrics().getCachePuts()); assertFalse(cache.remove(1, 10)); assertEquals(1, cache.localMetrics().getCacheHits()); assertEquals(1, cache.localMetrics().getCacheMisses()); assertEquals(2, cache.localMetrics().getCacheRemovals()); assertEquals(2, cache.localMetrics().getCachePuts()); }
writes = m.getCachePuts() + m.getCacheRemovals(); hits = m.getCacheHits(); misses = m.getCacheMisses(); removals = m.getCacheRemovals(); evictions = m.getCacheEvictions();
assertEquals(1, cache0.localMetrics().getCacheRemovals()); assertEquals(1, cache0.localMetrics().getCacheGets());
CacheMetrics m = grid(i).cache(DEFAULT_CACHE_NAME).localMetrics(); removes += m.getCacheRemovals(); reads += m.getCacheGets(); hits += m.getCacheHits();
/** * @throws Exception If failed. */ @Test public void testEntryProcessorRemove() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); cache.put(1, 20); int result = cache.invoke(1, new EntryProcessor<Integer, Integer, Integer>() { @Override public Integer process(MutableEntry<Integer, Integer> entry, Object... arguments) throws EntryProcessorException { Integer result = entry.getValue(); entry.remove(); return result; } }); assertEquals(1L, cache.localMetrics().getCachePuts()); assertEquals(20, result); assertEquals(1L, cache.localMetrics().getCacheHits()); assertEquals(100.0f, cache.localMetrics().getCacheHitPercentage()); assertEquals(0L, cache.localMetrics().getCacheMisses()); assertEquals(0f, cache.localMetrics().getCacheMissPercentage()); assertEquals(1L, cache.localMetrics().getCachePuts()); assertEquals(1L, cache.localMetrics().getCacheRemovals()); assertEquals(0L, cache.localMetrics().getCacheEvictions()); assert cache.localMetrics().getAveragePutTime() >= 0; assert cache.localMetrics().getAverageGetTime() >= 0; assert cache.localMetrics().getAverageRemoveTime() >= 0; }
/** * @throws Exception If failed. */ @Test public void testEntryProcessorRemove() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); cache.put(1, 20); int result = cache.invoke(1, new EntryProcessor<Integer, Integer, Integer>() { @Override public Integer process(MutableEntry<Integer, Integer> entry, Object... arguments) throws EntryProcessorException { Integer result = entry.getValue(); entry.remove(); return result; } }); assertEquals(1L, cache.localMetrics().getCachePuts()); assertEquals(20, result); assertEquals(1L, cache.localMetrics().getCacheHits()); assertEquals(100.0f, cache.localMetrics().getCacheHitPercentage()); assertEquals(0L, cache.localMetrics().getCacheMisses()); assertEquals(0f, cache.localMetrics().getCacheMissPercentage()); assertEquals(1L, cache.localMetrics().getCachePuts()); assertEquals(1L, cache.localMetrics().getCacheRemovals()); assertEquals(0L, cache.localMetrics().getCacheEvictions()); assert cache.localMetrics().getAveragePutTime() >= 0; assert cache.localMetrics().getAverageGetTime() >= 0; assert cache.localMetrics().getAverageRemoveTime() >= 0; }
txRollbacks += e.getCacheTxRollbacks(); evicts += e.getCacheEvictions(); removes += e.getCacheRemovals();
txRollbacks += e.getCacheTxRollbacks(); evicts += e.getCacheEvictions(); removes += e.getCacheRemovals();
assertEquals(m.getCacheRemovals(), 0); assertEquals(m.getCacheHits(), 0); assertEquals(m.getCacheMisses(), 0);
/** {@inheritDoc} */ @Override public long getCacheRemovals() { return cache.clusterMetrics().getCacheRemovals(); }
writer.writeLong(metrics.getCacheGets()); writer.writeLong(metrics.getCachePuts()); writer.writeLong(metrics.getCacheRemovals()); writer.writeLong(metrics.getCacheEvictions()); writer.writeFloat(metrics.getAverageGetTime());
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> applyx(IgniteInternalCache<Object, Object> c, GridKernalContext ctx) { CacheMetrics metrics = c.cache().localMetrics(); assert metrics != null; return new GridFinishedFuture<Object>(new GridCacheRestMetrics( (int)metrics.getCacheGets(), (int)(metrics.getCacheRemovals() + metrics.getCachePuts()), (int)metrics.getCacheHits(), (int)metrics.getCacheMisses()) ); } }
writes = m.getCachePuts() + m.getCacheRemovals(); hits = m.getCacheHits(); misses = m.getCacheMisses(); removals = m.getCacheRemovals(); evictions = m.getCacheEvictions();
txRollbacks += e.getCacheTxRollbacks(); evicts += e.getCacheEvictions(); removes += e.getCacheRemovals();
writer.writeLong(metrics.getCacheGets()); writer.writeLong(metrics.getCachePuts()); writer.writeLong(metrics.getCacheRemovals()); writer.writeLong(metrics.getCacheEvictions()); writer.writeFloat(metrics.getAverageGetTime());