PoolEvictor evictor = new BalancedAccessEvictor(); SizeOfEngine sizeOfEngine = createSizeOfEngine(null); this.onHeapPool = new BoundedPool(configuration.getMaxBytesLocalHeap(), evictor, sizeOfEngine); PoolEvictor evictor = new BalancedAccessEvictor(); this.onDiskPool = new BoundedPool(configuration.getMaxBytesLocalDisk(), evictor, null);
/** * {@inheritDoc} */ public boolean freeSpace(Collection<PoolAccessor<PoolParticipant>> from, long bytes) { if (from == null || from.isEmpty()) { return false; } List<PoolAccessor> random = new ArrayList<PoolAccessor>(from); Collections.shuffle(random); for (int i = 0; i < random.size(); i += SAMPLE_SIZE) { List<PoolAccessor> sorted = random.subList(i, Math.min(SAMPLE_SIZE + i, random.size())); Collections.sort(sorted, new EvictionCostComparator(getDesiredUnloadedSize(sorted), sorted.size() + 1)); for (PoolAccessor accessor : sorted) { int count; long byteSize = accessor.getSize(); long countSize = accessor.getParticipant().getApproximateCountSize(); if (countSize == 0 || byteSize == 0) { count = 1; } else { count = (int) Math.max((bytes * countSize) / byteSize, 1L); } if (accessor.getParticipant().evict(count, bytes)) { return true; } } } return false; }
/** * {@inheritDoc} */ public boolean freeSpace(Collection<PoolAccessor<PoolParticipant>> from, long bytes) { if (from == null || from.isEmpty()) { return false; } List<PoolAccessor> random = new ArrayList<PoolAccessor>(from); Collections.shuffle(random); for (int i = 0; i < random.size(); i += SAMPLE_SIZE) { List<PoolAccessor> sorted = random.subList(i, Math.min(SAMPLE_SIZE + i, random.size())); Collections.sort(sorted, new EvictionCostComparator(getDesiredUnloadedSize(sorted), sorted.size() + 1)); for (PoolAccessor accessor : sorted) { int count; long byteSize = accessor.getSize(); long countSize = accessor.getParticipant().getApproximateCountSize(); if (countSize == 0 || byteSize == 0) { count = 1; } else { count = (int) Math.max((bytes * countSize) / byteSize, 1L); } if (accessor.getParticipant().evict(count, bytes)) { return true; } } } return false; }
PoolEvictor evictor = new BalancedAccessEvictor(); SizeOfEngine sizeOfEngine = createSizeOfEngine(null); this.onHeapPool = new BoundedPool(configuration.getMaxBytesLocalHeap(), evictor, sizeOfEngine); PoolEvictor evictor = new BalancedAccessEvictor(); this.onDiskPool = new BoundedPool(configuration.getMaxBytesLocalDisk(), evictor, null);
/** * {@inheritDoc} */ public boolean freeSpace(Collection<PoolAccessor<PoolParticipant>> from, long bytes) { if (from == null || from.isEmpty()) { return false; } List<PoolAccessor> random = new ArrayList<PoolAccessor>(from); Collections.shuffle(random); for (int i = 0; i < random.size(); i += SAMPLE_SIZE) { List<PoolAccessor> sorted = random.subList(i, Math.min(SAMPLE_SIZE + i, random.size())); Collections.sort(sorted, new EvictionCostComparator(getDesiredUnloadedSize(sorted), sorted.size() + 1)); for (PoolAccessor accessor : sorted) { int count; long byteSize = accessor.getSize(); long countSize = accessor.getParticipant().getApproximateCountSize(); if (countSize == 0 || byteSize == 0) { count = 1; } else { count = (int) Math.max((bytes * countSize) / byteSize, 1L); } if (accessor.getParticipant().evict(count, bytes)) { return true; } } } return false; }
PoolEvictor evictor = new BalancedAccessEvictor(); SizeOfEngine sizeOfEngine = createSizeOfEngine(null); this.onHeapPool = new BoundedPool(configuration.getMaxBytesLocalHeap(), evictor, sizeOfEngine); PoolEvictor evictor = new BalancedAccessEvictor(); this.onDiskPool = new BoundedPool(configuration.getMaxBytesLocalDisk(), evictor, null);