private CouchbaseCluster createCouchbaseCluster() { return CouchbaseCluster.create(getCouchbaseEnvironment(), getContainerIpAddress()); }
public CouchbaseWriter(CouchbaseEnvironment couchbaseEnvironment, Config config) { List<String> hosts = ConfigUtils.getStringList(config, CouchbaseWriterConfigurationKeys.BOOTSTRAP_SERVERS); String password = ConfigUtils.getString(config, CouchbaseWriterConfigurationKeys.PASSWORD, ""); String bucketName = ConfigUtils.getString(config, CouchbaseWriterConfigurationKeys.BUCKET, CouchbaseWriterConfigurationKeys.BUCKET_DEFAULT); _cluster = CouchbaseCluster.create(couchbaseEnvironment, hosts); if(!password.isEmpty()) { _bucket = _cluster.openBucket(bucketName, password, Collections.<Transcoder<? extends Document, ?>>singletonList(_tupleDocumentTranscoder)); } else { _bucket = _cluster.openBucket(bucketName, Collections.<Transcoder<? extends Document, ?>>singletonList(_tupleDocumentTranscoder)); } _operationTimeout = ConfigUtils.getLong(config, CouchbaseWriterConfigurationKeys.OPERATION_TIMEOUT_MILLIS, CouchbaseWriterConfigurationKeys.OPERATION_TIMEOUT_DEFAULT); _operationTimeunit = TimeUnit.MILLISECONDS; _defaultWriteResponseMapper = new GenericWriteResponseWrapper<>(); log.info("Couchbase writer configured with: hosts: {}, bucketName: {}, operationTimeoutInMillis: {}", hosts, bucketName, _operationTimeout); }
cluster = CouchbaseCluster.create(env, host); bucket = cluster.openBucket(bucketName, bucketPassword); kvTimeout = env.kvTimeout();
.connectTimeout(TimeUnit.SECONDS.toMillis(15)) .bootstrapCarrierEnabled(true).build(); CouchbaseCluster cbCluster = CouchbaseCluster.create(cbEnv, "localhost"); Bucket bucket = cbCluster.openBucket("default",""); try {
@Override protected boolean initiateClient() { for (String host : hosts) { if (host == null) { LOGGER.error("Host Name should not be null."); throw new IllegalArgumentException("Host Name should not be null."); } } cluster = CouchbaseCluster.create(hosts); if (userName != null && password != null) { clusterManager = cluster.clusterManager(userName, password); } else { clusterManager = cluster.clusterManager(); } return true; }
@Override public void initialize(Map<String, Object> puProperties) { reader = new CouchbaseEntityReader(kunderaMetadata); setExternalProperties(puProperties); initializePropertyReader(); PersistenceUnitMetadata pum = kunderaMetadata.getApplicationMetadata() .getPersistenceUnitMetadata(getPersistenceUnit()); Properties pumProps = pum.getProperties(); if (puProperties != null) { pumProps.putAll(puProperties); } String host = pumProps.getProperty("kundera.nodes"); String keyspace = pumProps.getProperty("kundera.keyspace"); if (host == null) { throw new KunderaException("Hostname/IP is null."); } if (keyspace == null) { throw new KunderaException("kundera.keyspace is null."); } cluster = CouchbaseCluster.create(splitHostNames(host)); String password = ((CouchbasePropertyReader) propertyReader).csmd.getBucketProperty("bucket.password"); bucket = CouchbaseBucketUtils.openBucket(cluster, keyspace, password); }
/** * Creates a new {@link CouchbaseCluster} reference against the nodes passed in. * * @param environment the custom environment to use for this cluster reference. * @param nodes the list of nodes to use when connecting to the cluster reference. * @return a new {@link CouchbaseCluster} reference. */ public static CouchbaseCluster create(final CouchbaseEnvironment environment, final String... nodes) { return create(environment, Arrays.asList(nodes)); }
/** * Creates a new {@link CouchbaseCluster} reference against the nodes passed in. * * The {@link CouchbaseEnvironment} will be automatically created and its lifecycle managed. * * @param nodes the list of nodes to use when connecting to the cluster reference. * @return a new {@link CouchbaseCluster} reference. */ public static CouchbaseCluster create(final String... nodes) { return create(Arrays.asList(nodes)); }
public static Cluster getCluster(String... hosts) { String firstHost = hosts[0]; if (!clusters.containsKey(firstHost)) { clusters.put(firstHost, CouchbaseCluster.create(environment, hosts)); } return clusters.get(firstHost); }
public CouchbaseConfiguration(final List<URI> urlList, final String bucketPassword, final String bucketName, final boolean createBucket) { this.urlList = urlList; this.bucketPassword = bucketPassword; this.bucketName = bucketName; this.couchbaseCluster = CouchbaseCluster.create( urlList.stream().map(URI::toString).collect(Collectors.toList()) ); this.createBucket = createBucket; }
/** * Creates a {@link DefaultCouchbaseBucketManagerFactory} from {@link CouchbaseEnvironment} * * @param environment the {@link CouchbaseEnvironment} * @return the new {@link DefaultCouchbaseBucketManagerFactory} instance * @throws NullPointerException when environment is null */ public CouchbaseBucketManagerFactory getManagerFactory(CouchbaseEnvironment environment) throws NullPointerException { Objects.requireNonNull(environment, "environment is required"); CouchbaseCluster couchbaseCluster = CouchbaseCluster.create(environment, nodes); return new DefaultCouchbaseBucketManagerFactory(couchbaseCluster, user, password); }
@Override public void connect(URI uri, String database, Map<String, Object> customOptions) { if (database == null) { database = "default"; } this.couchbaseCluster = CouchbaseCluster.create(uri.toString()); connectToBucket(database, customOptions); }
private void initializeCluster() { if (this.cluster != null) { shutdown(); } LOGGER.debug("Initializing Couchbase cluster for nodes [{}]", this.nodes); this.cluster = CouchbaseCluster.create(new ArrayList<>(this.nodes)); }
/** * Returns the {@link Cluster} instance to connect to. * * @throws Exception on Bean construction failure. */ @Override @Bean(destroyMethod = "disconnect", name = BeanNames.COUCHBASE_CLUSTER) public Cluster couchbaseCluster() throws Exception { return CouchbaseCluster.create(couchbaseEnvironment(), getBootstrapHosts()); }
/** * Returns the {@link Cluster} instance to connect to. * * @throws Exception on Bean construction failure. */ @Override @Bean(destroyMethod = "disconnect", name = BeanNames.COUCHBASE_CLUSTER) public Cluster couchbaseCluster() throws Exception { return CouchbaseCluster.create(couchbaseEnvironment(), getBootstrapHosts()); }
public CouchbaseCluster getCouchbaseCluster() { if (couchbaseCluster == null) { couchbaseCluster = CouchbaseCluster.create(getCouchbaseEnvironment(), getContainerIpAddress()); } return couchbaseCluster; }
public CouchbaseConnectionImpl(CouchbaseEnvironment environment, String connectionString, String keyspace, String password, TimeUnit timeUnit, String namespace, ScanConsistency scanConsistent){ this.scanConsistency = scanConsistent; this.cluster = CouchbaseCluster.create(environment, connectionString); if(password != null) { this.bucket = this.cluster.openBucket(keyspace, password, environment.connectTimeout(), timeUnit); } else { this.bucket = this.cluster.openBucket(keyspace, environment.connectTimeout(), timeUnit); } this.namespace = namespace; }
public static CouchbaseCluster createCluster(CouchbaseConfig config, CouchbaseEnvironment couchbaseEnvironment) { final CouchbaseCluster cluster = CouchbaseCluster.create(couchbaseEnvironment, config.hosts()); cluster.authenticate(config.username(), config.password()); return cluster; }
public CouchbaseConnectionImpl(CouchbaseEnvironment environment, String connectionString, String keyspace, String password, TimeUnit timeUnit, String namespace, ScanConsistency scanConsistent){ this.scanConsistency = scanConsistent; this.cluster = CouchbaseCluster.create(environment, connectionString); if(password != null) { this.bucket = this.cluster.openBucket(keyspace, password, environment.connectTimeout(), timeUnit); } else { this.bucket = this.cluster.openBucket(keyspace, environment.connectTimeout(), timeUnit); } this.namespace = namespace; }