/** * This tracks block hit and misses against the cache for this Directory only * * @param isHit true if recording a hit otherwise it's a miss */ public void recordBlockCacheHit(boolean isHit) { if (isHit) { long hits = hitCounter.incrementAndGet(); if (isHitRateLoggingEnabled() && hits % 5000 == 0) { long misses = missCounter.get(); double hr = MTLRUCache.calculateHitRate(hits, misses); int hrRounded = (int) (hr * 100); boolean showHR = false; // if its poor, show frequently if (hr < 0.5) showHR = true; else // otherwise, show infrequently if (hits % 20000 == 0) showHR = true; if (showHR) { int compRate = 0; if (unCompressedTotal.get() != 0) { compRate = (int) (100.0 * (double) compressedTotal.get() / (double) unCompressedTotal.get()); } logger.log( Level.INFO, "Hit rate for " + directoryName + " Directory is " + hrRounded + "%, total reads " + (hits + misses) + ", Compress Rate:" + compRate + "%"); } } } else missCounter.incrementAndGet(); }
/* (non-Javadoc) * @see com.devwebsphere.wxslucene.jmx.LuceneDirectoryMBean#getBlockHitRate() */ @TabularAttribute(mbean = SummaryMBeanImpl.MONITOR_MBEAN) public Double getBlockHitRate() { if (blockLRUCache != null) return blockLRUCache.getHitRate(); else return 0.0; }