@Override public void onComplete(ClientResponse response) { this.response = response; pendingCompletion.add(this); } }
public void onFailure(RuntimeException e) { this.e = e; pendingCompletion.add(this); }
public void put(Node node, ClientRequest request) { // the lock protects the put from a concurrent removal of the queue for the node synchronized (unsent) { ConcurrentLinkedQueue<ClientRequest> requests = unsent.get(node); if (requests == null) { requests = new ConcurrentLinkedQueue<>(); unsent.put(node, requests); } requests.add(request); } }
@Override void dispatch(Object event, Iterator<Subscriber> subscribers) { checkNotNull(event); while (subscribers.hasNext()) { queue.add(new EventWithSubscriber(event, subscribers.next())); } EventWithSubscriber e; while ((e = queue.poll()) != null) { e.subscriber.dispatchEvent(e.event); } }
@Override public boolean add(E e) { this.makeSpaceIfNotAvailable(); return super.add(e); }
@Subscribe public void handleString(String string) { dispatchedSubscribers.add(this); }
@Override public Void call() { order.add(-1); finishLatch.countDown(); return null; } }
@Override public Void call() { order.add(2); finishLatch.countDown(); return null; } }
@Override public Void call() { order.add(0); finishLatch.countDown(); return null; } }
@Override void dispatch(Object event, Iterator<Subscriber> subscribers) { checkNotNull(event); while (subscribers.hasNext()) { queue.add(new EventWithSubscriber(event, subscribers.next())); } EventWithSubscriber e; while ((e = queue.poll()) != null) { e.subscriber.dispatchEvent(e.event); } }
@Override public void onSuccess(Void value) { if (interceptors != null) interceptors.onCommit(offsets); completedOffsetCommits.add(new OffsetCommitCompletion(cb, offsets, null)); }
@Override public void onFailure(RuntimeException e) { Exception commitException = e; if (e instanceof RetriableException) commitException = new RetriableCommitFailedException(e); completedOffsetCommits.add(new OffsetCommitCompletion(cb, offsets, commitException)); } });
@Subscribe public void handleInteger(Integer integer) { dispatchedSubscribers.add(this); dispatcher.dispatch("hello", stringSubscribers.iterator()); }
@Override public void onFailure(RuntimeException e) { pendingAsyncCommits.decrementAndGet(); completedOffsetCommits.add(new OffsetCommitCompletion(callback, offsets, new RetriableCommitFailedException(e))); } });
@Override protected void doNext(Publisher<? extends T> ev) { queue.add(Signal.<Publisher<? extends T>>next(ev)); if(WIP_UPDATER.getAndIncrement(this) == 0){ subscribeNext(); } }
@Override public void writeRecord(String record){ writeCalls.add(1); counter.add(1); } }
/** * Add a listener which will be notified when the future completes * @param listener non-null listener to add */ public void addListener(RequestFutureListener<T> listener) { this.listeners.add(listener); if (failed()) fireFailure(); else if (succeeded()) fireSuccess(); }
private void tryRecoverCurrentBatch(Integer failedBatchNumber) { log.info("Trying to recover currentBatch"); long nextBatchNumber = ConcurrentAwaitableCounter.nextCount(failedBatchNumber); byte[] newBuffer = acquireBuffer(); if (concurrentBatch.compareAndSet(failedBatchNumber, new Batch(this, newBuffer, nextBatchNumber))) { log.info("Successfully recovered currentBatch"); } else { // It's normal, a concurrent thread could succeed to recover first. buffersToReuse.add(newBuffer); } }
@Override public void onComplete() { try { queue.add(Signal.<Publisher<? extends T>>complete()); if (WIP_UPDATER.getAndIncrement(this) == 0) { subscribeNext(); } } catch (Exception e) { doError(e); } }
public void endInput() { for (int i = 0; i < numInputChannels; i++) { synchronized (inputQueues[i]) { inputQueues[i].add(InputValue.streamEnd()); inputQueues[i].notifyAll(); } inputGate.notifyChannelNonEmpty(inputChannels[i]); } }