private <V> void stopOnFailure(final OperationFuture<V> future) { future.addListener( new Runnable() { @Override public void run() { try { future.get(); } catch (final Exception e) { LOG.error("ZK operation failed", e); zkFailure = true; decoratedService .stop() .addListener( new Runnable() { @Override public void run() { notifyFailed(e); } }, Threads.SAME_THREAD_EXECUTOR); } } }, Threads.SAME_THREAD_EXECUTOR); }
private static <V> OperationFuture<V> listenFailure(final OperationFuture<V> operationFuture) { operationFuture.addListener( new Runnable() { @Override public void run() { try { if (!operationFuture.isCancelled()) { operationFuture.get(); } } catch (Exception e) { // TODO: what could be done besides just logging? LOG.error("Operation execution failed for " + operationFuture.getRequestPath(), e); } } }, Threads.SAME_THREAD_EXECUTOR); return operationFuture; }