private PoolAccessor<PoolParticipant> findUntriedLargestPoolableStore(Collection<PoolAccessor<PoolParticipant>> from, Collection<PoolAccessor<PoolParticipant>> tried) { PoolAccessor<PoolParticipant> largestPoolAccessor = null; for (PoolAccessor<PoolParticipant> accessor : from) { if (alreadyTried(tried, accessor)) { continue; } if (largestPoolAccessor == null || accessor.getSize() > largestPoolAccessor.getSize()) { largestPoolAccessor = accessor; } } return largestPoolAccessor; }
/** * {@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; }
// on-heap pool configuration Pool onHeapPool; if (configuration.getMaxBytesLocalHeap() > 0) { PoolEvictor evictor = new FromLargestCachePoolEvictor(); SizeOfEngine sizeOfEngine = cacheManager.createSizeOfEngine(this); onHeapPool = new BoundedPool(configuration.getMaxBytesLocalHeap(), evictor, sizeOfEngine); } else if (getCacheManager() != null && getCacheManager().getConfiguration().isMaxBytesLocalHeapSet()) { onHeapPool = getCacheManager().getOnHeapPool(); } else { onHeapPool = new UnboundedPool(); }
PoolEvictor evictor = new FromLargestCachePoolEvictor(); SizeOfEngine sizeOfEngine = cacheManager.createSizeOfEngine(this); onHeapPool = new BoundedPool(configuration.getMaxBytesLocalHeap(), evictor, sizeOfEngine); PoolEvictor evictor = new FromLargestCachePoolEvictor(); onDiskPool = new BoundedPool(configuration.getMaxBytesLocalDisk(), evictor, null); } else if (getCacheManager() != null && getCacheManager().getConfiguration().isMaxBytesLocalDiskSet()) {
PoolEvictor evictor = new FromLargestCachePoolEvictor(); SizeOfEngine sizeOfEngine = cacheManager.createSizeOfEngine(this); onHeapPool = new BoundedPool(configuration.getMaxBytesLocalHeap(), evictor, sizeOfEngine); PoolEvictor evictor = new FromLargestCachePoolEvictor(); onDiskPool = new BoundedPool(configuration.getMaxBytesLocalDisk(), evictor, null); } else if (getCacheManager() != null && getCacheManager().getConfiguration().isMaxBytesLocalDiskSet()) {
private PoolAccessor<PoolParticipant> findUntriedLargestPoolableStore(Collection<PoolAccessor<PoolParticipant>> from, Collection<PoolAccessor<PoolParticipant>> tried) { PoolAccessor<PoolParticipant> largestPoolAccessor = null; for (PoolAccessor<PoolParticipant> accessor : from) { if (alreadyTried(tried, accessor)) { continue; } if (largestPoolAccessor == null || accessor.getSize() > largestPoolAccessor.getSize()) { largestPoolAccessor = accessor; } } return largestPoolAccessor; }
/** * {@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; }
PoolEvictor evictor = new FromLargestCachePoolEvictor(); SizeOfEngine sizeOfEngine = cacheManager.createSizeOfEngine(this); onHeapPool = new BoundedPool(configuration.getMaxBytesLocalHeap(), evictor, sizeOfEngine); PoolEvictor evictor = new FromLargestCachePoolEvictor(); onDiskPool = new BoundedPool(configuration.getMaxBytesLocalDisk(), evictor, null); } else if (getCacheManager() != null && getCacheManager().getConfiguration().isMaxBytesLocalDiskSet()) {
private PoolAccessor<PoolParticipant> findUntriedLargestPoolableStore(Collection<PoolAccessor<PoolParticipant>> from, Collection<PoolAccessor<PoolParticipant>> tried) { PoolAccessor<PoolParticipant> largestPoolAccessor = null; for (PoolAccessor<PoolParticipant> accessor : from) { if (alreadyTried(tried, accessor)) { continue; } if (largestPoolAccessor == null || accessor.getSize() > largestPoolAccessor.getSize()) { largestPoolAccessor = accessor; } } return largestPoolAccessor; }
/** * {@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; }