private void healthCheckInternal()

in common/src/main/java/org/apache/cassandra/sidecar/common/CassandraAdapterDelegate.java [114:158]


    private void healthCheckInternal()
    {
        Session activeSession = cqlSessionProvider.localCql();
        if (activeSession == null)
        {
            logger.info("No local CQL session is available. Cassandra is down presumably.");
            nodeSettings = null;
            return;
        }

        maybeRegisterHostListener(activeSession);

        try
        {
            Row oneResult = activeSession.execute("select release_version, partitioner from system.local")
                                         .one();

            // Note that within the scope of this method, we should keep on using the local releaseVersion
            String releaseVersion = oneResult.getString("release_version");
            NodeSettings newNodeSettings = new NodeSettings(releaseVersion,
                                                            oneResult.getString("partitioner"),
                                                            sidecarVersion);
            if (!newNodeSettings.equals(nodeSettings))
            {
                // Update the nodeSettings cache
                SimpleCassandraVersion previousVersion = currentVersion;
                currentVersion = SimpleCassandraVersion.create(releaseVersion);
                adapter = versionProvider.cassandra(releaseVersion)
                                         .create(cqlSessionProvider, jmxClient);
                nodeSettings = newNodeSettings;
                logger.info("Cassandra version change detected (from={} to={}). New adapter loaded={}",
                            previousVersion, currentVersion, adapter);
            }
            logger.debug("Cassandra version {}", releaseVersion);
        }
        catch (IllegalArgumentException | NoHostAvailableException e)
        {
            logger.error("Unexpected error connecting to Cassandra instance.", e);
            // The cassandra node is down.
            // Unregister the host listener and nullify the session in order to get a new object.
            nodeSettings = null;
            maybeUnregisterHostListener(activeSession);
            cqlSessionProvider.close();
        }
    }