public synchronized Session localCql()

in common/src/main/java/org/apache/cassandra/sidecar/common/CQLSessionProvider.java [89:127]


    public synchronized Session localCql()
    {
        Cluster cluster = null;
        try
        {
            if (localSession == null)
            {
                logger.info("Connecting to {}", inet);
                cluster = Cluster.builder()
                                 .addContactPointsWithPorts(inet)
                                 .withLoadBalancingPolicy(wlp)
                                 .withQueryOptions(queryOptions)
                                 .withReconnectionPolicy(reconnectionPolicy)
                                 .withoutMetrics()
                                 // tests can create a lot of these Cluster objects, to avoid creating HWTs and
                                 // event thread pools for each we have the override
                                 .withNettyOptions(nettyOptions)
                                 .build();
                localSession = cluster.connect();
                logger.info("Successfully connected to Cassandra instance!");
            }
        }
        catch (Exception e)
        {
            logger.error("Failed to reach Cassandra", e);
            if (cluster != null)
            {
                try
                {
                    cluster.close();
                }
                catch (Exception ex)
                {
                    logger.error("Failed to close cluster in cleanup", ex);
                }
            }
        }
        return localSession;
    }