in core/src/main/java/com/datastax/oss/driver/internal/core/metadata/NodeStateManager.java [131:170]
private void onChannelEvent(ChannelEvent event) {
assert adminExecutor.inEventLoop();
if (closeWasCalled) {
return;
}
LOG.debug("[{}] Processing {}", logPrefix, event);
DefaultNode node = (DefaultNode) event.node;
assert node != null;
switch (event.type) {
case OPENED:
node.openConnections += 1;
if (node.state == NodeState.DOWN || node.state == NodeState.UNKNOWN) {
setState(node, NodeState.UP, "a new connection was opened to it");
}
break;
case CLOSED:
node.openConnections -= 1;
if (node.openConnections == 0 && node.reconnections > 0) {
setState(node, NodeState.DOWN, "it was reconnecting and lost its last connection");
}
break;
case RECONNECTION_STARTED:
node.reconnections += 1;
if (node.openConnections == 0) {
setState(node, NodeState.DOWN, "it has no connections and started reconnecting");
}
break;
case RECONNECTION_STOPPED:
node.reconnections -= 1;
break;
case CONTROL_CONNECTION_FAILED:
// Special case for init, where this means that a contact point is down. In other
// situations that information is not really useful, we rely on
// openConnections/reconnections instead.
if (!isInitialized) {
setState(node, NodeState.DOWN, "it was tried as a contact point but failed");
}
break;
}
}