@Override public long remainingSlots() { return workQueue != null ? workQueue.remainingCapacity() : Long.MAX_VALUE; }
private boolean isBoundedQueue() { return workQueue.remainingCapacity() != Integer.MAX_VALUE; }
@Override public int remainingCapacity() { return underlyingQueue.remainingCapacity(); }
/** * Returns maximum remaining capacity. This does not reflect how much you can * ideally fit in this FairCallQueue, as that would depend on the scheduler's * decisions. */ @Override public int remainingCapacity() { int sum = 0; for (BlockingQueue<E> q : this.queues) { sum += q.remainingCapacity(); } return sum; }
@Override public int remainingCapacity() { return delegate().remainingCapacity(); }
@Override public int workQueueRemainingCapacity() { return executor.getQueue().remainingCapacity(); }
@Override public int remainingCapacity() { return takeRef.get().remainingCapacity(); }
@Override public int remainingCapacity() { return delegate().remainingCapacity(); }
int nextPullBatchNums() { return Math.min(clientConfig.getRmqPullMessageBatchNums(), consumeRequestCache.remainingCapacity()); }
@Override public int remainingCapacity() { return delegate().remainingCapacity(); }
@Override public int remainingCapacity() { return delegate().remainingCapacity(); }
private RandomAccessFile checkOut() throws IOException, InterruptedException { RandomAccessFile fileHandle = readFileHandles.poll(); if (fileHandle != null) { return fileHandle; } int remaining = readFileHandles.remainingCapacity(); if (remaining > 0) { LOG.info("Opening " + file + " for read, remaining number of file " + "handles available for reads of this file is " + remaining); return open(); } return readFileHandles.take(); }
/** * Stores metrics in the store. * * @param metric Metric to store * @throws MetricException if database write fails */ public void insert(Metric metric) throws MetricException { try { // don't bother blocking on a full queue, just drop metrics in case we can't keep up if (queue.remainingCapacity() <= 0) { LOG.info("Metrics q full, dropping metric"); return; } queue.put(metric); } catch (Exception e) { String message = "Failed to insert metric"; LOG.error(message, e); if (this.failureMeter != null) { this.failureMeter.mark(); } throw new MetricException(message, e); } }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(LogCodes.getLog(LogCodes.ERROR_PROVIDER_TR_POOL_REJECTION, executor.getActiveCount(), executor.getPoolSize(), executor.getLargestPoolSize(), executor .getCorePoolSize(), executor.getMaximumPoolSize(), executor.getQueue() .size(), executor.getQueue().remainingCapacity())); } throw new RejectedExecutionException(); } }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(LogCodes.getLog(LogCodes.ERROR_PROVIDER_TR_POOL_REJECTION, executor.getActiveCount(), executor.getPoolSize(), executor.getLargestPoolSize(), executor .getCorePoolSize(), executor.getMaximumPoolSize(), executor.getQueue() .size(), executor.getQueue().remainingCapacity())); } throw new RejectedExecutionException(); } }
/** * Returns maximum number of tasks that can be submitted to given * pool (with bounded queue) before saturation (when submission * throws RejectedExecutionException). */ static final int saturatedSize(ThreadPoolExecutor pool) { BlockingQueue<Runnable> q = pool.getQueue(); return pool.getMaximumPoolSize() + q.size() + q.remainingCapacity(); }
@Override public void start() { channelCounter.start(); channelCounter.setChannelSize(queue.size()); channelCounter.setChannelSize( Long.valueOf(queue.size() + queue.remainingCapacity())); super.start(); }
@Override public Boolean call() throws Exception { barrier.await(); Assert.assertTrue(q.offer(obj, delayMS, TimeUnit.MILLISECONDS)); Assert.assertEquals(q.remainingCapacity(), 0); barrier.await(); q.put(obj); return true; } }
/** * remainingCapacity decreases on add, increases on remove */ public void testRemainingCapacity() { BlockingQueue q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.remainingCapacity()); assertEquals(SIZE, q.size() + q.remainingCapacity()); assertEquals(i, q.remove()); } for (int i = 0; i < SIZE; ++i) { assertEquals(SIZE - i, q.remainingCapacity()); assertEquals(SIZE, q.size() + q.remainingCapacity()); assertTrue(q.add(i)); } }
/** * remainingCapacity decreases on add, increases on remove */ public void testRemainingCapacity() { BlockingQueue q = populatedDeque(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.remainingCapacity()); assertEquals(SIZE, q.size() + q.remainingCapacity()); assertEquals(i, q.remove()); } for (int i = 0; i < SIZE; ++i) { assertEquals(SIZE - i, q.remainingCapacity()); assertEquals(SIZE, q.size() + q.remainingCapacity()); assertTrue(q.add(i)); } }