private void addInternal(CacheDirective directive, CachePool pool) { boolean addedDirective = pool.getDirectiveList().add(directive); assert addedDirective; directivesById.put(directive.getId(), directive); String path = directive.getPath(); List<CacheDirective> directives = directivesByPath.get(path); if (directives == null) { directives = new ArrayList<CacheDirective>(1); directivesByPath.put(path, directives); } directives.add(directive); // Fix up pool stats CacheDirectiveStats stats = computeNeeded(directive.getPath(), directive.getReplication()); directive.addBytesNeeded(stats.getBytesNeeded()); directive.addFilesNeeded(directive.getFilesNeeded()); setNeedsRescan(); }
/** * 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."); } }
private void addInternal(CacheDirective directive, CachePool pool) { boolean addedDirective = pool.getDirectiveList().add(directive); assert addedDirective; directivesById.put(directive.getId(), directive); String path = directive.getPath(); List<CacheDirective> directives = directivesByPath.get(path); if (directives == null) { directives = new ArrayList<CacheDirective>(1); directivesByPath.put(path, directives); } directives.add(directive); // Fix up pool stats CacheDirectiveStats stats = computeNeeded(directive.getPath(), directive.getReplication()); directive.addBytesNeeded(stats.getBytesNeeded()); directive.addFilesNeeded(directive.getFilesNeeded()); setNeedsRescan(); }
private void addInternal(CacheDirective directive, CachePool pool) { boolean addedDirective = pool.getDirectiveList().add(directive); assert addedDirective; directivesById.put(directive.getId(), directive); String path = directive.getPath(); List<CacheDirective> directives = directivesByPath.get(path); if (directives == null) { directives = new ArrayList<CacheDirective>(1); directivesByPath.put(path, directives); } directives.add(directive); // Fix up pool stats CacheDirectiveStats stats = computeNeeded(directive.getPath(), directive.getReplication()); directive.addBytesNeeded(stats.getBytesNeeded()); directive.addFilesNeeded(directive.getFilesNeeded()); setNeedsRescan(); }
/** * 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."); } }
/** * 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."); } }