/** * Notify this pool that {@code connection} has become idle. Returns true if the connection has * been removed from the pool and should be closed. */ boolean connectionBecameIdle(RealConnection connection) { assert (Thread.holdsLock(this)); if (connection.noNewStreams || maxIdleConnections == 0) { connections.remove(connection); return true; } else { notifyAll(); // Awake the cleanup thread: we may have exceeded the idle connection limit. return false; } }
private void evictConnection(Holder holder) { holder.removed = true; connectionRemoved.accept(holder.connection); if (holder.capacity > 0) { capacity -= holder.capacity; available.remove(holder); holder.capacity = 0; } weight -= holder.weight; }
private <T> void finished(Deque<T> calls, T call) { Runnable idleCallback; synchronized (this) { if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!"); idleCallback = this.idleCallback; } boolean isRunning = promoteAndExecute(); if (!isRunning && idleCallback != null) { idleCallback.run(); } }
/** * Notify this pool that {@code connection} has become idle. Returns true if the connection has * been removed from the pool and should be closed. */ boolean connectionBecameIdle(RealConnection connection) { assert (Thread.holdsLock(this)); if (connection.noNewStreams || maxIdleConnections == 0) { connections.remove(connection); return true; } else { notifyAll(); // Awake the cleanup thread: we may have exceeded the idle connection limit. return false; } }
private void deletePartition(long pid) { LOG.debug("Delete partition: {}", pid); try { partitionIdsLock.lock(); partitionIds.remove(pid); partitionIdsState.put(PARTITION_IDS_KEY, partitionIds); } finally { partitionIdsLock.unlock(); } }
@Override public E remove() { assertTrue(Thread.holdsLock(mutex)); return delegate.remove(); }
@Override public boolean remove(Object object) { assertTrue(Thread.holdsLock(mutex)); return delegate.remove(object); }
private <T> void finished(Deque<T> calls, T call) { Runnable idleCallback; synchronized (this) { if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!"); idleCallback = this.idleCallback; } boolean isRunning = promoteAndExecute(); if (!isRunning && idleCallback != null) { idleCallback.run(); } }
/** {@inheritDoc} */ @Override public E remove() { E res = deque.remove(); adder.decrement(); return res; }
/** {@inheritDoc} */ @Override public boolean remove(Object o) { boolean res = deque.remove(o); if (res) adder.decrement(); return res; }
private <T> void finished(Deque<T> calls, T call, boolean promoteCalls) { int runningCallsCount; Runnable idleCallback; synchronized (this) { if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!"); if (promoteCalls) promoteCalls(); runningCallsCount = runningCallsCount(); idleCallback = this.idleCallback; } if (runningCallsCount == 0 && idleCallback != null) { idleCallback.run(); } }
@Override public void closeScreen(UIScreenLayer screen) { if (screens.remove(screen)) { ResourceUrn screenUri = screenLookup.inverse().remove(screen); onCloseScreen(screen, screenUri, true); } }
connections.remove(longestIdleConnection); } else if (idleConnectionCount > 0) {
/** Removes the Pointer from the {@link #pointerStack} of this Scope. */ public PointerScope detach(Pointer p) { if (logger.isDebugEnabled()) { logger.debug("Detaching " + p + " from " + this); } pointerStack.remove(p); return this; }
private void closeScreen(ResourceUrn screenUri, boolean sendEvents) { UIScreenLayer screen = screenLookup.remove(screenUri); if (screen != null) { screens.remove(screen); onCloseScreen(screen, screenUri, sendEvents); } }
/** Calls {@link #deallocate()} when {@link #deallocateOnClose} is true, * and removes itself from {@link #scopeStack}. */ @Override public void close() { if (logger.isDebugEnabled()) { logger.debug("Closing " + this); } if (deallocateOnClose()) { deallocate(); } scopeStack.get().remove(this); }
/** * Abort all incomplete batches (whether they have been sent or not) */ void abortBatches(final RuntimeException reason) { for (ProducerBatch batch : incomplete.copyAll()) { Deque<ProducerBatch> dq = getDeque(batch.topicPartition); synchronized (dq) { batch.abortRecordAppends(); dq.remove(batch); } batch.abort(reason); deallocate(batch); } }
/** * Abort any batches which have not been drained */ void abortUndrainedBatches(RuntimeException reason) { for (ProducerBatch batch : incomplete.copyAll()) { Deque<ProducerBatch> dq = getDeque(batch.topicPartition); boolean aborted = false; synchronized (dq) { if ((transactionManager != null && !batch.hasSequence()) || (transactionManager == null && !batch.isClosed())) { aborted = true; batch.abortRecordAppends(); dq.remove(batch); } } if (aborted) { batch.abort(reason); deallocate(batch); } } }