Java SDK A lot of connection / disconnection when starting


#1

Hi,

I am wondering why I can see the following logs when using the Java SDK everytime it is initialised

INFO] CouchbaseEnvironment: {sslEnabled=false, sslKeystoreFile='null', sslKeystorePassword='null', queryEnabled=false, queryPort=8093, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=8091, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=11210, bootstrapCarrierSslPort=11207, ioPoolSize=4, computationPoolSize=4, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=1, queryServiceEndpoints=1, searchServiceEndpoints=1, ioPool=NioEventLoopGroup, coreScheduler=CoreScheduler, eventBus=DefaultEventBus, packageNameAndVersion=couchbase-jvm-core/1.2.4 (git: 1.2.4), dcpEnabled=false, retryStrategy=BestEffort, maxRequestLifetime=75000, retryDelay=ExponentialDelay{growBy 1.0 MICROSECONDS; lower=100, upper=100000}, reconnectDelay=ExponentialDelay{growBy 1.0 MILLISECONDS; lower=32, upper=4096}, observeIntervalDelay=ExponentialDelay{growBy 1.0 MICROSECONDS; lower=10, upper=100000}, keepAliveInterval=30000, autoreleaseAfter=2000, bufferPoolingEnabled=true, tcpNodelayEnabled=true, mutationTokensEnabled=false, socketConnectTimeout=10000, dcpConnectionBufferSize=20971520, dcpConnectionBufferAckThreshold=0.2, queryTimeout=75000, viewTimeout=75000, kvTimeout=2500, connectTimeout=10000, disconnectTimeout=25000, dnsSrvEnabled=false} [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost [INFO] Disconnected from Node localhost [INFO] Connected to Node localhost

#2

Are you using a static Cluster object? Can you show your code in which you create the cluster?


#3

I am creating an environment and then creating the cluster using it…

The wrapper object doing this do not use a static cluster, but the wrapper could or not be used as a static object or not… But I can see the logs above in both cases.

Example code in the wrapper object method:

    DefaultCouchbaseEnvironment.Builder couchbaseEnvironmentBuilder = DefaultCouchbaseEnvironment.builder();

    if (null != kvTimeout) {
        couchbaseEnvironmentBuilder.kvTimeout(kvTimeout);
    }
    if (null != viewTimeout) {
        couchbaseEnvironmentBuilder.viewTimeout(viewTimeout);
    }
    if (null != queryTimeout) {
        couchbaseEnvironmentBuilder.queryTimeout(queryTimeout);
    }
    if (null != connectTimeout) {
        couchbaseEnvironmentBuilder.connectTimeout(connectTimeout);
    }
    if (null != disconnectTimeout) {
        couchbaseEnvironmentBuilder.disconnectTimeout(disconnectTimeout);
    }
    if (null != managementTimeout) {
        couchbaseEnvironmentBuilder.managementTimeout(managementTimeout);
    }
    if (null != maxRequestLifetime) {
        couchbaseEnvironmentBuilder.maxRequestLifetime(maxRequestLifetime);
    }
    if (null != autoreleaseAfter) {
        couchbaseEnvironmentBuilder.autoreleaseAfter(autoreleaseAfter);
    }
    if (null != socketConnectTimeout) {
        couchbaseEnvironmentBuilder.socketConnectTimeout(socketConnectTimeout);
    }
    if (null != kvEndpoints) {
        couchbaseEnvironmentBuilder.kvEndpoints(kvEndpoints);
    }
    if (null != viewEndpoints) {
        couchbaseEnvironmentBuilder.viewEndpoints(viewEndpoints);
    }
    if (null != queryEndpoints) {
        couchbaseEnvironmentBuilder.queryEndpoints(queryEndpoints);
    }
    if (null != kvEndpoints) {
        couchbaseEnvironmentBuilder.kvEndpoints(kvEndpoints);
    }
    if (null != viewEndpoints) {
        couchbaseEnvironmentBuilder.viewEndpoints(viewEndpoints);
    }
    if (null != queryEndpoints) {
        couchbaseEnvironmentBuilder.queryEndpoints(queryEndpoints);
    }
    this.couchbaseEnvironment = couchbaseEnvironmentBuilder.build();

    this.cluster = CouchbaseCluster.create(this.couchbaseEnvironment, couchbaseHosts);

#4

I did some more digging and it looks like the use of ClusterManager is the one outputting the Connected / Disconnected logs

Using the following example:

public class Test {

public static void main(String[] args) {
    DefaultCouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().build();
    CouchbaseCluster cluster = CouchbaseCluster.create(env, "localhost");
    ClusterManager clusterManager = cluster.clusterManager("admin", "password");

    if (clusterManager.hasBucket("myBucket")) {
        BucketSettings bucketSettings = clusterManager.getBucket("myBucket");
        Bucket bucket = cluster.openBucket("myBucket", "password");
        bucket.close();
    }

    cluster.disconnect();
}

}

creates the following output:

Mon 29 13:56:05 [main] INFO CouchbaseCore - CouchbaseEnvironment: {sslEnabled=false, sslKeystoreFile=‘null’, sslKeystorePassword=‘null’, queryEnabled=false, queryPort=8093, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=8091, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=11210, bootstrapCarrierSslPort=11207, ioPoolSize=4, computationPoolSize=4, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=1, queryServiceEndpoints=1, searchServiceEndpoints=1, ioPool=NioEventLoopGroup, coreScheduler=CoreScheduler, eventBus=DefaultEventBus, packageNameAndVersion=couchbase-jvm-core/1.2.4 (git: 1.2.4), dcpEnabled=false, retryStrategy=BestEffort, maxRequestLifetime=75000, retryDelay=ExponentialDelay{growBy 1.0 MICROSECONDS; lower=100, upper=100000}, reconnectDelay=ExponentialDelay{growBy 1.0 MILLISECONDS; lower=32, upper=4096}, observeIntervalDelay=ExponentialDelay{growBy 1.0 MICROSECONDS; lower=10, upper=100000}, keepAliveInterval=30000, autoreleaseAfter=2000, bufferPoolingEnabled=true, tcpNodelayEnabled=true, mutationTokensEnabled=false, socketConnectTimeout=1000, dcpConnectionBufferSize=20971520, dcpConnectionBufferAckThreshold=0.2, queryTimeout=75000, viewTimeout=75000, kvTimeout=2500, connectTimeout=5000, disconnectTimeout=25000, dnsSrvEnabled=false}
Mon 29 13:56:06 [cb-io-1-1] INFO Node - Connected to Node localhost
Mon 29 13:56:06 [cb-io-1-1] INFO Node - Disconnected from Node localhost
Mon 29 13:56:07 [cb-io-1-2] INFO Node - Connected to Node localhost
Mon 29 13:56:07 [cb-io-1-2] INFO Node - Disconnected from Node localhost
Mon 29 13:56:07 [cb-io-1-3] INFO Node - Connected to Node localhost
Mon 29 13:56:07 [cb-computations-3] INFO ConfigurationProvider - Opened bucket myBucket
Mon 29 13:56:07 [main] INFO ConfigurationProvider - Closed bucket myBucket
Mon 29 13:56:07 [cb-io-1-3] INFO Node - Disconnected from Node localhost

Basically, the line clusterManager.hasBucket(“myBucket”) creates 2 log entries, connected and disconnected, the same for clusterManager.getBucket(“myBucket”) and finally, the opening of the bucket just show 1 log of connected!

Is this intended to have the cluster manager connecting / disconnecting on every call?


#5

Yes this is normal behavior as we only keep the connection persistent when we prepare a Bucket reference. Note such a connection would be reused by the bucketManager if it was established beforehand for a Bucket.