Skip to content

Instantly share code, notes, and snippets.

@dejanb
Created November 18, 2013 16:35
Show Gist options
  • Select an option

  • Save dejanb/7530926 to your computer and use it in GitHub Desktop.

Select an option

Save dejanb/7530926 to your computer and use it in GitHub Desktop.
public final void handleTransportFailure(IOException e) throws InterruptedException {
if (LOG.isTraceEnabled()) {
LOG.trace(this + " handleTransportFailure: " + e);
}
synchronized (reconnectMutex) {
Transport transport = connectedTransport.getAndSet(null);
if (transport != null) {
disposeTransport(transport);
boolean reconnectOk = false;
if (canReconnect()) {
reconnectOk = true;
}
LOG.warn("Transport (" + transport.getRemoteAddress() + ") failed, reason: " + e
+ (reconnectOk ? "," : ", not") + " attempting to automatically reconnect");
initialized = false;
failedConnectTransportURI = connectedTransportURI;
connectedTransportURI = null;
connected = false;
connectedToPriority = false;
if (reconnectOk) {
// notify before any reconnect attempt so ack state can be whacked
if (transportListener != null) {
transportListener.transportInterupted();
}
updated.remove(failedConnectTransportURI);
reconnectTask.wakeup();
} else if (!isDisposed()) {
propagateFailureToExceptionListener(e);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment