@Override public void onConnectionClosed(Transport.Connection connection) { try { List<Transport.ResponseContext<? extends TransportResponse>> pruned = responseHandlers.prune(h -> h.connection().getCacheKey().equals(connection.getCacheKey())); // callback that an exception happened, but on a different thread since we don't // want handlers to worry about stack overflows getExecutorService().execute(() -> { for (Transport.ResponseContext holderToNotify : pruned) { holderToNotify.handler().handleException(new NodeDisconnectedException(connection.getNode(), holderToNotify.action())); } }); } catch (EsRejectedExecutionException ex) { logger.debug("Rejected execution on onConnectionClosed", ex); } }
@Override public void onConnectionClosed(Transport.Connection connection) { try { for (Map.Entry<Long, RequestHolder> entry : clientHandlers.entrySet()) { RequestHolder holder = entry.getValue(); if (holder.connection().getCacheKey().equals(connection.getCacheKey())) { final RequestHolder holderToNotify = clientHandlers.remove(entry.getKey()); if (holderToNotify != null) { // callback that an exception happened, but on a different thread since we don't // want handlers to worry about stack overflows threadPool.generic().execute(() -> holderToNotify.handler().handleException(new NodeDisconnectedException( connection.getNode(), holderToNotify.action()))); } } } } catch (EsRejectedExecutionException ex) { logger.debug("Rejected execution on onConnectionClosed", ex); } }
@Override public void onConnectionClosed(Transport.Connection connection) { try { List<Transport.ResponseContext> pruned = responseHandlers.prune(h -> h.connection().getCacheKey().equals(connection .getCacheKey())); // callback that an exception happened, but on a different thread since we don't // want handlers to worry about stack overflows getExecutorService().execute(() -> { for (Transport.ResponseContext holderToNotify : pruned) { holderToNotify.handler().handleException(new NodeDisconnectedException(connection.getNode(), holderToNotify.action())); } }); } catch (EsRejectedExecutionException ex) { logger.debug("Rejected execution on onConnectionClosed", ex); } }
@Override public Object getCacheKey() { return connection.getCacheKey(); } }