in server/src/main/java/org/apache/cassandra/sidecar/cluster/CassandraAdapterDelegate.java [242:290]
protected void nativeProtocolHealthCheck()
{
Session activeSession;
try
{
activeSession = cqlSessionProvider.get();
}
catch (CassandraUnavailableException cue)
{
LOGGER.info("No local CQL session is available for cassandraInstanceId={}. " +
"Cassandra instance is down presumably.", cassandraInstanceId);
markNativeDownAndMaybeNotifyDisconnection();
return;
}
maybeRegisterHostListener(activeSession);
try
{
// NOTE: We cannot use `executeLocal` here as there may be no adapter yet.
SimpleStatement healthCheckStatement = new SimpleStatement("SELECT release_version FROM system.local");
Metadata metadata = activeSession.getCluster().getMetadata();
host = getHost(metadata);
if (host == null)
{
LOGGER.warn("Could not find host in cluster metadata by address and port {}",
localNativeTransportAddress);
return;
}
healthCheckStatement.setHost(host);
healthCheckStatement.setConsistencyLevel(ConsistencyLevel.ONE);
Row row = activeSession.execute(healthCheckStatement).one();
// This should never happen but added for completeness
Preconditions.checkArgument(row != null, "Session execution result should never be null");
if (isNativeUp.compareAndSet(false, true))
{
notifyNativeConnection();
}
}
catch (IllegalArgumentException | NoHostAvailableException e)
{
LOGGER.debug("Unexpected error querying Cassandra instance {}", cassandraInstanceId, e);
// The cassandra native protocol connection to the node is down.
markNativeDownAndMaybeNotifyDisconnection();
// Unregister the host listener.
maybeUnregisterHostListener(activeSession);
}
}