.setNameFormat("FsDatasetCache-%d-" + dataset.toString()) .build(); this.usedBytesCount = new UsedBytesCount(); this.uncachingExecutor = new ThreadPoolExecutor( 0, 1,
+ "bytes in total.", key, usedBytesCount.get()); if (mappableBlock != null) { mappableBlock.close();
ExtendedBlock extBlk = new ExtendedBlock(key.getBlockPoolId(), key.getBlockId(), length, genstamp); long newUsedBytes = usedBytesCount.reserve(length); boolean reservedBytes = false; try { if (!success) { if (reservedBytes) { usedBytesCount.release(length); + "bytes in total.", key, usedBytesCount.get()); if (mappableBlock != null) { mappableBlock.close();
ExtendedBlock extBlk = new ExtendedBlock(key.getBlockPoolId(), key.getBlockId(), length, genstamp); long newUsedBytes = usedBytesCount.reserve(length); boolean reservedBytes = false; try { if (!success) { if (reservedBytes) { usedBytesCount.release(length); + "bytes in total.", key, usedBytesCount.get()); if (mappableBlock != null) { mappableBlock.close();
.setNameFormat("FsDatasetCache-%d-" + dataset.toString()) .build(); this.usedBytesCount = new UsedBytesCount(); this.uncachingExecutor = new ThreadPoolExecutor( 0, 1,
.setNameFormat("FsDatasetCache-%d-" + dataset.toString()) .build(); this.usedBytesCount = new UsedBytesCount(); this.uncachingExecutor = new ThreadPoolExecutor( 0, 1,
@Override public void run() { Value value; if (shouldDefer()) { deferredUncachingExecutor.schedule( this, revocationPollingMs, TimeUnit.MILLISECONDS); return; } synchronized (FsDatasetCache.this) { value = mappableBlockMap.get(key); } Preconditions.checkNotNull(value); Preconditions.checkArgument(value.state == State.UNCACHING); IOUtils.closeQuietly(value.mappableBlock); synchronized (FsDatasetCache.this) { mappableBlockMap.remove(key); } long newUsedBytes = usedBytesCount.release(value.mappableBlock.getLength()); numBlocksCached.addAndGet(-1); dataset.datanode.getMetrics().incrBlocksUncached(1); if (revocationTimeMs != 0) { LOG.debug("Uncaching of {} completed. usedBytes = {}", key, newUsedBytes); } else { LOG.debug("Deferred uncaching of {} completed. usedBytes = {}", key, newUsedBytes); } } }
@Override public void run() { Value value; if (shouldDefer()) { deferredUncachingExecutor.schedule( this, revocationPollingMs, TimeUnit.MILLISECONDS); return; } synchronized (FsDatasetCache.this) { value = mappableBlockMap.get(key); } Preconditions.checkNotNull(value); Preconditions.checkArgument(value.state == State.UNCACHING); IOUtils.closeQuietly(value.mappableBlock); synchronized (FsDatasetCache.this) { mappableBlockMap.remove(key); } long newUsedBytes = usedBytesCount.release(value.mappableBlock.getLength()); numBlocksCached.addAndGet(-1); dataset.datanode.getMetrics().incrBlocksUncached(1); if (revocationTimeMs != 0) { LOG.debug("Uncaching of {} completed. usedBytes = {}", key, newUsedBytes); } else { LOG.debug("Deferred uncaching of {} completed. usedBytes = {}", key, newUsedBytes); } } }
/** * Get the approximate amount of cache space used. */ public long getCacheUsed() { return usedBytesCount.get(); }
/** * Get the approximate amount of cache space used. */ public long getCacheUsed() { return usedBytesCount.get(); }
/** * 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) { return usedBytesCount.release(count); }
/** * Get the approximate amount of cache space used. */ public long getCacheUsed() { return usedBytesCount.get(); }
/** * Release some bytes that we're using rounded down to the page size. * * @param count The number of bytes to release. We will round this * down to the page size. * * @return The new number of usedBytes. */ long releaseRoundDown(long count) { return usedBytesCount.releaseRoundDown(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) { return usedBytesCount.reserve(count); }