/** {@inheritDoc} */ @Override public float getAveragePutTime() { return cache.clusterMetrics().getAveragePutTime(); }
/** * @throws Exception If failed. */ @Test public void testPutAllAvgTime() throws Exception { IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); assertEquals(0.0, cache.localMetrics().getAveragePutTime(), 0.0); assertEquals(0, cache.localMetrics().getCachePuts()); Map<Integer, Integer> values = new HashMap<>(); values.put(1, 1); values.put(2, 2); values.put(3, 3); cache.putAll(values); float averagePutTime = cache.localMetrics().getAveragePutTime(); assert averagePutTime >= 0; assertEquals(values.size(), cache.localMetrics().getCachePuts()); }
/** * @throws Exception If failed. */ @Test public void testPutAsyncAvgTime() throws Exception { IgniteCache<Object, Object> cache = grid(0).cache(DEFAULT_CACHE_NAME); assertEquals(0.0, cache.localMetrics().getAveragePutTime(), 0.0); assertEquals(0, cache.localMetrics().getCachePuts()); cache.putAsync(1, 1).get(); TimeUnit.MILLISECONDS.sleep(100L); assert cache.localMetrics().getAveragePutTime() > 0; }
/** * @throws Exception If failed. */ @Test public void testPutIfAbsentAsyncAvgTime() throws Exception { IgniteCache<Object, Object> cache = grid(0).cache(DEFAULT_CACHE_NAME); Integer key = null; for (int i = 0; i < 1000; i++) { if (affinity(cache).isPrimary(grid(0).localNode(), i)) { key = i; break; } } assertEquals(0.0f, cache.localMetrics().getAveragePutTime()); cache.putIfAbsentAsync(key, key).get(); TimeUnit.MILLISECONDS.sleep(100L); assert cache.localMetrics().getAveragePutTime() > 0; }
/** * @throws Exception If failed. */ @Test public void testGetAndPutIfAbsentAsyncAvgTime() throws Exception { IgniteCache<Object, Object> cache = grid(0).cache(DEFAULT_CACHE_NAME); Integer key = null; for (int i = 0; i < 1000; i++) { if (affinity(cache).isPrimary(grid(0).localNode(), i)) { key = i; break; } } assertEquals(0.0f, cache.localMetrics().getAveragePutTime()); cache.getAndPutIfAbsentAsync(key, key).get(); TimeUnit.MILLISECONDS.sleep(100L); assert cache.localMetrics().getAveragePutTime() > 0; }
/** * @throws Exception If failed. */ @Test public void testPutAvgTime() throws Exception { final IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); assertEquals(0.0, cache.localMetrics().getAveragePutTime(), 0.0); assertEquals(0, cache.localMetrics().getCachePuts()); for (int i = 0; i < KEY_CNT; i++) cache.put(i, i); assert cache.localMetrics().getAveragePutTime() > 0; assertEquals(KEY_CNT, cache.localMetrics().getCachePuts()); }
/** * @throws Exception If failed. */ @Test public void testGetAndPutAsyncAvgTime() throws Exception { IgniteCache<Object, Object> cache = grid(0).cache(DEFAULT_CACHE_NAME); Integer key = null; for (int i = 0; i < 1000; i++) { if (affinity(cache).isPrimary(grid(0).localNode(), i)) { key = i; break; } } assertEquals(0.0, cache.localMetrics().getAveragePutTime(), 0.0); assertEquals(0.0, cache.localMetrics().getAverageGetTime(), 0.0); cache.getAndPutAsync(key, key).get(); TimeUnit.MILLISECONDS.sleep(100L); assert cache.localMetrics().getAveragePutTime() > 0; assert cache.localMetrics().getAverageGetTime() > 0; }
avgPutTime = m.getAveragePutTime(); avgRemovalTime = m.getAverageRemoveTime(); putsPerSec = perSecond(m.getAveragePutTime()); removalsPerSec = perSecond(m.getAverageRemoveTime()); commitsPerSec = perSecond(m.getAverageTxCommitTime());
/** * @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; }
entryProcessorMinInvocationTime = e.getEntryProcessorMinInvocationTime(); putAvgTimeNanos += e.getAveragePutTime(); getAvgTimeNanos += e.getAverageGetTime(); rmvAvgTimeNanos += e.getAverageRemoveTime();
entryProcessorMinInvocationTime = e.getEntryProcessorMinInvocationTime(); putAvgTimeNanos += e.getAveragePutTime(); getAvgTimeNanos += e.getAverageGetTime(); rmvAvgTimeNanos += e.getAverageRemoveTime();
assertEquals(m.getAverageGetTime(), 0f); assertEquals(m.getAverageRemoveTime(), 0f); assertEquals(m.getAveragePutTime(), 0f); assertEquals(m.getAverageTxCommitTime(), 0f); assertEquals(m.getAverageTxRollbackTime(), 0f);
/** {@inheritDoc} */ @Override public float getAveragePutTime() { return cache.clusterMetrics().getAveragePutTime(); }
writer.writeLong(metrics.getCacheEvictions()); writer.writeFloat(metrics.getAverageGetTime()); writer.writeFloat(metrics.getAveragePutTime()); writer.writeFloat(metrics.getAverageRemoveTime()); writer.writeFloat(metrics.getAverageTxCommitTime());
avgPutTime = m.getAveragePutTime(); avgRemovalTime = m.getAverageRemoveTime(); putsPerSec = perSecond(m.getAveragePutTime()); removalsPerSec = perSecond(m.getAverageRemoveTime()); commitsPerSec = perSecond(m.getAverageTxCommitTime());
entryProcessorMinInvocationTime = e.getEntryProcessorMinInvocationTime(); putAvgTimeNanos += e.getAveragePutTime(); getAvgTimeNanos += e.getAverageGetTime(); rmvAvgTimeNanos += e.getAverageRemoveTime();
writer.writeLong(metrics.getCacheEvictions()); writer.writeFloat(metrics.getAverageGetTime()); writer.writeFloat(metrics.getAveragePutTime()); writer.writeFloat(metrics.getAverageRemoveTime()); writer.writeFloat(metrics.getAverageTxCommitTime());