use of com.couchbase.client.core.env.IoEnvironment in project couchbase-elasticsearch-connector by couchbase.
the class CouchbaseHelper method applyCustomEnvironmentProperties.
private static void applyCustomEnvironmentProperties(ClusterEnvironment.Builder envBuilder, CouchbaseConfig config) {
// Begin workaround for IoEnvironment config.
// Prior to Java client 3.1.5, IoEnvironment isn't configurable
// via system properties. Until then, handle it manually.
Map<String, String> envProps = new HashMap<>(config.env());
IoEnvironment.Builder ioEnvBuilder = IoEnvironment.builder();
String nativeIoEnabled = envProps.remove("ioEnvironment.enableNativeIo");
if (nativeIoEnabled != null) {
ioEnvBuilder.enableNativeIo(Boolean.parseBoolean(nativeIoEnabled));
}
String eventLoopThreadCount = envProps.remove("ioEnvironment.eventLoopThreadCount");
if (eventLoopThreadCount != null) {
ioEnvBuilder.eventLoopThreadCount(Integer.parseInt(eventLoopThreadCount));
}
envBuilder.ioEnvironment(ioEnvBuilder);
try {
envBuilder.load(new AbstractMapPropertyLoader<CoreEnvironment.Builder>() {
@Override
protected Map<String, String> propertyMap() {
return envProps;
}
});
} catch (Exception e) {
throw new ConfigException("Failed to apply Couchbase environment properties; " + e.getMessage());
}
}
Aggregations