本文整理汇总了Java中com.couchbase.client.java.Cluster.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Java Cluster.disconnect方法的具体用法?Java Cluster.disconnect怎么用?Java Cluster.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.couchbase.client.java.Cluster
的用法示例。
在下文中一共展示了Cluster.disconnect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadJSONDocumentsTest
import com.couchbase.client.java.Cluster; //导入方法依赖的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);
}
示例2: loadRecords
import com.couchbase.client.java.Cluster; //导入方法依赖的package包/类
public CouchbaseResult loadRecords(ServerConfiguration configuration, CouchbaseDatabase database, CouchbaseQuery couchbaseQuery) {
Cluster cluster = CouchbaseCluster.create(DefaultCouchbaseEnvironment
.builder()
.queryEnabled(true)
.build(),
configuration.getServerUrl());
// AuthenticationSettings authenticationSettings = configuration.getAuthenticationSettings();
// ClusterManager clusterManager = cluster.clusterManager(authenticationSettings.getUsername(), authenticationSettings.getPassword());
Bucket beerBucket = cluster.openBucket(database.getName(), 10, TimeUnit.SECONDS);
N1qlQueryResult queryResult = beerBucket.query(N1qlQuery.simple(select("*").from(i(database.getName())).limit(couchbaseQuery.getLimit())));
//TODO dirty zone :(
CouchbaseResult result = new CouchbaseResult(database.getName());
List<JsonObject> errors = queryResult.errors();
if (!errors.isEmpty()) {
cluster.disconnect();
result.addErrors(errors);
return result;
}
for (N1qlQueryRow row : queryResult.allRows()) {
result.add(row.value());
}
cluster.disconnect();
return result;
}
示例3: main
import com.couchbase.client.java.Cluster; //导入方法依赖的package包/类
public static void main(String[] args) {
Cluster cluster = CouchbaseCluster.create(DefaultCouchbaseEnvironment
.builder()
.queryEnabled(true)
.build());
Bucket defaultBucket = cluster.openBucket("default");
defaultBucket.remove("user:walter");
JsonArray friends = JsonArray.empty()
.add(JsonObject.empty().put("name", "Mike Ehrmantraut"))
.add(JsonObject.empty().put("name", "Jesse Pinkman"));
JsonObject content = JsonObject.empty()
.put("firstname", "Walter")
.put("lastname", "White")
.put("age", 52)
.put("aliases", JsonArray.from("Walt Jackson", "Mr. Mayhew", "David Lynn"))
.put("friends", friends);
JsonDocument walter = JsonDocument.create("user:walter", content);
JsonDocument inserted = defaultBucket.insert(walter);
JsonDocument foundGuy = defaultBucket.get("user:walter");
System.out.println(foundGuy.content().toMap());
Bucket beerBucket = cluster.openBucket("beer-sample");
N1qlQueryResult result = beerBucket.query(N1qlQuery.simple(select("*").from(i("beer-sample")).limit(10)));
System.out.println("Errors found: " + result.errors());
for (N1qlQueryRow row : result.allRows()) {
JsonObject jsonObject = row.value();
System.out.println(jsonObject.toMap());
}
cluster.disconnect();
}
示例4: shouldTraceChangesOnCouchbase
import com.couchbase.client.java.Cluster; //导入方法依赖的package包/类
@Test
public void shouldTraceChangesOnCouchbase() {
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().dcpEnabled(true).build();
Cluster cluster = CouchbaseCluster.create(env);
CouchbaseEventDispatcher couchbaseEventHandler = new CouchbaseEventDispatcher(cluster.core(), "default",
Arrays.asList("127.0.0.1"), "", new CouchbaseEventHandler());
couchbaseEventHandler.start();
Bucket defaultBucket = cluster.openBucket();
JsonObject user = JsonObject.empty().put("firstname", "Lorenzo").put("lastname", "Speranzoni")
.put("job", "CEO @ LARUS Business Automation").put("age", 41);
JsonDocument doc = JsonDocument.create("inserpio", user);
JsonDocument response = defaultBucket.upsert(doc);
System.out.println(response);
cluster.disconnect();
}
示例5: sendJSONDocumentsToCouchbase
import com.couchbase.client.java.Cluster; //导入方法依赖的package包/类
/**
*
* @param jsonDocuments
*/
public void sendJSONDocumentsToCouchbase(List<JsonDocument> jsonDocuments) {
Cluster cluster = CouchbaseCluster.create();
Bucket defaultBucket = cluster.openBucket();
for (JsonDocument jsonDocument : jsonDocuments) {
defaultBucket.upsert(jsonDocument);
}
cluster.disconnect();
}