@Override public void close() throws IOException { try { while (store.getStats().get(1).getElementCount() > 0) { Thread.sleep(100); } } catch (InterruptedException e) { throw new IOException(e); } finally { try { store.close(); } catch (DataStoreException e) { throw new IOException(e); } } } };
@Override public void close() throws IOException { try { while (store.getStats().get(1).getElementCount() > 0) { Thread.sleep(100); } } catch (InterruptedException e) { throw new IOException(e); } finally { try { store.close(); } catch (DataStoreException e) { throw new IOException(e); } } } };
CompositeDataSupport toCompositeData() { Object[] values = new Object[]{ stats.getName(), stats.getRequestCount(), stats.getHitCount(), new BigDecimal(stats.getHitRate(),new MathContext(2)), stats.getMissCount(), new BigDecimal(stats.getMissRate(), new MathContext(2)), stats.getLoadCount(), stats.getLoadSuccessCount(), stats.getLoadExceptionCount(), timeInWords(stats.getTotalLoadTime()), TimeUnit.NANOSECONDS.toMillis((long) stats.getAverageLoadPenalty()) + "ms", stats.getEvictionCount(), stats.getElementCount(), humanReadableByteCount(stats.estimateCurrentWeight()), humanReadableByteCount(stats.estimateCurrentMemoryWeight()), humanReadableByteCount(stats.getMaxTotalWeight()), }; try { return new CompositeDataSupport(TYPE, FIELD_NAMES, values); } catch (OpenDataException e) { throw new IllegalStateException(e); } } }
CompositeDataSupport toCompositeData() { Object[] values = new Object[]{ stats.getName(), stats.getRequestCount(), stats.getHitCount(), new BigDecimal(stats.getHitRate(),new MathContext(2)), stats.getMissCount(), new BigDecimal(stats.getMissRate(), new MathContext(2)), stats.getLoadCount(), stats.getLoadSuccessCount(), stats.getLoadExceptionCount(), timeInWords(stats.getTotalLoadTime()), TimeUnit.NANOSECONDS.toMillis((long) stats.getAverageLoadPenalty()) + "ms", stats.getEvictionCount(), stats.getElementCount(), humanReadableByteCount(stats.estimateCurrentWeight()), humanReadableByteCount(stats.estimateCurrentMemoryWeight()), humanReadableByteCount(stats.getMaxTotalWeight()), }; try { return new CompositeDataSupport(TYPE, FIELD_NAMES, values); } catch (OpenDataException e) { throw new IllegalStateException(e); } } }
CompositeDataSupport toCompositeData() { Object[] values = new Object[]{ stats.getName(), stats.getRequestCount(), stats.getHitCount(), new BigDecimal(stats.getHitRate(),new MathContext(2)), stats.getMissCount(), new BigDecimal(stats.getMissRate(), new MathContext(2)), stats.getLoadCount(), stats.getLoadSuccessCount(), stats.getLoadExceptionCount(), timeInWords(stats.getTotalLoadTime()), TimeUnit.NANOSECONDS.toMillis((long) stats.getAverageLoadPenalty()) + "ms", stats.getEvictionCount(), stats.getElementCount(), humanReadableByteCount(stats.estimateCurrentWeight()), humanReadableByteCount(stats.estimateCurrentMemoryWeight()), humanReadableByteCount(stats.getMaxTotalWeight()), }; try { return new CompositeDataSupport(TYPE, FIELD_NAMES, values); } catch (OpenDataException e) { throw new IllegalStateException(e); } } }
/** * evict implicitly. * @throws Exception */ @Test public void evictImplicit() throws Exception { LOG.info("Started evictImplicit"); for (int i = 0; i < 15; i++) { File f = createFile(i, loader, cache, folder); assertCache(i, cache, f); } File f = createFile(30, loader, cache, folder); assertCache(30, cache, f); // One of the entries should have been evicted assertTrue(cache.getStats().getElementCount() == 15); assertCacheStats(cache, 15, 60 * 1024, 16, 16); LOG.info("Finished evictImplicit"); }
private static void assertCacheStats(DataStoreCacheStatsMBean cache, long elems, long weight, long hits, long count) { assertEquals("elements don't match", elems, cache.getElementCount()); assertEquals("weight doesn't match", weight, cache.estimateCurrentWeight()); assertEquals("hits count don't match", hits, cache.getHitCount()); assertEquals("requests count don't match", count, cache.getRequestCount()); }
private static void assertCacheStats(FileCache cache, long elems, long weight, long loads, long loadSuccesses) { assertEquals(elems, cache.getStats().getElementCount()); assertEquals(weight, cache.getStats().estimateCurrentWeight()); assertEquals(loads, cache.getStats().getLoadCount()); assertEquals(loadSuccesses, cache.getStats().getLoadSuccessCount()); } }
private static void assertCacheStats(UploadStagingCache cache, long elems, long weight, long hits, long count) { assertEquals(elems, cache.getStats().getElementCount()); assertEquals(weight, cache.getStats().estimateCurrentWeight()); assertEquals(hits, cache.getStats().getHitCount()); assertEquals(count, cache.getStats().getRequestCount()); } }