/** {@inheritDoc} */ @Override public float getAverageRemoveTime() { return cache.clusterMetrics().getAverageRemoveTime(); }
/** * @throws Exception If failed. */ @Test public void testRemoveAllAvgTime() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); cache.put(1, 1); cache.put(2, 2); cache.put(3, 3); assertEquals(0.0, cache.localMetrics().getAverageRemoveTime(), 0.0); Set<Integer> keys = new HashSet<>(4, 1); keys.add(1); keys.add(2); keys.add(3); cache.removeAll(keys); float averageRmvTime = cache.localMetrics().getAverageRemoveTime(); assert averageRmvTime >= 0; }
/** * @throws Exception If failed. */ @Test public void testRemoveAvgTime() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); for (int i = 0; i < KEY_CNT; i++) cache.put(i, i); assertEquals(0.0, cache.localMetrics().getAverageRemoveTime(), 0.0); for (int i = 0; i < KEY_CNT; i++) cache.remove(i); assert cache.localMetrics().getAverageRemoveTime() > 0; }
/** * @throws Exception If failed. */ @Test public void testGetAndRemoveAsyncAvgTime() throws Exception { IgniteCache<Object, Object> cache = grid(0).cache(DEFAULT_CACHE_NAME); for (int i = 0; i < KEY_CNT; i++) cache.put(i, i); assertEquals(0.0, cache.localMetrics().getAverageRemoveTime(), 0.0); for (int i = 0; i < KEY_CNT; i++) cache.getAndRemoveAsync(i).get(); assert cache.localMetrics().getAverageRemoveTime() > 0; }
/** * @throws Exception If failed. */ @Test public void testRemoveAllAsyncAvgTime() throws Exception { IgniteCache<Object, Object> cache = grid(0).cache(DEFAULT_CACHE_NAME); Set<Integer> keys = new LinkedHashSet<>(); for (int i = 0; i < 1000; i++) { if (affinity(cache).isPrimary(grid(0).localNode(), i)) { keys.add(i); cache.put(i, i); if(keys.size() == 3) break; } } assertEquals(0.0, cache.localMetrics().getAverageRemoveTime(), 0.0); IgniteFuture<?> fut = cache.removeAllAsync(keys); fut.get(); assert cache.localMetrics().getAverageRemoveTime() >= 0; }
/** * @throws Exception If failed. */ @Test public void testRemoveAsyncValAvgTime() throws Exception { IgniteCache<Object, Object> cache = grid(0).cache(DEFAULT_CACHE_NAME); Integer key = 0; for (int i = 0; i < 1000; i++) { if (affinity(cache).isPrimary(grid(0).localNode(), i)) { key = i; break; } } assertEquals(cache.localMetrics().getAverageRemoveTime(), 0.0, 0.0); cache.put(key, key); IgniteFuture<Boolean> fut = cache.removeAsync(key, key); assertTrue(fut.get()); assert cache.localMetrics().getAverageRemoveTime() >= 0; }
avgRemovalTime = m.getAverageRemoveTime(); removalsPerSec = perSecond(m.getAverageRemoveTime()); commitsPerSec = perSecond(m.getAverageTxCommitTime()); rollbacksPerSec = perSecond(m.getAverageTxRollbackTime());
/** * @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; }
rmvAvgTimeNanos += e.getAverageRemoveTime(); commitAvgTimeNanos += e.getAverageTxCommitTime(); rollbackAvgTimeNanos += e.getAverageTxRollbackTime();
rmvAvgTimeNanos += e.getAverageRemoveTime(); commitAvgTimeNanos += e.getAverageTxCommitTime(); rollbackAvgTimeNanos += e.getAverageTxRollbackTime();
assertEquals(m.getCacheMisses(), 0); assertEquals(m.getAverageGetTime(), 0f); assertEquals(m.getAverageRemoveTime(), 0f); assertEquals(m.getAveragePutTime(), 0f); assertEquals(m.getAverageTxCommitTime(), 0f);
/** {@inheritDoc} */ @Override public float getAverageRemoveTime() { return cache.clusterMetrics().getAverageRemoveTime(); }
writer.writeFloat(metrics.getAverageGetTime()); writer.writeFloat(metrics.getAveragePutTime()); writer.writeFloat(metrics.getAverageRemoveTime()); writer.writeFloat(metrics.getAverageTxCommitTime()); writer.writeFloat(metrics.getAverageTxRollbackTime());
avgRemovalTime = m.getAverageRemoveTime(); removalsPerSec = perSecond(m.getAverageRemoveTime()); commitsPerSec = perSecond(m.getAverageTxCommitTime()); rollbacksPerSec = perSecond(m.getAverageTxRollbackTime());
rmvAvgTimeNanos += e.getAverageRemoveTime(); commitAvgTimeNanos += e.getAverageTxCommitTime(); rollbackAvgTimeNanos += e.getAverageTxRollbackTime();
writer.writeFloat(metrics.getAverageGetTime()); writer.writeFloat(metrics.getAveragePutTime()); writer.writeFloat(metrics.getAverageRemoveTime()); writer.writeFloat(metrics.getAverageTxCommitTime()); writer.writeFloat(metrics.getAverageTxRollbackTime());