@Override public Boolean call() throws Exception { return requestIterable.isFull(); } });
public void getRejectedAndDroppedRequests(ConcurrentBoundedPriorityIterable<T> iterable) { requestsExceedingAvailableResourcePool = iterable.getRequestsExceedingAvailableResourcePool(); requestsRejectedWithLowPriority = iterable.getRequestsRejectedWithLowPriority(); requestsRejectedDueToInsufficientEviction = iterable.getRequestsRejectedDueToInsufficientEviction(); requestsDropped = iterable.getRequestsDropped(); }
new ConcurrentBoundedPriorityIterable<>(new MyComparator(), new MyEstimator(), "min", ResourcePool.builder().maxResource(MEMORY, 100.).build()); Assert.assertFalse(iterable.add("a-500")); Assert.assertTrue(iterable.add("d-50")); Assert.assertFalse(iterable.isFull()); Assert.assertTrue(iterable.add("d-50")); Assert.assertTrue(iterable.isFull()); Assert.assertFalse(iterable.add("d-50")); Assert.assertFalse(iterable.add("e-50")); Assert.assertTrue(iterable.add("e-10")); Assert.assertTrue(iterable.add("b-50")); .newArrayList(Iterators.transform(iterable.iterator(), new AllocatedRequestsIteratorBase.TExtractor<String>())); Assert.assertEquals(items.size(), 2); Assert.assertEquals(items.get(0), "b-50"); Assert.assertEquals(items.get(1), "d-50"); iterable.reopen(); Assert.assertFalse(iterable.add("c-500")); items = Lists .newArrayList(Iterators.transform(iterable.iterator(), new AllocatedRequestsIteratorBase.TExtractor<String>())); Assert.assertEquals(items.size(), 2);
ResourcePool resourcePool) { final ConcurrentBoundedPriorityIterable<T> iterable = new ConcurrentBoundedPriorityIterable<>(this.configuration.getPrioritizer(), this.configuration.getResourceEstimator(), this.configuration.getStoreRejectedRequestsSetting(), resourcePool); iterable.add(joinIterator.next()); iterable.logStatistics(Optional.of(this.log)); return new AllocatedRequestsIteratorBase<>(iterable.iterator(), resourcePool);
/** * Offer an element to the container. * @return true if the element was added, false if there was no space and we could not evict any elements to make it fit. * Note that the element may get evicted by future offers, so a return of true is not a guarantee that the * element will be present at any time in the future. */ public boolean add(T t) { if (this.closed) { throw new RuntimeException( ConcurrentBoundedPriorityIterable.class.getSimpleName() + " is no longer accepting requests!"); } AllocatedRequestsIteratorBase.RequestWithResourceRequirement<T> newElement = new AllocatedRequestsIteratorBase.RequestWithResourceRequirement<>(t, this.estimator.estimateRequirement(t, this.resourcePool)); boolean addedWorkunits = addImpl(newElement); if (!addedWorkunits) { this.rejectedElement = true; } return addedWorkunits; }
ResourcePool resourcePool) { final ConcurrentBoundedPriorityIterable<T> iterable = new ConcurrentBoundedPriorityIterable<>(this.configuration.getPrioritizer(), this.configuration.getResourceEstimator(), this.configuration.getStoreRejectedRequestsSetting(), resourcePool); iterable.add(joinIterator.next()); iterable.logStatistics(Optional.of(this.log)); return new AllocatedRequestsIteratorBase<>(iterable.iterator(), resourcePool);
/** * Offer an element to the container. * @return true if the element was added, false if there was no space and we could not evict any elements to make it fit. * Note that the element may get evicted by future offers, so a return of true is not a guarantee that the * element will be present at any time in the future. */ public boolean add(T t) { if (this.closed) { throw new RuntimeException( ConcurrentBoundedPriorityIterable.class.getSimpleName() + " is no longer accepting requests!"); } AllocatedRequestsIteratorBase.RequestWithResourceRequirement<T> newElement = new AllocatedRequestsIteratorBase.RequestWithResourceRequirement<>(t, this.estimator.estimateRequirement(t, this.resourcePool)); boolean addedWorkunits = addImpl(newElement); if (!addedWorkunits) { this.rejectedElement = true; } return addedWorkunits; }
public void getRejectedAndDroppedRequests(ConcurrentBoundedPriorityIterable<T> iterable) { requestsExceedingAvailableResourcePool = iterable.getRequestsExceedingAvailableResourcePool(); requestsRejectedWithLowPriority = iterable.getRequestsRejectedWithLowPriority(); requestsRejectedDueToInsufficientEviction = iterable.getRequestsRejectedDueToInsufficientEviction(); requestsDropped = iterable.getRequestsDropped(); }
@Override public Boolean call() throws Exception { return requestIterable.isFull(); } });
@Override public Boolean call() throws Exception { return requestIterable.isFull(); } });
@Override public Boolean call() throws Exception { return requestIterable.isFull(); } });