@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("misses=").append(getMisses()); sb.append(";hits=").append(getHits()); sb.append(";cached=").append(getCached()); sb.append(";bytesCached=").append(getBytesCached()); sb.append(";bytesEvicted=").append(getBytesEvicted()); return sb.toString(); } }
long statSize = store.getStats().getBlockCache().getBytesCached(); assertTrue("Block cache stats expected to be near " + blockCacheSize + " was " + statSize, blockCacheSize / 2 < statSize &&
public void testReadStats() throws Exception { HoplogOrganizer<SortedHoplogPersistedEvent> bucket = regionManager.create(0); ArrayList<TestEvent> items = new ArrayList<TestEvent>(); for (int i = 0; i < 100; i++) { items.add(new TestEvent("key-" + i, "value-" + System.nanoTime())); } bucket.flush(items.iterator(), 100); // validate read stats assertEquals(0, stats.getRead().getCount()); assertEquals(0, stats.getRead().getBytes()); // number of bytes read must be greater than size of key and value and must be increasing int bytesRead = "key-1".getBytes().length + "value=1233232".getBytes().length; for (int i = 0; i < 5; i++) { long previousRead = stats.getRead().getBytes(); PersistedEventImpl e = bucket.read(BlobHelper.serializeToBlob("key-" + i)); assertNotNull(e); assertEquals(i + 1, stats.getRead().getCount()); assertTrue( (bytesRead + previousRead) < stats.getRead().getBytes()); } //Make sure the block cache stats are being updated. assertTrue(storeStats.getBlockCache().getMisses() > 0); assertTrue(storeStats.getBlockCache().getBytesCached() > 0); assertTrue(storeStats.getBlockCache().getCached() > 0); //Do a duplicate read to make sure we get a hit in the cache PersistedEventImpl e = bucket.read(BlobHelper.serializeToBlob("key-" + 0)); assertTrue(storeStats.getBlockCache().getHits() > 0); }
public HFileStoreStatistics(StatisticsFactory factory, String typeName, String name) { StatisticsTypeFactory tf = StatisticsTypeFactoryImpl.singleton(); StatisticDescriptor bcMisses = tf.createLongCounter("blockCacheMisses", "The total number of block cache misses", "misses"); StatisticDescriptor bcHits = tf.createLongCounter("blockCacheHits", "The total number of block cache hits", "hits"); StatisticDescriptor bcCached = tf.createLongGauge("blocksCached", "The current number of cached blocks", "blocks"); StatisticDescriptor bcBytesCached = tf.createLongGauge("blockBytesCached", "The current number of bytes cached", "bytes"); StatisticDescriptor bcBytesEvicted = tf.createLongCounter("blockBytesEvicted", "The total number of bytes cached", "bytes"); StatisticsType type = tf.createType(typeName, "Statistics about structured I/O operations for a region", new StatisticDescriptor[] { bcMisses, bcHits, bcCached, bcBytesCached, bcBytesEvicted }); blockCache = new CacheOperation(bcMisses.getId(), bcHits.getId(), bcCached.getId(), bcBytesCached.getId(), bcBytesEvicted.getId()); stats = factory.createAtomicStatistics(type, name); }
public HFileStoreStatistics(StatisticsFactory factory, String typeName, String name) { StatisticsTypeFactory tf = StatisticsTypeFactoryImpl.singleton(); StatisticDescriptor bcMisses = tf.createLongCounter("blockCacheMisses", "The total number of block cache misses", "misses"); StatisticDescriptor bcHits = tf.createLongCounter("blockCacheHits", "The total number of block cache hits", "hits"); StatisticDescriptor bcCached = tf.createLongGauge("blocksCached", "The current number of cached blocks", "blocks"); StatisticDescriptor bcBytesCached = tf.createLongGauge("blockBytesCached", "The current number of bytes cached", "bytes"); StatisticDescriptor bcBytesEvicted = tf.createLongCounter("blockBytesEvicted", "The total number of bytes cached", "bytes"); StatisticsType type = tf.createType(typeName, "Statistics about structured I/O operations for a region", new StatisticDescriptor[] { bcMisses, bcHits, bcCached, bcBytesCached, bcBytesEvicted }); blockCache = new CacheOperation(bcMisses.getId(), bcHits.getId(), bcCached.getId(), bcBytesCached.getId(), bcBytesEvicted.getId()); stats = factory.createAtomicStatistics(type, name); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("misses=").append(getMisses()); sb.append(";hits=").append(getHits()); sb.append(";cached=").append(getCached()); sb.append(";bytesCached=").append(getBytesCached()); sb.append(";bytesEvicted=").append(getBytesEvicted()); return sb.toString(); } }