private void checkDone() { if (_count.decrementAndGet() == 0) { if (_exceptions.isEmpty()) { _callback.onSuccess(None.none()); } else { _callback.onError(new MultiException(_exceptions)); } } } }
/** * Returns a new callback which defers invocation of another callback until a specified * number of onSuccess() or onError() calls to the new callback have occured. * * @param callback * the underlying callback * @param count * the number of combined onSuccess()/onError() calls that must be invoked on * the new callback before the underlying callback's onSuccess (if all were * successful) or onError (if any errors occurred) method is invoked. If count * is zero, the underlying callback's onSuccess will be invoked immediately on * the calling thread. * @return the new callback */ public static Callback<None> countDown(final Callback<None> callback, final int count) { if (count == 0) { callback.onSuccess(None.none()); return empty(); } return new MultiCallback(callback, count); }
@Override public void start(Callback<None> callback) { callback.onSuccess(None.none()); }
@Override public void onSuccess(None result) { LOG.info("D2 WarmUp completed"); startUpCallback.onSuccess(None.none()); } }, "This message will never be used, even in case of timeout, no exception should be passed up");
@Override public void start(final Callback<None> callback) { callback.onSuccess(None.none()); }
@Override public void onSuccess(None result) { LOG.info("EventBus Throttler sent all requests"); callback.onSuccess(None.none()); } }, "This message will never be used, even in case of timeout, no exception should be passed up");
/** * The standard {@link ChannelPoolManagerFactoryImpl} is stateless, and doesn't need to do any operation at shutdown */ @Override public void shutdown(Callback<None> callback) { callback.onSuccess(None.none()); } }
@Override public void onError(Throwable e) { LOG.info( "EventBus Throttler didn't send all requests in time, continuing startup. The WarmUp will continue in background"); callback.onSuccess(None.none()); }
@Override public void shutdown(Callback<None> callback) { callback.onSuccess(None.none()); } }
@Override public void shutdown(final Callback<None> callback) { callback.onSuccess(None.none()); }
private void finishShutdown(Callback<None> shutdown) { ScheduledFuture<?> future = _objectTimeoutFuture; if (future != null) { future.cancel(false); } LOG.info("{}: {}", _poolName, "shutdown complete"); shutdown.onSuccess(None.none()); }
@Override public void start(Callback<None> callback) { callback.onSuccess(None.none()); }
@Override public void onError(Throwable e) { LOG.info("D2 WarmUp hit timeout, continuing startup. The WarmUp will continue in background", e); startUpCallback.onSuccess(None.none()); }
/** * It executes a stub shutdown */ @Override public void shutdown(final Callback<None> callback, final Runnable callbackStopRequest, final Runnable callbackShutdown, long shutdownTimeout) { callbackStopRequest.run(); callbackShutdown.run(); callback.onSuccess(None.none()); }
@Override public void onSuccess(None none) { synchronized (_mutex) { _state = State.SHUTDOWN; } LOG.info("All connection pools shutdown"); callback.onSuccess(None.none()); }
/** * It's assumed that the Persistent connection has been started outside of this class */ @Override public void start(Callback<None> callback) { _afterStartupCallbacks.add(() -> callback.onSuccess(None.none())); fireAfterStartupCallbacks(); }
/** * Once initialized, start sending the requests. The callback will be called once all the requests returned * a result (which is published on the {@link #_externalSubscriber}). * * If the bus never returns all the values, the callback will be never called */ public void sendRequests(Callback<None> callback) { LOG.info("Event Bus Requests throttler started for {} keys at a {} load rate", _keysToFetch.size(), _maxConcurrentRequests); if (_keysToFetch.size() == 0) { callback.onSuccess(None.none()); return; } _callback = callback; makeRequests(_maxConcurrentRequests); }
@Override public void shutdown(Callback<None> shutdown) { info(_log, "shutting down"); shutdown.onSuccess(None.none()); }
private void drain(Deque<Callback<None>> callbacks, Throwable t) { for (;!callbacks.isEmpty();) { try { if (t != null) { callbacks.poll().onError(t); } else { callbacks.poll().onSuccess(None.none()); } } catch (Throwable throwable) { _log.error("Unexpected throwable from markUp/markDown callback.", throwable); } } }
@Override public void start(Callback<None> callback) { if (start()) { callback.onSuccess(None.none()); } else { callback.onError(new IOException("unable to create file path: " + _fsPath)); } }