/** * Release some bytes that we're using. * * @param count The number of bytes to release. We will round this * up to the page size. * * @return The new number of usedBytes. */ long release(long count) { count = rounder.round(count); return usedBytes.addAndGet(-count); }
/** * Try to reserve more bytes. * * @param count The number of bytes to add. We will round this * up to the page size. * * @return The new number of usedBytes if we succeeded; * -1 if we failed. */ long reserve(long count) { count = rounder.round(count); while (true) { long cur = usedBytes.get(); long next = cur + count; if (next > maxBytes) { return -1; } if (usedBytes.compareAndSet(cur, next)) { return next; } } }
/** * Try to reserve more bytes. * * @param count The number of bytes to add. We will round this * up to the page size. * * @return The new number of usedBytes if we succeeded; * -1 if we failed. */ long reserve(long count) { count = rounder.round(count); while (true) { long cur = usedBytes.get(); long next = cur + count; if (next > maxBytes) { return -1; } if (usedBytes.compareAndSet(cur, next)) { return next; } } }
setHeartbeatResponse(cacheBlocks(fileLocs[i])); total = DFSTestUtil.verifyExpectedCacheUsage( rounder.round(total + fileSizes[i]), 4 * (i + 1), fsd); for (int i=0; i<numFiles-1; i++) { setHeartbeatResponse(uncacheBlocks(fileLocs[i])); long uncachedBytes = rounder.round(fileSizes[i]); total -= uncachedBytes; curCachedBlocks -= uncachedBytes / BLOCK_SIZE;
/** * Release some bytes that we're using. * * @param count The number of bytes to release. We will round this * up to the page size. * * @return The new number of usedBytes. */ long release(long count) { count = rounder.round(count); return usedBytes.addAndGet(-count); }