本文整理汇总了Java中com.couchbase.client.java.Cluster类的典型用法代码示例。如果您正苦于以下问题:Java Cluster类的具体用法?Java Cluster怎么用?Java Cluster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cluster类属于com.couchbase.client.java包,在下文中一共展示了Cluster类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:couchbaselabs,项目名称:GitTalent,代码行数:8,代码来源:CouchbaseTestConfig.java
示例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));
}
开发者ID:maxcleme,项目名称:f4f-tts,代码行数:12,代码来源:CouchbaseTtsDao.java
示例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);
}
开发者ID:maxcleme,项目名称:f4f-tts,代码行数:8,代码来源:ServerModule.java
示例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();
}
开发者ID:ldoguin,项目名称:testcontainers-spring-boot-couchbase,代码行数:8,代码来源:CouchbaseConfiguration.java
示例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);
}
开发者ID:larusba,项目名称:neo4j-couchbase-connector,代码行数:28,代码来源:SpotifyCouchbaseLoaderTest.java
示例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);
}
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:9,代码来源:CouchbaseConfig.java
示例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;
}
开发者ID:Excelian,项目名称:Mache,代码行数:13,代码来源:CouchbaseConnectionContext.java
示例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;
}
开发者ID:dboissier,项目名称:nosql4idea,代码行数:28,代码来源:CouchbaseClient.java
示例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();
}
开发者ID:dboissier,项目名称:nosql4idea,代码行数:39,代码来源:CouchbaseClientTest.java
示例14: couchbaseCluster
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Override
@Bean
public Cluster couchbaseCluster() throws Exception {
return couchbaseContainer.geCouchbaseCluster();
}
开发者ID:couchbaselabs,项目名称:GitTalent,代码行数:6,代码来源:CouchbaseTestConfig.java
示例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;
}
开发者ID:saarthakgupta,项目名称:couchbase-healthcheck,代码行数:7,代码来源:CouchbaseClient.java
示例16: getCluster
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
public Cluster getCluster() {
return cluster;
}
开发者ID:saarthakgupta,项目名称:couchbase-healthcheck,代码行数:4,代码来源:CouchbaseClient.java
示例17: couchbaseCluster
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Bean
@Primary
public Cluster couchbaseCluster() throws Exception {
return couchbaseContainer.geCouchbaseCluster();
}
开发者ID:ldoguin,项目名称:testcontainers-spring-boot-couchbase,代码行数:6,代码来源:CouchbaseConfiguration.java
示例18: test
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Test
public void test() throws IOException {
System.out.println("Starting DB...");
Cluster cluster = CouchbaseCluster.create();
System.out.println("Created DB");
System.out.println("Opening bucket...");
Bucket bucket = cluster.openBucket("default");
System.out.println("Opened bucket");
int docs = 0;
String artistId = "51Blml2LZPmy7TTiAg47vQ";
String albumsUrl = "https://api.spotify.com/v1/artists/" + artistId + "/albums";
System.out.println("Getting the artist's albums...");
String albumsJson = this.getRequest(albumsUrl);
System.out.println("Got the artist's albums...");
docs++;
JsonObject albumsObject = JsonObject.fromJson(albumsJson);
String albumsId = albumsObject.getString("id");
albumsId = albumsId == null ? "albums" + artistId : albumsId;
JsonDocument albumsDocument = JsonDocument.create(albumsId, albumsObject);
bucket.upsert(albumsDocument);
JsonArray albums = albumsObject.getArray("items");
for (Object albumObj : albums) {
JsonObject item = (JsonObject) albumObj;
String itemHref = item.getString("href");
System.out.println("Getting the album...");
String albumJson = this.getRequest(itemHref);
System.out.println("Got the album...");
docs++;
JsonObject albumObject = JsonObject.fromJson(albumJson);
String albumId = albumObject.getString("id");
JsonDocument albumDocument = JsonDocument.create(albumId, albumObject);
bucket.upsert(albumDocument);
JsonArray tracks = albumObject.getObject("tracks").getArray("items");
for (Object trackObj : tracks) {
JsonObject track = (JsonObject) trackObj;
String trackHref = track.getString("href");
System.out.println("Getting the track...");
String trackJson = this.getRequest(trackHref);
System.out.println("Got the track...");
docs++;
JsonObject trackObject = JsonObject.fromJson(trackJson);
String trackId = trackObject.getString("id");
JsonDocument trackDocument = JsonDocument.create(trackId, trackObject);
bucket.upsert(trackDocument);
}
}
System.out.println("Total documents " + docs);
}
开发者ID:larusba,项目名称:neo4j-couchbase-connector,代码行数:50,代码来源:SpotifyRecursiveLoaderTest.java
示例19: 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
示例20: couchbaseCluster
import com.couchbase.client.java.Cluster; //导入依赖的package包/类
@Override
public Cluster couchbaseCluster() throws Exception {
return this.cluster;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:SpringBootCouchbaseConfigurer.java
注:本文中的com.couchbase.client.java.Cluster类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论