Skip to content

Instantly share code, notes, and snippets.

@ingenthr
Created September 3, 2013 23:25
Show Gist options
  • Save ingenthr/6430935 to your computer and use it in GitHub Desktop.
Save ingenthr/6430935 to your computer and use it in GitHub Desktop.
Adjusting CouchbaseClient tuneables via CouchbaseConnectionFactoryBuilder.
/**
* Copyright (C) 2009-2013 Couchbase, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING
* IN THE SOFTWARE.
*/
import com.couchbase.client.CouchbaseConnectionFactoryBuilder;
import com.couchbase.client.CouchbaseClient;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
public class Demo {
protected static List<URI> bootstrapList;
public static void main(String args[]) throws IOException, URISyntaxException {
bootstrapList = Arrays.asList(new URI("http://localhost:8091/pools"));
Demo demoer = new Demo();
demoer.demoIt();
}
protected void demoIt() throws IOException {
CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
cfb.setTimeoutExceptionThreshold(100);
CouchbaseClient cb;
cb = new CouchbaseClient(cfb.buildCouchbaseConnection(bootstrapList, "default", ""));
cb.set("foo", "bar");
System.out.println(cb.get("foo"));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.couchbase.client.demo</groupId>
<artifactId>CouchbaseClientTuningEx</artifactId>
<version>0.1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>couchbase</id>
<name>Couchbase Maven Repository</name>
<url>http://files.couchbase.com/maven2/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>couchbase</groupId>
<artifactId>couchbase-client</artifactId>
<version>1.1.9</version>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment