org.ektorp.impl.StdCouchDbInstance Java Examples
The following examples show how to use
org.ektorp.impl.StdCouchDbInstance.
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: CouchDbConnectionManager.java From open-Autoscaler with Apache License 2.0 | 6 votes |
private CouchDbConnector initConnection(String dbName, String userName, String password, String host, int port, boolean enableSSL, int timeout) { Builder builder = new StdHttpClient.Builder() .host(host) .port(port) .connectionTimeout(timeout) .socketTimeout(timeout) .enableSSL(enableSSL); if(userName != null && !userName.isEmpty() && password != null && !password.isEmpty()) builder.username(userName).password(password); dbInstance = new StdCouchDbInstance(builder.build()); if (!dbInstance.checkIfDbExists(dbName)) dbInstance.createDatabase(dbName); CouchDbConnector couchDB = dbInstance.createConnector(dbName, true); return couchDB; }
Example #2
Source File: CouchDbStore.java From attic-apex-malhar with Apache License 2.0 | 6 votes |
@Override public void connect() throws IOException { StdHttpClient.Builder builder = new StdHttpClient.Builder(); if (dbUrl != null) { try { builder.url(dbUrl); } catch (MalformedURLException e) { throw new IllegalArgumentException(e.getMessage()); } } if (userName != null) { builder.username(userName); } if (password != null) { builder.password(password); } HttpClient httpClient = builder.build(); couchInstance = new StdCouchDbInstance(httpClient); dbConnector = couchInstance.createConnector(dbName, false); }
Example #3
Source File: CouchdbStoreService.java From open-Autoscaler with Apache License 2.0 | 5 votes |
private CouchDbConnector initConnection() throws MalformedURLException, ProxyInitilizedFailedException { String username = ConfigManager.get("couchdbUsername"); String password = ConfigManager.get("couchdbPassword"); String host = ConfigManager.get("couchdbHost"); int port = ConfigManager.getInt("couchdbPort"); int timeout = ConfigManager.getInt("couchdbTimeout"); boolean enableSSL = ConfigManager.getBoolean("couchdbEnableSSL", false); String dbName = ConfigManager.get("couchdbDBName"); Builder builder = new StdHttpClient.Builder(); builder = builder .host(host) .port(port) .connectionTimeout(timeout) .enableSSL(enableSSL); if (username != null && !username.isEmpty() && password != null && !password.isEmpty() ) { builder = builder.username(username).password(password); } CouchDbInstance dbInstance = new StdCouchDbInstance(builder.build()); if (!dbInstance.checkIfDbExists(dbName)) dbInstance.createDatabase(dbName); CouchDbConnector couchDB = dbInstance.createConnector(dbName, true); return couchDB; }
Example #4
Source File: CloudantInstanceCreator.java From bluemix-cloud-connectors with Apache License 2.0 | 5 votes |
@Override public CouchDbInstance create(CloudantServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig) { HttpClient httpClient; try { httpClient = new StdHttpClient.Builder() .url(serviceInfo.getUrl()) .build(); return new StdCouchDbInstance(httpClient); } catch (MalformedURLException e) { LOG.logp(Level.WARNING, CloudantInstanceCreator.class.getName(), "create", "Error parsing URL", e); return null; } }
Example #5
Source File: CouchDBTestHelper.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
static void setup() { StdHttpClient.Builder builder = new StdHttpClient.Builder(); HttpClient httpClient = builder.build(); StdCouchDbInstance instance = new StdCouchDbInstance(httpClient); DbPath dbPath = new DbPath(TEST_DB); if (instance.checkIfDbExists((dbPath))) { instance.deleteDatabase(dbPath.getPath()); } connector = instance.createConnector(TEST_DB, true); }
Example #6
Source File: CouchDBTestHelper.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
static void teardown() { StdHttpClient.Builder builder = new StdHttpClient.Builder(); HttpClient httpClient = builder.build(); StdCouchDbInstance instance = new StdCouchDbInstance(httpClient); DbPath dbPath = new DbPath(TEST_DB); if (instance.checkIfDbExists((dbPath))) { instance.deleteDatabase(dbPath.getPath()); } }