本文整理汇总了Java中com.couchbase.client.java.Cluster类的典型用法代码示例。如果您正苦于以下问题:Java Cluster类的具体用法?Java Cluster怎么用?Java Cluster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cluster类属于com.couchbase.client.java包,在下文中一共展示了Cluster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: couchbaseClusterInfo
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Override
@Bean
public ClusterInfo couchbaseClusterInfo() throws Exception {
Cluster cc = couchbaseCluster();
ClusterManager manager = cc.clusterManager(clusterUser, clusterPassword);
return manager.info();
}
示例2: CouchbaseTtsDao
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Inject
CouchbaseTtsDao(Cluster cluster) {
bucket = cluster.openBucket(TTS_BUCKET_NAME);
// Clear all designs docs
bucket.bucketManager().getDesignDocuments().forEach(designDocument -> bucket.bucketManager().removeDesignDocument(designDocument.name()));
// Insert designs docs
designDocuments().forEach(designDocument -> bucket.bucketManager().insertDesignDocument(designDocument));
}
示例3: provideCluster
import com.couchbase.client.java.Cluster; //导入依赖的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);
}
示例4: couchbaseClusterInfo
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Bean
@Primary
public ClusterInfo couchbaseClusterInfo() throws Exception {
Cluster cc = couchbaseCluster();
ClusterManager manager = cc.clusterManager(AbstractSpringBootTestConfig.clusterUser, AbstractSpringBootTestConfig.clusterPassword);
return manager.info();
}
示例5: 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);
}
示例6: SpringBootCouchbaseConfigurer
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
public SpringBootCouchbaseConfigurer(CouchbaseEnvironment env, Cluster cluster,
ClusterInfo clusterInfo, Bucket bucket) {
this.env = env;
this.cluster = cluster;
this.clusterInfo = clusterInfo;
this.bucket = bucket;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:SpringBootCouchbaseConfigurer.java
示例7: defaultConfiguration
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Test
public void defaultConfiguration() {
load(null, "spring.couchbase.bootstrapHosts=localhost");
assertThat(this.context.getBeansOfType(Cluster.class)).hasSize(1);
assertThat(this.context.getBeansOfType(ClusterInfo.class)).hasSize(1);
assertThat(this.context.getBeansOfType(CouchbaseEnvironment.class)).hasSize(1);
assertThat(this.context.getBeansOfType(Bucket.class)).hasSize(1);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:CouchbaseAutoConfigurationIntegrationTests.java
示例8: customConfiguration
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Test
public void customConfiguration() {
load(CustomConfiguration.class, "spring.couchbase.bootstrapHosts=localhost");
assertThat(this.context.getBeansOfType(Cluster.class)).hasSize(2);
assertThat(this.context.getBeansOfType(ClusterInfo.class)).hasSize(1);
assertThat(this.context.getBeansOfType(CouchbaseEnvironment.class)).hasSize(1);
assertThat(this.context.getBeansOfType(Bucket.class)).hasSize(2);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:CouchbaseAutoConfigurationIntegrationTests.java
示例9: assertNoCouchbaseBeans
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
private void assertNoCouchbaseBeans() {
// No beans are going to be created
assertThat(this.context.getBeansOfType(CouchbaseEnvironment.class)).isEmpty();
assertThat(this.context.getBeansOfType(ClusterInfo.class)).isEmpty();
assertThat(this.context.getBeansOfType(Cluster.class)).isEmpty();
assertThat(this.context.getBeansOfType(Bucket.class)).isEmpty();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:CouchbaseAutoConfigurationTests.java
示例10: bucket
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Bean(destroyMethod = "close")
@Autowired
Bucket bucket(
final Cluster cluster,
@Value("${database.bucket.name:default}") final String name,
@Value("${database.bucket.password:}") final String password) {
return cluster.openBucket(name, password);
}
示例11: getConnection
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Override
public Cluster getConnection(MacheLoader cacheLoader) {
super.registerLoader(cacheLoader);
if (cluster == null) {
synchronized (this) {
if (cluster == null) {
cluster = CouchbaseCluster.create(builder, nodes);
}
}
}
return cluster;
}
示例12: 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;
}
示例13: 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();
}
示例14: couchbaseCluster
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Override
@Bean
public Cluster couchbaseCluster() throws Exception {
return couchbaseContainer.geCouchbaseCluster();
}
示例15: CouchbaseClient
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
public CouchbaseClient(final String user, final String password, final Cluster cluster) {
super();
this.user = user;
this.password = password;
this.cluster = cluster;
}