@Override public int getAndResetFailedAssignCount() { return failedAssignCount.getAndSet(0); }
@Override public int getAndResetFailedAssignCount() { return failedAssignCount.getAndSet(0); }
public static int get(AtomicInteger counter, boolean reset) { if (reset) { return counter.getAndSet(0); } else { return counter.get(); } } }
public static int getAndResetInvocationCount() { return COUNTER.getAndSet( 0 ); } }
public synchronized void setPartitionedSplitCount(int partitionedSplitCount) { if (partitionedSplitCount < 0) { int oldValue = localPartitionedSplitCount.getAndSet(0); nodeTotalPartitionedSplitCount.addAndGet(-oldValue); throw new IllegalArgumentException("partitionedSplitCount is negative"); } int oldValue = localPartitionedSplitCount.getAndSet(partitionedSplitCount); nodeTotalPartitionedSplitCount.addAndGet(partitionedSplitCount - oldValue); }
void acquire() { if (mRefCount.getAndSet(1) != 0) { throw new RuntimeException( "Tried to acquire a LayoutOutput that already had a non-zero ref count!"); } }
@Override public String statisticCallback() { int count = rejectCounter.getAndSet(0); if (count > 0) { return String.format("type: motan name: reject_request_pool total_count: %s reject_count: %s", threadPoolExecutor.getPoolSize(), count); } else { return null; } } }
@Override public String statisticCallback() { int count = rejectCounter.getAndSet(0); if (count > 0) { return String.format("type: motan name: reject_request total_count: %s reject_count: %s", totalCounter.get(), count); } else { return null; } } }
@Override public String statisticCallback() { int count = rejectCounter.getAndSet(0); if (count > 0) { return String.format("type: motan name: reject_request_pool total_count: %s reject_count: %s", threadPoolExecutor.getPoolSize(), count); } else { return null; } } }
@Override public void onNext(Notification<T> args) { if (waiting.getAndSet(0) == 1 || !args.isOnNext()) { Notification<T> toOffer = args; while (!buf.offer(toOffer)) { Notification<T> concurrentItem = buf.poll(); // in case if we won race condition with onComplete/onError method if (concurrentItem != null && !concurrentItem.isOnNext()) { toOffer = concurrentItem; } } } }
@Override public void onNext(Notification<T> args) { if (waiting.getAndSet(0) == 1 || !args.isOnNext()) { Notification<T> toOffer = args; while (!buf.offer(toOffer)) { Notification<T> concurrentItem = buf.poll(); // in case if we won race condition with onComplete/onError method if (concurrentItem != null && !concurrentItem.isOnNext()) { toOffer = concurrentItem; } } } }
public void cleanup() { int leakedSplits = localPartitionedSplitCount.getAndSet(0); if (leakedSplits == 0) { return; } log.error("BUG! %s for %s leaked with %s partitioned splits. Cleaning up so server can continue to function.", getClass().getName(), taskId, leakedSplits); nodeTotalPartitionedSplitCount.addAndGet(-leakedSplits); }
@Override public Object getState() { LOG.debug("Getting metrics for client connection to {}", dstAddressPrefixedName); HashMap<String, Object> ret = new HashMap<String, Object>(); ret.put("reconnects", totalConnectionAttempts.getAndSet(0)); ret.put("sent", messagesSent.getAndSet(0)); ret.put("pending", pendingMessages.get()); ret.put("lostOnSend", messagesLost.getAndSet(0)); ret.put("dest", dstAddress.toString()); String src = srcAddressName(); if (src != null) { ret.put("src", src); } return ret; }
static ViewNodeInfo acquire() { final ViewNodeInfo viewNodeInfo = ComponentsPools.acquireViewNodeInfo(); if (viewNodeInfo.mReferenceCount.getAndSet(1) != 0) { throw new IllegalStateException("The ViewNodeInfo reference acquired from the pool " + " wasn't correctly released."); } return viewNodeInfo; }
static NodeInfo acquire() { final NodeInfo nodeInfo = ComponentsPools.acquireNodeInfo(); if (nodeInfo.mReferenceCount.getAndSet(1) != 0) { throw new IllegalStateException("The NodeInfo reference acquired from the pool " + " wasn't correctly released."); } return nodeInfo; }
@Override public void onNext(Notification<T> args) { if (waiting.getAndSet(0) == 1 || !args.isOnNext()) { Notification<T> toOffer = args; while (!buf.offer(toOffer)) { Notification<T> concurrentItem = buf.poll(); // in case if we won race condition with onComplete/onError method if (concurrentItem != null && !concurrentItem.isOnNext()) { toOffer = concurrentItem; } } } }
@Override public void onNext(Notification<T> args) { if (waiting.getAndSet(0) == 1 || !args.isOnNext()) { Notification<T> toOffer = args; while (!buf.offer(toOffer)) { Notification<T> concurrentItem = buf.poll(); // in case if we won race condition with onComplete/onError method if (concurrentItem != null && !concurrentItem.isOnNext()) { toOffer = concurrentItem; } } } }
public synchronized void removeProvider(Provider<?> provider) { String serviceKey = MotanFrameworkUtil.getServiceKey(provider.getUrl()); providers.remove(serviceKey); List<Method> methods = ReflectUtil.getPublicMethod(provider.getInterface()); int publicMethodCount = methods.size(); methodCounter.getAndSet(methodCounter.get() - publicMethodCount); LoggerUtil.info("RequestRouter removeProvider: url=" + provider.getUrl() + " all_public_method_count=" + methodCounter.get()); }
public void clear() { fullyLock(); try { for (Node<E> p, h = head; (p = h.next) != null; h = p) { h.next = h; p.setValue(null); } head = last; // assert head.item == null && head.next == null; if (count.getAndSet(0) == capacity) notFull.signal(); } finally { fullyUnlock(); } }
@Override public void progress( ImportStage stage, int percent ) { if ( percent > 100 ) { fail( "Expected percentage to be 0..100% but was " + percent ); } AtomicInteger stageProgress = progress.computeIfAbsent( stage, s -> new AtomicInteger() ); int previous = stageProgress.getAndSet( percent ); if ( previous > percent ) { fail( "Progress should go forwards only, but went from " + previous + " to " + percent ); } }