当前位置: 首页>>代码示例>>Java>>正文


Java Cluster.disconnect方法代码示例

本文整理汇总了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);
}
 
开发者ID:larusba,项目名称:neo4j-couchbase-connector,代码行数:28,代码来源:SpotifyCouchbaseLoaderTest.java

示例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;
    }
 
开发者ID:dboissier,项目名称:nosql4idea,代码行数:28,代码来源:CouchbaseClient.java

示例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();
}
 
开发者ID:dboissier,项目名称:nosql4idea,代码行数:39,代码来源:CouchbaseClientTest.java

示例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();
}
 
开发者ID:larusba,项目名称:neo4j-couchbase-connector,代码行数:26,代码来源:CouchbaseEventHandlerTest.java

示例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();
}
 
开发者ID:larusba,项目名称:neo4j-couchbase-connector,代码行数:18,代码来源:Neo4jEventListener.java


注:本文中的com.couchbase.client.java.Cluster.disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。