use of com.couchbase.client.java.query.consistency.ScanConsistency in project teiid by teiid.
the class CouchbaseManagedConnectionFactory method createConnectionFactory.
@SuppressWarnings("serial")
@Override
public BasicConnectionFactory<CouchbaseConnectionImpl> createConnectionFactory() throws ResourceException {
final CouchbaseEnvironment environment = DefaultCouchbaseEnvironment.builder().managementTimeout(managementTimeout).queryTimeout(queryTimeout).viewTimeout(viewTimeout).kvTimeout(kvTimeout).searchTimeout(searchTimeout).connectTimeout(connectTimeout).dnsSrvEnabled(dnsSrvEnabled).build();
if (this.connectionString == null) {
// $NON-NLS-1$
throw new InvalidPropertyException(UTIL.getString("no_server"));
}
if (this.keyspace == null) {
// $NON-NLS-1$
throw new InvalidPropertyException(UTIL.getString("no_keyspace"));
}
if (this.namespace == null) {
// $NON-NLS-1$
throw new InvalidPropertyException(UTIL.getString("no_namespace"));
}
final ScanConsistency consistency = ScanConsistency.valueOf(scanConsistency);
TimeUnit unit = TimeUnit.MILLISECONDS;
if (this.timeUnit != null) {
try {
unit = TimeUnit.valueOf(timeUnit);
} catch (IllegalArgumentException e) {
// $NON-NLS-1$
throw new InvalidPropertyException(UTIL.getString("invalid_timeUnit", timeUnit));
}
}
final TimeUnit timeoutUnit = unit;
return new BasicConnectionFactory<CouchbaseConnectionImpl>() {
@Override
public CouchbaseConnectionImpl getConnection() throws ResourceException {
return new CouchbaseConnectionImpl(environment, connectionString, keyspace, password, timeoutUnit, namespace, consistency);
}
};
}
Aggregations