public void addBytesCached(long bytes) { this.bytesCached += bytes; pool.addBytesCached(bytes); }
public void addBytesNeeded(long bytes) { this.bytesNeeded += bytes; pool.addBytesNeeded(bytes); }
public void addFilesCached(long files) { this.filesCached += files; pool.addFilesCached(files); }
/** * Throws an exception if the CachePool does not have enough capacity to * cache the given path at the replication factor. * * @param pool CachePool where the path is being cached * @param path Path that is being cached * @param replication Replication factor of the path * @throws InvalidRequestException if the pool does not have enough capacity */ private void checkLimit(CachePool pool, String path, short replication) throws InvalidRequestException { CacheDirectiveStats stats = computeNeeded(path, replication); if (pool.getLimit() == CachePoolInfo.LIMIT_UNLIMITED) { return; } if (pool.getBytesNeeded() + stats.getBytesNeeded() > pool.getLimit()) { throw new InvalidRequestException("Caching path " + path + " of size " + stats.getBytesNeeded() / replication + " bytes at replication " + replication + " would exceed pool " + pool.getPoolName() + "'s remaining capacity of " + (pool.getLimit() - pool.getBytesNeeded()) + " bytes."); } }
/** * Create a cache pool. * * Only the superuser should be able to call this function. * * @param info The info for the cache pool to create. * @return Information about the cache pool we created. */ public CachePoolInfo addCachePool(CachePoolInfo info) throws IOException { assert namesystem.hasWriteLock(); CachePool pool; try { CachePoolInfo.validate(info); String poolName = info.getPoolName(); pool = cachePools.get(poolName); if (pool != null) { throw new InvalidRequestException("Cache pool " + poolName + " already exists."); } pool = CachePool.createFromInfoAndDefaults(info); cachePools.put(pool.getPoolName(), pool); } catch (IOException e) { LOG.info("addCachePool of " + info + " failed: ", e); throw e; } LOG.info("addCachePool of {} successful.", info); return pool.getInfo(true); }
@Override // IntrusiveCollection.Element public void removeInternal(IntrusiveCollection<? extends Element> list) { assert list == pool.getDirectiveList(); this.pool = null; this.prev = null; this.next = null; }
/** * Create a new cache pool based on a CachePoolInfo object. * No fields in the CachePoolInfo can be blank. */ static CachePool createFromInfo(CachePoolInfo info) { return new CachePool(info.getPoolName(), info.getOwnerName(), info.getGroupName(), info.getMode(), info.getLimit(), info.getDefaultReplication(), info.getMaxRelativeExpiryMs()); }
public void addFilesNeeded(long files) { this.filesNeeded += files; pool.addFilesNeeded(files); }
/** * Get statistics about this CachePool. * * @return Cache pool statistics. */ private CachePoolStats getStats() { return new CachePoolStats.Builder(). setBytesNeeded(bytesNeeded). setBytesCached(bytesCached). setBytesOverlimit(getBytesOverlimit()). setFilesNeeded(filesNeeded). setFilesCached(filesCached). build(); }
public BatchedListEntries<CachePoolEntry> listCachePools(FSPermissionChecker pc, String prevKey) { assert namesystem.hasReadLock(); final int NUM_PRE_ALLOCATED_ENTRIES = 16; ArrayList<CachePoolEntry> results = new ArrayList<CachePoolEntry>(NUM_PRE_ALLOCATED_ENTRIES); SortedMap<String, CachePool> tailMap = cachePools.tailMap(prevKey, false); int numListed = 0; for (Entry<String, CachePool> cur : tailMap.entrySet()) { if (numListed++ >= maxListCachePoolsResponses) { return new BatchedListEntries<CachePoolEntry>(results, true); } results.add(cur.getValue().getEntry(pc)); } return new BatchedListEntries<CachePoolEntry>(results, false); }
if (pool.getBytesNeeded() > pool.getLimit()) { LOG.debug("Directive {}: not scanning file {} because " + "bytesNeeded for pool {} is {}, but the pool's limit is {}", directive.getId(), file.getFullPathName(), pool.getPoolName(), pool.getBytesNeeded(), pool.getLimit()); return;
@Override // IntrusiveCollection.Element public void setPrev(IntrusiveCollection<? extends Element> list, Element prev) { assert list == pool.getDirectiveList(); this.prev = prev; }
/** * Create a cache pool. * * Only the superuser should be able to call this function. * * @param info The info for the cache pool to create. * @return Information about the cache pool we created. */ public CachePoolInfo addCachePool(CachePoolInfo info) throws IOException { assert namesystem.hasWriteLock(); CachePool pool; try { CachePoolInfo.validate(info); String poolName = info.getPoolName(); pool = cachePools.get(poolName); if (pool != null) { throw new InvalidRequestException("Cache pool " + poolName + " already exists."); } pool = CachePool.createFromInfoAndDefaults(info); cachePools.put(pool.getPoolName(), pool); } catch (IOException e) { LOG.info("addCachePool of " + info + " failed: ", e); throw e; } LOG.info("addCachePool of {} successful.", info); return pool.getInfo(true); }
CachePoolInfo.DEFAULT_MAX_RELATIVE_EXPIRY : info.getMaxRelativeExpiryMs(); return new CachePool(info.getPoolName(), ownerName, groupName, mode, limit, defaultReplication, maxRelativeExpiry);
public void addFilesNeeded(long files) { this.filesNeeded += files; pool.addFilesNeeded(files); }
/** * Get statistics about this CachePool. * * @return Cache pool statistics. */ private CachePoolStats getStats() { return new CachePoolStats.Builder(). setBytesNeeded(bytesNeeded). setBytesCached(bytesCached). setBytesOverlimit(getBytesOverlimit()). setFilesNeeded(filesNeeded). setFilesCached(filesCached). build(); }
public BatchedListEntries<CachePoolEntry> listCachePools(FSPermissionChecker pc, String prevKey) { assert namesystem.hasReadLock(); final int NUM_PRE_ALLOCATED_ENTRIES = 16; ArrayList<CachePoolEntry> results = new ArrayList<CachePoolEntry>(NUM_PRE_ALLOCATED_ENTRIES); SortedMap<String, CachePool> tailMap = cachePools.tailMap(prevKey, false); int numListed = 0; for (Entry<String, CachePool> cur : tailMap.entrySet()) { if (numListed++ >= maxListCachePoolsResponses) { return new BatchedListEntries<CachePoolEntry>(results, true); } results.add(cur.getValue().getEntry(pc)); } return new BatchedListEntries<CachePoolEntry>(results, false); }
/** * Throws an exception if the CachePool does not have enough capacity to * cache the given path at the replication factor. * * @param pool CachePool where the path is being cached * @param path Path that is being cached * @param replication Replication factor of the path * @throws InvalidRequestException if the pool does not have enough capacity */ private void checkLimit(CachePool pool, String path, short replication) throws InvalidRequestException { CacheDirectiveStats stats = computeNeeded(path, replication); if (pool.getLimit() == CachePoolInfo.LIMIT_UNLIMITED) { return; } if (pool.getBytesNeeded() + (stats.getBytesNeeded() * replication) > pool .getLimit()) { throw new InvalidRequestException("Caching path " + path + " of size " + stats.getBytesNeeded() / replication + " bytes at replication " + replication + " would exceed pool " + pool.getPoolName() + "'s remaining capacity of " + (pool.getLimit() - pool.getBytesNeeded()) + " bytes."); } }
@Override // IntrusiveCollection.Element public boolean isInList(IntrusiveCollection<? extends Element> list) { return pool == null ? false : list == pool.getDirectiveList(); } };
/** * Create a cache pool. * * Only the superuser should be able to call this function. * * @param info The info for the cache pool to create. * @return Information about the cache pool we created. */ public CachePoolInfo addCachePool(CachePoolInfo info) throws IOException { assert namesystem.hasWriteLock(); CachePool pool; try { CachePoolInfo.validate(info); String poolName = info.getPoolName(); pool = cachePools.get(poolName); if (pool != null) { throw new InvalidRequestException("Cache pool " + poolName + " already exists."); } pool = CachePool.createFromInfoAndDefaults(info); cachePools.put(pool.getPoolName(), pool); } catch (IOException e) { LOG.info("addCachePool of " + info + " failed: ", e); throw e; } LOG.info("addCachePool of {} successful.", info); return pool.getInfo(true); }