for (int i = 0; i < stats.length; i++) { bytesToFreeForBucket[i] = 0; long freeGoal = (long) Math.floor(stats[i].totalCount() * (1 - minFactor)); freeGoal = Math.max(freeGoal, 1); if (stats[i].freeCount() < freeGoal) { bytesToFreeForBucket[i] = stats[i].itemSize() * (freeGoal - stats[i].freeCount()); bytesToFreeWithoutExtra += bytesToFreeForBucket[i]; if (msgBuffer != null) { msgBuffer.append("Free for bucketSize(" + stats[i].itemSize() + ")=" + StringUtils.byteDesc(bytesToFreeForBucket[i]) + ", ");
void logStatistics() { IndexStatistics total = new IndexStatistics(); IndexStatistics[] stats = getIndexStatistics(total); LOG.info("Bucket allocator statistics follow:\n"); LOG.info(" Free bytes=" + total.freeBytes() + "+; used bytes=" + total.usedBytes() + "; total bytes=" + total.totalBytes()); for (IndexStatistics s : stats) { LOG.info(" Object size " + s.itemSize() + " used=" + s.usedCount() + "; free=" + s.freeCount() + "; total=" + s.totalCount()); } }
for (int i = 0; i < stats.length; i++) { bytesToFreeForBucket[i] = 0; long freeGoal = (long) Math.floor(stats[i].totalCount() * (1 - DEFAULT_MIN_FACTOR)); freeGoal = Math.max(freeGoal, 1); if (stats[i].freeCount() < freeGoal) { bytesToFreeForBucket[i] = stats[i].itemSize() * (freeGoal - stats[i].freeCount()); bytesToFreeWithoutExtra += bytesToFreeForBucket[i]; if (msgBuffer != null) { msgBuffer.append("Free for bucketSize(" + stats[i].itemSize() + ")=" + StringUtils.byteDesc(bytesToFreeForBucket[i]) + ", "); boolean needFreeForExtra = false; for (int i = 0; i < stats.length; i++) { long freeGoal = (long) Math.floor(stats[i].totalCount() * (1 - DEFAULT_MIN_FACTOR)); freeGoal = Math.max(freeGoal, 1); if (stats[i].freeCount() < freeGoal) { needFreeForExtra = true; break;
BucketSizeInfo bucketSizeInfo = mAllocator.roundUpToBucketSizeInfo(blockSize); IndexStatistics indexStatistics = bucketSizeInfo.statistics(); assertEquals("unexpected freeCount for " + bucketSizeInfo, 0, indexStatistics.freeCount());
public IndexStatistics() { setTo(-1, -1, 0); }
public IndexStatistics(long free, long used, long itemSize) { setTo(free, used, itemSize); }
IndexStatistics[] getIndexStatistics(IndexStatistics grandTotal) { IndexStatistics[] stats = getIndexStatistics(); long totalfree = 0, totalused = 0; for (IndexStatistics stat : stats) { totalfree += stat.freeBytes(); totalused += stat.usedBytes(); } grandTotal.setTo(totalfree, totalused, 1); return stats; }
public IndexStatistics statistics() { long free = 0, used = 0; for (Object obj : bucketList.keySet()) { Bucket b = (Bucket) obj; free += b.freeCount(); used += b.usedCount(); } return new IndexStatistics(free, used, bucketSizes[sizeIndex]); }
void logStatistics() { IndexStatistics total = new IndexStatistics(); IndexStatistics[] stats = getIndexStatistics(total); LOG.info("Bucket allocator statistics follow:\n"); LOG.info(" Free bytes=" + total.freeBytes() + "+; used bytes=" + total.usedBytes() + "; total bytes=" + total.totalBytes()); for (IndexStatistics s : stats) { LOG.info(" Object size " + s.itemSize() + " used=" + s.usedCount() + "; free=" + s.freeCount() + "; total=" + s.totalCount()); } }
BucketSizeInfo bucketSizeInfo = mAllocator.roundUpToBucketSizeInfo(blockSize); IndexStatistics indexStatistics = bucketSizeInfo.statistics(); assertEquals("unexpected freeCount for " + bucketSizeInfo, 0, indexStatistics.freeCount());
/** * Return the count of bucketSizeinfos still need free space */ private int bucketSizesAboveThresholdCount(float minFactor) { BucketAllocator.IndexStatistics[] stats = bucketAllocator.getIndexStatistics(); int fullCount = 0; for (int i = 0; i < stats.length; i++) { long freeGoal = (long) Math.floor(stats[i].totalCount() * (1 - minFactor)); freeGoal = Math.max(freeGoal, 1); if (stats[i].freeCount() < freeGoal) { fullCount++; } } return fullCount; }
public IndexStatistics(long free, long used, long itemSize) { setTo(free, used, itemSize); }
public IndexStatistics() { setTo(-1, -1, 0); }
public synchronized IndexStatistics statistics() { long free = 0, used = 0; for (Object obj : bucketList.keySet()) { Bucket b = (Bucket) obj; free += b.freeCount(); used += b.usedCount(); } return new IndexStatistics(free, used, bucketSizes[sizeIndex]); }
IndexStatistics[] getIndexStatistics(IndexStatistics grandTotal) { IndexStatistics[] stats = getIndexStatistics(); long totalfree = 0, totalused = 0; for (IndexStatistics stat : stats) { totalfree += stat.freeBytes(); totalused += stat.usedBytes(); } grandTotal.setTo(totalfree, totalused, 1); return stats; }