/** * {@inheritDoc} */ public boolean freeSpace(Collection<PoolAccessor<PoolParticipant>> from, long bytes) { if (from == null || from.isEmpty()) { return false; } long remainingSizeInBytes = bytes; Collection<PoolAccessor<PoolParticipant>> tried = new ArrayList<PoolAccessor<PoolParticipant>>(); while (tried.size() != from.size()) { PoolAccessor<PoolParticipant> largestPoolAccessor = findUntriedLargestPoolableStore(from, tried); long beforeEvictionSize = largestPoolAccessor.getSize(); if (!largestPoolAccessor.getParticipant().evict(1, bytes)) { tried.add(largestPoolAccessor); continue; } long afterEvictionSize = largestPoolAccessor.getSize(); remainingSizeInBytes -= (beforeEvictionSize - afterEvictionSize); if (remainingSizeInBytes <= 0L) { return true; } } return false; }
/** * {@inheritDoc} */ public boolean freeSpace(Collection<PoolAccessor<PoolParticipant>> from, long bytes) { if (from == null || from.isEmpty()) { return false; } long remainingSizeInBytes = bytes; Collection<PoolAccessor<PoolParticipant>> tried = new ArrayList<PoolAccessor<PoolParticipant>>(); while (tried.size() != from.size()) { PoolAccessor<PoolParticipant> largestPoolAccessor = findUntriedLargestPoolableStore(from, tried); long beforeEvictionSize = largestPoolAccessor.getSize(); if (!largestPoolAccessor.getParticipant().evict(1, bytes)) { tried.add(largestPoolAccessor); continue; } long afterEvictionSize = largestPoolAccessor.getSize(); remainingSizeInBytes -= (beforeEvictionSize - afterEvictionSize); if (remainingSizeInBytes <= 0L) { return true; } } return false; }
/** * {@inheritDoc} */ public boolean freeSpace(Collection<PoolAccessor<PoolParticipant>> from, long bytes) { if (from == null || from.isEmpty()) { return false; } long remainingSizeInBytes = bytes; Collection<PoolAccessor<PoolParticipant>> tried = new ArrayList<PoolAccessor<PoolParticipant>>(); while (tried.size() != from.size()) { PoolAccessor<PoolParticipant> largestPoolAccessor = findUntriedLargestPoolableStore(from, tried); long beforeEvictionSize = largestPoolAccessor.getSize(); if (!largestPoolAccessor.getParticipant().evict(1, bytes)) { tried.add(largestPoolAccessor); continue; } long afterEvictionSize = largestPoolAccessor.getSize(); remainingSizeInBytes -= (beforeEvictionSize - afterEvictionSize); if (remainingSizeInBytes <= 0L) { return true; } } return false; }