protected void connectionClosed(ClientCnx cnx) {
if (CLIENT_CNX_UPDATER.compareAndSet(this, cnx, null)) {
if (!isValidStateForReconnection()) {
log.info("[{}] [{}] Ignoring reconnection request (state: {})", topic, getHandlerName(), STATE_UPDATER.get(this));
return;
}
long delayMs = backoff.next();
STATE_UPDATER.set(this, State.Connecting);
log.info("[{}] [{}] Closed connection {} -- Will try again in {} s", topic, getHandlerName(), cnx.channel(),
delayMs / 1000.0);
client.timer().newTimeout(timeout -> {
log.warn("[{}] [{}] Reconnecting after timeout", topic, getHandlerName());
grabCnx();
}, delayMs, TimeUnit.MILLISECONDS);
}
}