@Override public void onSuccess(InputStream result) { openConnections.getAndDecrement(); }
/** Report that checksum was ok, so we may ponder going back to HBase checksum. */ public void checksumOk() { if (this.useHBaseChecksumConfigured && !this.useHBaseChecksum && (this.hbaseChecksumOffCount.getAndDecrement() < 0)) { // The stream we need is already open (because we were using HBase checksum in the past). assert this.streamNoFsChecksum != null; this.useHBaseChecksum = true; } }
private boolean remove(SimpleServerRpcConnection connection) { boolean removed = connections.remove(connection); if (removed) { count.getAndDecrement(); } return removed; }
static int getAndDecrement(AtomicInteger ai) { if (ai instanceof BTraceAtomicInteger) { return ai.getAndDecrement(); } else { throw new IllegalArgumentException(); } }
public void elementRemoved(E e) { currentSize.addAndGet(-1 * getBytesSize(e)); elementCount.getAndDecrement(); }
/** * Retries the test if count is not 0. * @param result The result of the test. */ @Override public boolean retry(ITestResult result) { if (count.getAndDecrement() > 0) { return retryMethod(result); } return false; }
@Implementation protected synchronized void release() { if (wifiManager != null) { shadowOf(wifiManager).activeLockCount.getAndDecrement(); } if (refCounted) { if (--refCount < 0) throw new RuntimeException("WifiLock under-locked"); } else { locked = false; } }
/** * Unlinks interior Node p with predecessor trail. */ void unlink(Node<E> p, Node<E> trail) { // assert isFullyLocked(); // p.next is not changed, to allow iterators that are // traversing p to maintain their weak-consistency guarantee. p.setValue(null); trail.next = p.next; if (last == p) last = trail; if (count.getAndDecrement() == capacity) notFull.signal(); }
@Implementation protected synchronized void release() { if (wifiManager != null) { shadowOf(wifiManager).activeLockCount.getAndDecrement(); } if (refCounted) { if (--refCount < 0) throw new RuntimeException("WifiLock under-locked"); } else { locked = false; } }
@Override public void onSuccess(T result) { counter.getAndDecrement(); onClientSuccess(client, result); executeSuccess(); }
@Override public void fulfill( AvailabilityRequirement requirement ) { if ( !blockingRequirements.remove( requirement ) ) { return; } synchronized ( requirementCount ) { if ( requirementCount.getAndDecrement() == 1 && !isShutdown.get() ) { log.info( DATABASE_AVAILABLE_MSG, requirement.description(), databaseName ); listeners.notify( AvailabilityListener::available ); } } }
@Override public void subscribe(Subscriber<? super String> t1) { t1.onSubscribe(new BooleanSubscription()); System.out.println(count.get() + " @ " + String.valueOf(last - System.currentTimeMillis())); last = System.currentTimeMillis(); if (count.getAndDecrement() == 0) { t1.onNext("hello"); t1.onComplete(); } else { t1.onError(new RuntimeException()); } }
@Override public void run() { long nr = 0; try { while (!terminate.get()) { Thread.sleep(emitDelay); if (nextBeforeFailure.getAndDecrement() > 0) { observer.onNext(nr++); } else { active.decrementAndGet(); observer.onError(new RuntimeException("expected-failed")); break; } } } catch (InterruptedException t) { } } };
@Override public void run() { long nr = 0; try { while (!terminate.get()) { Thread.sleep(emitDelay); if (nextBeforeFailure.getAndDecrement() > 0) { subscriber.onNext(nr++); } else { active.decrementAndGet(); subscriber.onError(new RuntimeException("expected-failed")); break; } } } catch (InterruptedException t) { } } };
@Override public void notifyReleased(Stream stream) { acquiredPartitions.removePartition(stream.getPartition()); if (acquiredStreams.remove(stream.getStreamName(), stream)) { numAcquired.getAndDecrement(); } }
/** * Should be called if the Thread that uses this cache is about to exist to release resources out of the cache */ void free() { // As free() may be called either by the finalizer or by FastThreadLocal.onRemoval(...) we need to ensure // we only call this one time. if (freed.compareAndSet(false, true)) { int numFreed = free(tinySubPageDirectCaches) + free(smallSubPageDirectCaches) + free(normalDirectCaches) + free(tinySubPageHeapCaches) + free(smallSubPageHeapCaches) + free(normalHeapCaches); if (numFreed > 0 && logger.isDebugEnabled()) { logger.debug("Freed {} thread-local buffer(s) from thread: {}", numFreed, Thread.currentThread().getName()); } if (directArena != null) { directArena.numThreadCaches.getAndDecrement(); } if (heapArena != null) { heapArena.numThreadCaches.getAndDecrement(); } } }
@Override public void subscribe(Observer<? super String> t1) { t1.onSubscribe(Disposables.empty()); System.out.println(count.get() + " @ " + String.valueOf(last - System.currentTimeMillis())); last = System.currentTimeMillis(); if (count.getAndDecrement() == 0) { t1.onNext("hello"); t1.onComplete(); } else { t1.onError(new RuntimeException()); } }
void checkProgrammedFail() throws KeeperException { if (stepsToFail.getAndDecrement() == 0 || this.alwaysFail) { throw KeeperException.create(failReturnCode); } }
/** {@inheritDoc} */ @Override protected void writeToSocket(TcpDiscoveryAbstractMessage msg, Socket sock, int res, long timeout) throws IOException { if (msg instanceof TcpDiscoveryJoinRequestMessage && failJoinReqRes.getAndDecrement() > 0) res = RES_WAIT; super.writeToSocket(msg, sock, res, timeout); }
@Override protected boolean flush(ByteBuffer buf) throws IOException { if (numFlushesRemaining.decrementAndGet() == 0 && !ready()) flushFailureAction.run(); else if (numDelayedFlushesRemaining.getAndDecrement() != 0) return false; resetDelayedFlush(); return super.flush(buf); }