com.couchbase.client.CouchbaseConnectionFactoryBuilder Java Examples

The following examples show how to use com.couchbase.client.CouchbaseConnectionFactoryBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigureCouchbase.java    From micro-server with Apache License 2.0 5 votes vote down vote up
@Bean(name = "couchbaseClient")
public CouchbaseClient couchbaseClient() throws IOException, URISyntaxException {
    if (couchbaseClientEnabled) {
        logger.info("Creating CouchbaseClient for servers: {}", couchbaseServers);
        CouchbaseConnectionFactoryBuilder builder = new CouchbaseConnectionFactoryBuilder();
        builder.setOpTimeout(opTimeout);
        CouchbaseConnectionFactory cf = builder.buildCouchbaseConnection(getServersList(), couchbaseBucket,
                                                                         StringUtils.trimAllWhitespace(Optional.ofNullable(couchbasePassword)
                                                                                                               .orElse("")));
        return new CouchbaseClient(
                                   cf);
    }
    return null;

}
 
Example #2
Source File: CouchBaseWindowStore.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
@Override
public void connect() throws IOException
{
  super.connect();
  logger.debug("connection established");
  try {
    CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
    cfb.setOpTimeout(timeout);  // wait up to 10 seconds for an operation to succeed
    cfb.setOpQueueMaxBlockTime(blockTime); // wait up to 10 second when trying to enqueue an operation
    clientMeta = new CouchbaseClient(cfb.buildCouchbaseConnection(baseURIs, bucketMeta, passwordMeta));
  } catch (IOException e) {
    logger.error("Error connecting to Couchbase: ", e);
    DTThrowable.rethrow(e);
  }
}
 
Example #3
Source File: CouchBaseClientFactory.java    From GraceKelly with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and returns {@link CouchbaseClient} based on the parameters provided.
 * @param urls
 * @param bucketName
 * @param password
 * @return {@link CouchbaseClient} instance.
 * @throws IOException
 */
public static CouchbaseClient getCouchBaseClient(String[] urls, String bucketName, String password) throws IOException {

    List<URI> uris = new ArrayList<URI>();
    for (String url: urls){
        uris.add(URI.create(url));
    }

    CouchbaseConnectionFactoryBuilder builder = new CouchbaseConnectionFactoryBuilder();
    CouchbaseClient couchbaseClient = new CouchbaseClient(builder.buildCouchbaseConnection(uris,bucketName,password));
    return couchbaseClient;
}