builder.ioPool(group, new IoPoolShutdownHook(group)); env = builder.build(); logParams();
.bootstrapCarrierDirectPort(serverPort) .connectTimeout(TimeUnit.SECONDS.toMillis(15)) .bootstrapCarrierEnabled(true).build(); CouchbaseCluster cbCluster = CouchbaseCluster.create(cbEnv, "localhost"); Bucket bucket = cbCluster.openBucket("default","");
private static DefaultCouchbaseEnvironment getEnv(String hostOrKey) { URI singleHostURI = checkAndGetURI(hostOrKey); DefaultCouchbaseEnvironment.Builder builder = DefaultCouchbaseEnvironment.builder(); builder.connectTimeout(Long.parseLong(getConfig("connectTimeout"))); builder.socketConnectTimeout(Integer.parseInt(getConfig("socketConnectTimeout"))); builder.kvTimeout(Integer.parseInt(getConfig("kvTimeout"))); builder.ioPoolSize(Integer.parseInt(getConfig("ioPoolSize"))); builder.computationPoolSize(Integer.parseInt(getConfig("computationPoolSize"))); if (singleHostURI == null || singleHostURI.getScheme() == null) { Map<String, Object> couchbaseConfig = getKeyMap(hostOrKey); Object port; if ((port = couchbaseConfig.get(PORT_CONFIG_KEY)) != null) { builder.bootstrapHttpDirectPort(Integer.parseInt(port.toString())); } } else { if (singleHostURI.getPort() != -1) { builder.bootstrapHttpDirectPort(singleHostURI.getPort()); } } return builder.build(); }
final CouchbaseEnvironment env = CouchbaseHelper.environmentBuilder(config.couchbase(), config.trustStore()).build(); final CouchbaseCluster cluster = CouchbaseHelper.createCluster(config.couchbase(), env);
.connectTimeout(connectTimeout) .dnsSrvEnabled(dnsSrvEnabled) .build();
.connectTimeout(connectTimeout) .dnsSrvEnabled(dnsSrvEnabled) .build();
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(); } }
@Bean(destroyMethod = "disconnect") @ConditionalOnProperty("store.enable") public Cluster couchbaseCluster( @Value("#{'${store.nodes:127.0.0.1}'.split(',')}") String... nodes) { CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder() .queryEnabled(useCouchbaseForFindAll) .build(); return CouchbaseCluster.create(env, nodes); }
@Override protected CouchbaseEnvironment createInstance() throws Exception { return couchbaseEnvBuilder.build(); }
@Override protected CouchbaseEnvironment createInstance() throws Exception { return couchbaseEnvBuilder.build(); }
@Override protected CouchbaseEnvironment getEnvironment() { return DefaultCouchbaseEnvironment.builder() .connectTimeout(10000) .kvTimeout(10000) .queryTimeout(10000) .viewTimeout(10000) .build(); }
public CouchbaseEnvironment getCouchbaseEnvironment() { if (couchbaseEnvironment == null) { initCluster(); couchbaseEnvironment = DefaultCouchbaseEnvironment.builder() .bootstrapCarrierDirectPort(getMappedPort(11210)) .bootstrapCarrierSslPort(getMappedPort(11207)) .bootstrapHttpDirectPort(getMappedPort(8091)) .bootstrapHttpSslPort(getMappedPort(18091)) .build(); } return couchbaseEnvironment; }
public CouchbaseConnection(String bootstrapNodes, String bucket, String password) { CouchbaseEnvironment environment = new DefaultCouchbaseEnvironment.Builder().connectTimeout(20000L).build(); this.cluster = CouchbaseCluster.create(environment, bootstrapNodes); this.bucketName = bucket; this.password = password; }
/** * CAVEAT: Only suitable for one-shot command-line tools, since this method * leaks a couchbase environment. That's bad, right? * * @deprecated Leaks the environment. Probably shouldn't use this. */ @Deprecated public static Bucket openBucket(CouchbaseConfig config, Supplier<KeyStore> keystore) { // xxx there's no way to shut down this environment :-/ final CouchbaseEnvironment env = environmentBuilder(config, keystore).build(); return createCluster(config, env).openBucket(config.bucket()); }
/** * Creates a {@link CouchbaseEnvironment} with default settings applied. * * @return a {@link DefaultCouchbaseEnvironment} with default settings. */ public static DefaultCouchbaseEnvironment create() { return builder().build(); }
@Before public void before() { ENV = DefaultCouchbaseEnvironment.builder().bootstrapHttpDirectPort(couchbase.getMappedPort(8091)).build(); }
return builder.build();
@BeforeSuite public void startServers() { _couchbaseTestServer = new CouchbaseTestServer(TestUtils.findFreePort()); _couchbaseTestServer.start(); _couchbaseEnvironment = DefaultCouchbaseEnvironment.builder().bootstrapHttpEnabled(true) .bootstrapHttpDirectPort(_couchbaseTestServer.getPort()) .bootstrapCarrierDirectPort(_couchbaseTestServer.getServerPort()).bootstrapCarrierEnabled(false) .kvTimeout(10000).build(); }
private DefaultCouchbaseEnvironment createCouchbaseEnvironment() { initCluster(); return DefaultCouchbaseEnvironment.builder() .kvTimeout(10000) .bootstrapCarrierDirectPort(getMappedPort(MEMCACHED)) .bootstrapCarrierSslPort(getMappedPort(MEMCACHED_SSL)) .bootstrapHttpDirectPort(getMappedPort(REST)) .bootstrapHttpSslPort(getMappedPort(REST_SSL)) .build(); }