/** * Disconnect from the Couchbase cluster. */ @OnDisabled public void shutdown() { if(cluster != null){ cluster.disconnect(); cluster = null; } }
private void stopCluster() { getCouchbaseCluster().disconnect(); getCouchbaseEnvironment().shutdown(); }
@Override public void dropSchema() { if (operation != null && ("create-drop").equalsIgnoreCase(operation)) { for (TableInfo tableInfo : tableInfos) { removeBucket(tableInfo.getTableName()); } } cluster.disconnect(); cluster = null; }
@Override public void destroy() { indexManager.close(); if (schemaManager != null) { schemaManager.dropSchema(); } if (bucket != null) { LOGGER.info("Closing bucket " + bucket.name() + "."); CouchbaseBucketUtils.closeBucket(bucket); LOGGER.info("Closed bucket " + bucket.name() + "."); } if (cluster != null) { LOGGER.info("Closing connection to couchbase."); cluster.disconnect(); LOGGER.info("Closed connection to couchbase."); } else { LOGGER.warn("Can't close connection to Couchbase, it was already disconnected"); } externalProperties = null; schemaManager = null; }
@Override public void close() { couchbaseCluster.disconnect(); } }
@Override public Boolean disconnect() { return disconnect(environment.disconnectTimeout(), TIMEOUT_UNIT); }
private static void run(ConnectorConfig config, boolean catchUp) throws IOException { final CouchbaseEnvironment env = environmentBuilder(config.couchbase(), config.trustStore()).build(); final CouchbaseCluster cluster = createCluster(config.couchbase(), env); try { final Bucket bucket = cluster.openBucket(config.couchbase().bucket()); final CouchbaseBucketConfig bucketConfig = getBucketConfig(bucket); final CheckpointDao checkpointDao = new CouchbaseCheckpointDao(bucket, config.group().name()); if (catchUp) { setCheckpointToNow(config, checkpointDao); System.out.println("Set checkpoint for connector '" + config.group().name() + "' to match current state of Couchbase bucket."); } else { final int numVbuckets = bucketConfig.numberOfPartitions(); final Set<Integer> vbuckets = IntStream.range(0, numVbuckets).boxed().collect(toSet()); checkpointDao.clear(bucketConfig.uuid(), vbuckets); System.out.println("Cleared checkpoint for connector '" + config.group().name() + "'."); } } finally { cluster.disconnect(); env.shutdown(); } }
dcpClient.disconnect().await(); checkpointExecutor.awaitTermination(10, SECONDS); cluster.disconnect();