本文整理汇总了Java中com.couchbase.client.java.CouchbaseCluster类的典型用法代码示例。如果您正苦于以下问题:Java CouchbaseCluster类的具体用法?Java CouchbaseCluster怎么用?Java CouchbaseCluster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CouchbaseCluster类属于com.couchbase.client.java包,在下文中一共展示了CouchbaseCluster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
private void run(String[] args) throws InterruptedException, InvalidTaskTypeException {
nodes = Arrays.asList("192.168.4.246", "192.168.4.247", "192.168.4.248");
couchbaseEnvironment = DefaultCouchbaseEnvironment.builder().build();
clusterCouchbase = CouchbaseCluster.create(couchbaseEnvironment, nodes);
proteusBucket = clusterCouchbase.openBucket("proteus");
for (KafkaTopics topic : KafkaTopics.values()) {
Properties runnerProperties = new Properties();
runnerProperties = ConsumerUtils.loadPropertiesFromFile(PROPERTIES_FILE);
runnerProperties.put("eu.proteus.kafkaTopic", topic.name());
runners.add(new Runner(runnerProperties, proteusBucket));
}
if (!service.isShutdown()) {
for (Runner runner : runners) {
Thread t = new Thread(runner);
t.start();
// service.execute(runner);
}
}
service.shutdownNow();
}
示例2: initialize
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
/**
* Start initializing the client. This will schedule a task that retries
* connection until successful.
*/
public void initialize() {
try {
logger.debug("Trying to connect to couchbase bucket {}", bucketName);
cluster = CouchbaseCluster.create(new ArrayList<>(nodes));
bucket = cluster.openBucket(bucketName, password, timeout, TimeUnit.SECONDS);
logger.info("Connected to Couchbase bucket {}.", bucketName);
if (views != null) {
doEnsureIndexes(designDocument, views);
}
} catch (final Exception e) {
throw new RuntimeException("Failed to connect to Couchbase bucket", e);
}
}
示例3: initialize
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
/**
* Start initializing the client. This will schedule a task that retries
* connection until successful.
*/
public void initialize() {
try {
LOGGER.debug("Trying to connect to couchbase bucket [{}]", this.bucketName);
this.cluster = CouchbaseCluster.create(new ArrayList<>(this.nodes));
this.bucket = this.cluster.openBucket(this.bucketName, this.password, this.timeout, TimeUnit.SECONDS);
LOGGER.info("Connected to Couchbase bucket [{}]", this.bucketName);
if (this.views != null) {
doEnsureIndexes(this.designDocument, this.views);
}
} catch (final Exception e) {
throw new RuntimeException("Failed to connect to Couchbase bucket", e);
}
}
示例4: testSimple
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
@Test
public void testSimple() throws Exception {
CouchbaseCluster cc = couchbase.geCouchbaseCluster();
ClusterManager cm = cc.clusterManager("Administrator","password");
List<BucketSettings> buckets = cm.getBuckets();
Assert.assertNotNull(buckets);
Assert.assertTrue(buckets.size() == 3);
BucketSettings settings = DefaultBucketSettings.builder()
.enableFlush(true).name("default").quota(100).replicas(0).type(BucketType.COUCHBASE).build();
settings = cm.insertBucket(settings);
CouchbaseWaitStrategy s = new CouchbaseWaitStrategy();
s.withBasicCredentials("Administrator", "password");
s.waitUntilReady(couchbase);
Bucket bucket = cc.openBucket("default");
Assert.assertNotNull(bucket);
}
示例5: beerBucketTest
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
@Test
public void beerBucketTest() throws InterruptedException {
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()
.bootstrapCarrierDirectPort(couchbase.getMappedPort(11210))
.bootstrapCarrierSslPort(couchbase.getMappedPort(11207))
.bootstrapHttpDirectPort(couchbase.getMappedPort(8091))
.bootstrapHttpSslPort(couchbase.getMappedPort(18091))
.build();
CouchbaseCluster cc = CouchbaseCluster.create(env);
ClusterManager cm = cc.clusterManager("Administrator", "password");
assertTrue(cm.hasBucket("beer-sample"));
Bucket bucket = cc.openBucket("beer-sample");
assertTrue(bucket.exists("21st_amendment_brewery_cafe"));
bucket.close();
}
示例6: couchbaseCluster
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
@Provides
@Singleton
protected CouchbaseCluster couchbaseCluster(Config config) {
LOGGER.info("Creating CouchbaseCluster");
final CouchbaseCluster cluster = CouchbaseCluster.create(
DefaultCouchbaseEnvironment.builder().build(),
config.getHosts()
);
// The ratpack Service.stop() api isn't called on JVM exit, and it's very important to free the cluster, so...
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
LOGGER.info("Disconnecting CouchbaseCluster");
cluster.disconnect();
}));
initBuckets(config, cluster);
return cluster;
}
示例7: connect
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
@Override
public void connect(ServerConfiguration serverConfiguration) {
CouchbaseCluster cluster = CouchbaseCluster.create(serverConfiguration.getServerUrl());
String userDatabase = serverConfiguration.getUserDatabase();
Bucket bucket = null;
try {
if (StringUtils.isEmpty(userDatabase)) {
bucket = cluster.openBucket();
} else {
bucket = cluster.openBucket(userDatabase);
}
} catch (Exception ex) {
throw new ConfigurationException(ex);
} finally {
if (bucket != null) {
bucket.close();
}
cluster.disconnect();
}
}
示例8: CouchbaseCacheManager
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
/**
* Creates a new CouchbaseCacheManager.
*
* @param provider the caching provider used
* @param uri the uri of the manager
* @param classLoader the classloader associated with the manager
* @param properties the properties used by the manager
*/
public CouchbaseCacheManager(CouchbaseCachingProvider provider, URI uri, ClassLoader classLoader,
Properties properties) {
this.provider = provider;
this.uri = uri;
this.classLoader = new WeakReference<ClassLoader>(classLoader);
this.properties = properties;
this.caches = new HashMap<String, Cache>();
// this.isClosed defaults to false
if (provider.getEnvironment() == null) {
this.cluster = CouchbaseCluster.create(provider.getBoostrap());
} else {
this.cluster = CouchbaseCluster.create(provider.getEnvironment(), provider.getBoostrap());
}
}
示例9: main
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().build();
clusterCouchbase = CouchbaseCluster.create(env, "192.168.4.246", "192.168.4.247", "192.168.4.248");
proteusBucket = clusterCouchbase.openBucket("proteus-testing");
String coil = "40101001";
DocumentFragment<Lookup> resultHSM = proteusBucket.lookupIn(coil).get("proteus-hsm").execute();
DocumentFragment<Lookup> resultFlatness = proteusBucket.lookupIn(coil).get("proteus-flatness").execute();
DocumentFragment<Lookup> resultRealtime = proteusBucket.lookupIn(coil).get("proteus-realtime").execute();
System.out.println("Resultado para la bobina < " + "40101022" + " > | < HSM > " + resultHSM.size()
+ " | < Flantess > " + resultFlatness.size() + " | < Realtime > " + resultRealtime.size());
// System.out.println(resultRealtime.toString());
// Thread.sleep(3000);
// System.out.println(resultFlatness.toString());
// Thread.sleep(3000);
System.out.println(resultHSM.toString());
Thread.sleep(3000);
ArrayList<String> coils = new ArrayList<String>();
coils.add("40101022");
coils.add("40101018");
for (String bobina : coils) {
CouchbaseUtils.checkDataInserted(bobina, proteusBucket);
}
}
示例10: provideCluster
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
@Provides
@Singleton
public Cluster provideCluster(Properties properties) {
String clusterLocation = Optional.ofNullable(properties.getProperty(COUCHBASE_CLUSTER_LOCATION_PROPERTY_KEY))
.orElseThrow(() -> new RuntimeException("Missing cluster location in property file, key : " + COUCHBASE_CLUSTER_LOCATION_PROPERTY_KEY));
return CouchbaseCluster.create(clusterLocation);
}
示例11: loadJSONDocumentsTest
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
@Test
public void loadJSONDocumentsTest()
{
System.out.println("starting db...");
Cluster cluster = CouchbaseCluster.create();
System.out.println("creted db...");
System.out.println("opening bucket...");
Bucket defaultBucket = cluster.openBucket("default");
System.out.println("opened bucket...");
SpotifyCouchbaseLoader loader = new SpotifyCouchbaseLoader();
String u2ArtistId = "51Blml2LZPmy7TTiAg47vQ";
loader.loadJson(defaultBucket, u2ArtistId);
//Get JSON Document "albums"
JsonDocument jsonDocument = defaultBucket.get("albums");
cluster.disconnect();
//Check if JSON Document "albums" is loaded
Assert.assertNotNull(jsonDocument);
Object items = jsonDocument.content().get("items");
Assert.assertNotNull(items);
}
示例12: main
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
public static void main(String... args) throws Exception {
CouchbaseCluster cluster = CouchbaseCluster.create("127.0.0.1");
Bucket bucket = cluster.openBucket("default");
while (true) {
for (int i = 0; i < 1024; i++) {
bucket.upsert(JsonDocument.create("doc:" + i, JsonObject.create().put("uuid", UUID.randomUUID().toString())));
Thread.sleep(1000);
}
}
}
示例13: apply
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
try {
this.environment = DefaultCouchbaseEnvironment.create();
this.cluster = CouchbaseCluster.create(this.environment, "localhost");
testConnection(this.cluster);
return new CouchbaseStatement(base, this.environment, this.cluster);
}
catch (Exception ex) {
logger.info("No couchbase server available");
return new SkipStatement();
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:CouchbaseTestServer.java
示例14: CouchbaseSongStore
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
public CouchbaseSongStore() {
String cbServers = System.getProperty(SERVERS_PROPERTY, "localhost");
String bucketName = System.getProperty(BUCKET_NAME_PROPERTY, "default");
String password = System.getProperty(PASSWORD_PROPERTY, "");
cluster = CouchbaseCluster.create(cbServers);
bucket = cluster.openBucket(bucketName, password);
}
示例15: getCluster
import com.couchbase.client.java.CouchbaseCluster; //导入依赖的package包/类
public CouchbaseCluster getCluster() {
if (null == cluster) {
logger.log("env: " + System.getenv("COUCHBASE_HOST"));
cluster = CouchbaseCluster.create(System.getenv("COUCHBASE_HOST"));
}
return cluster;
}