本文整理汇总了Java中com.couchbase.client.java.env.CouchbaseEnvironment类的典型用法代码示例。如果您正苦于以下问题:Java CouchbaseEnvironment类的具体用法?Java CouchbaseEnvironment怎么用?Java CouchbaseEnvironment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CouchbaseEnvironment类属于com.couchbase.client.java.env包,在下文中一共展示了CouchbaseEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEnvironment
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的package包/类
@Override
protected CouchbaseEnvironment getEnvironment() {
return DefaultCouchbaseEnvironment.builder()
.connectTimeout(10000)
.kvTimeout(10000)
.queryTimeout(10000)
.viewTimeout(10000)
.build();
}
示例2: beerBucketTest
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的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();
}
示例3: build
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的package包/类
@Override
public DataWriter build()
throws IOException {
State state = this.destination.getProperties();
Properties taskProps = state.getProperties();
Config config = ConfigUtils.propertiesToConfig(taskProps);
CouchbaseEnvironment couchbaseEnvironment = CouchbaseEnvironmentFactory.getInstance(config);
//TODO: Read config to decide whether to build a blocking writer or an async writer
// build an async couchbase writer
AsyncDataWriter couchbaseWriter = new CouchbaseWriter(couchbaseEnvironment, config);
return AsyncWriterManager.builder()
.asyncDataWriter(couchbaseWriter)
.failureAllowanceRatio(0.0)
.retriesEnabled(false)
.config(config)
.build();
}
示例4: main
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的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);
}
}
示例5: getCouchbaseEnvironnement
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的package包/类
public CouchbaseEnvironment getCouchbaseEnvironnement() {
if (couchbaseEnvironment == null) {
initCluster();
couchbaseEnvironment = DefaultCouchbaseEnvironment.builder()
.bootstrapCarrierDirectPort(getMappedPort(11210))
.bootstrapCarrierSslPort(getMappedPort(11207))
.bootstrapHttpDirectPort(getMappedPort(8091))
.bootstrapHttpSslPort(getMappedPort(18091))
.build();
}
return couchbaseEnvironment;
}
示例6: getCouchbaseEnvironnement
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的package包/类
public CouchbaseEnvironment getCouchbaseEnvironnement() {
if (couchbaseEnvironment == null) {
initCluster();
couchbaseEnvironment = DefaultCouchbaseEnvironment.builder()
.bootstrapCarrierDirectPort(getMappedPort(11210))
.bootstrapCarrierSslPort(getMappedPort(11207))
.bootstrapHttpDirectPort(getMappedPort(8091))
.bootstrapHttpSslPort(getMappedPort(18091))
.build();
}
return couchbaseEnvironment;
}
示例7: SpringBootCouchbaseConfigurer
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的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
示例8: defaultConfiguration
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的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
示例9: customConfiguration
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的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
示例10: assertNoCouchbaseBeans
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的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
示例11: getInstance
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的package包/类
/**
* Gets the singleton.
* @param couchbaseEnvironment - the single couchbase env, if null then the
* default is instantiated
* @param nodes - the nodes to connect to
* @return the singleton connection context
*/
public static CouchbaseConnectionContext getInstance(CouchbaseEnvironment couchbaseEnvironment,
List<String> nodes) {
if (singletonInstance == null) {
synchronized (CouchbaseConnectionContext.class) {
if (singletonInstance == null) {
if (couchbaseEnvironment == null) {
couchbaseEnvironment = DefaultCouchbaseEnvironment.create();
}
singletonInstance = new CouchbaseConnectionContext(couchbaseEnvironment, nodes);
}
}
}
return singletonInstance;
}
示例12: mockCouchbaseCluster
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的package包/类
@Before
public void mockCouchbaseCluster() {
PowerMockito.mockStatic(CouchbaseCluster.class);
mockedCluster = mock(CouchbaseCluster.class);
when(CouchbaseCluster.create(any(CouchbaseEnvironment.class),
anyListOf(String.class))).thenReturn(mockedCluster);
mockedManager = mock(ClusterManager.class);
when(mockedCluster.clusterManager(anyString(), anyString())).thenReturn(mockedManager);
}
示例13: populateBucket
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的package包/类
private void populateBucket() {
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()
.socketConnectTimeout(60000)
.connectTimeout(60000)
.keepAliveInterval(60000)
.build();
CouchbaseCluster cluster = CouchbaseCluster.create(env, bootstrapNodes);
Bucket bucket = cluster.openBucket(bucketName, password);
assertTrue(bucket.bucketManager().flush());
JsonDocument document = JsonDocument.create("foo", JsonObject.create().put("bar", 42));
bucket.upsert(document, PersistTo.MASTER);
bucket.close();
cluster.disconnect();
}
示例14: getInstance
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的package包/类
/**
* Currently hands out a singleton DefaultCouchbaseEnvironment.
* This is done because it is recommended to use a single couchbase environment instance per JVM.
* TODO: Determine if we need to use the config to tweak certain parameters
* @param config
* @return
*/
public static synchronized CouchbaseEnvironment getInstance(Config config)
{
if (couchbaseEnvironment == null)
{
return DefaultCouchbaseEnvironment.create();
}
else {
return couchbaseEnvironment;
}
}
示例15: testServer
import com.couchbase.client.java.env.CouchbaseEnvironment; //导入依赖的package包/类
@Test
public static void testServer()
throws InterruptedException, IOException {
CouchbaseTestServer couchbaseTestServer = new CouchbaseTestServer(TestUtils.findFreePort());
couchbaseTestServer.start();
int port = couchbaseTestServer.getPort();
int serverPort = couchbaseTestServer.getServerPort();
try {
CouchbaseEnvironment cbEnv = DefaultCouchbaseEnvironment.builder().bootstrapHttpEnabled(true)
.bootstrapHttpDirectPort(port)
.bootstrapCarrierDirectPort(serverPort)
.connectTimeout(TimeUnit.SECONDS.toMillis(15))
.bootstrapCarrierEnabled(true).build();
CouchbaseCluster cbCluster = CouchbaseCluster.create(cbEnv, "localhost");
Bucket bucket = cbCluster.openBucket("default","");
try {
JsonObject content = JsonObject.empty().put("name", "Michael");
JsonDocument doc = JsonDocument.create("docId", content);
JsonDocument inserted = bucket.insert(doc);
}
catch (Exception e)
{
Assert.fail("Should not throw exception on insert", e);
}
}
finally
{
couchbaseTestServer.stop();
}
}