import akka.actor.ActorRef;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;
entry.complete(envelope.getMessage());
}
}
+
+ @Override
+ public final String toString() {
+ return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
+ }
+
+ ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+ return toStringHelper.add("client", context.getIdentifier()).add("cookie", cookie).add("poisoned", poisoned);
+ }
}
return;
}
- LOG.debug("{}: resolved shard {} to {}", persistenceId(), shard, backend);
+ LOG.info("{}: resolved shard {} to {}", persistenceId(), shard, backend);
final long stamp = connectionsLock.writeLock();
try {
// Create a new connected connection
final ConnectedClientConnection<T> newConn = new ConnectedClientConnection<>(conn.context(),
conn.cookie(), backend);
- LOG.debug("{}: resolving connection {} to {}", persistenceId(), conn, newConn);
+ LOG.info("{}: resolving connection {} to {}", persistenceId(), conn, newConn);
// Start reconnecting without the old connection lock held
final ConnectionConnectCohort cohort = Verify.verifyNotNull(connectionUp(newConn));
// Make sure new lookups pick up the new connection
connections.replace(shard, conn, newConn);
- LOG.debug("{}: replaced connection {} with {}", persistenceId(), conn, newConn);
+ LOG.info("{}: replaced connection {} with {}", persistenceId(), conn, newConn);
} finally {
connectionsLock.unlockWrite(stamp);
}
void reconnectConnection(final ConnectedClientConnection<?> oldConn,
final ReconnectingClientConnection<?> newConn) {
final ReconnectingClientConnection<T> conn = (ReconnectingClientConnection<T>)newConn;
- connections.replace(oldConn.cookie(), (AbstractClientConnection<T>)oldConn, conn);
- LOG.debug("{}: connection {} reconnecting as {}", persistenceId(), oldConn, newConn);
+ LOG.info("{}: connection {} reconnecting as {}", persistenceId(), oldConn, newConn);
+
+ final boolean replaced = connections.replace(oldConn.cookie(), (AbstractClientConnection<T>)oldConn, conn);
+ if (!replaced) {
+ final AbstractClientConnection<T> existing = connections.get(oldConn.cookie());
+ LOG.warn("{}: old connection {} does not match existing {}, new connection {} in limbo", persistenceId(),
+ oldConn, existing, newConn);
+ }
final Long shard = oldConn.cookie();
+ LOG.info("{}: refreshing backend for shard {}", persistenceId(), shard);
resolver().refreshBackendInfo(shard, conn.getBackendInfo().get()).whenComplete(
(backend, failure) -> context().executeInActor(behavior -> {
backendConnectFinished(shard, conn, backend, failure);