use of com.couchbase.client.dcp.config.HostAndPort in project couchbase-elasticsearch-connector by couchbase.
the class DcpHelper method newClient.
public static Client newClient(String groupName, CouchbaseConfig config, Set<SeedNode> kvNodes, Supplier<KeyStore> trustStore) {
// ES connector bootstraps using Manager port, but the DCP client wants KV port.
// Get the KV ports from the bucket config!
Set<String> seedNodes = kvNodes.stream().map(node -> new HostAndPort(node.address(), node.kvPort().orElseThrow(() -> new AssertionError("seed node missing KV port")))).map(HostAndPort::format).collect(toSet());
Set<String> collectionNames = config.collections().stream().map(ScopeAndCollection::format).collect(toSet());
final Client.Builder builder = Client.builder().meterRegistry(Metrics.registry()).userAgent("elasticsearch-connector", VersionHelper.getVersion(), groupName).bootstrapTimeout(Duration.ofMillis(config.dcp().connectTimeout().millis())).seedNodes(seedNodes).networkResolution(NetworkResolution.valueOf(config.network().name())).bucket(config.bucket()).authenticator(authenticator(config)).controlParam(DcpControl.Names.SET_NOOP_INTERVAL, 20).compression(config.dcp().compression()).collectionsAware(true).scopeName(config.scope()).collectionNames(collectionNames).mitigateRollbacks(config.dcp().persistencePollingInterval().duration(), config.dcp().persistencePollingInterval().timeUnit()).flowControl(toSaturatedInt(config.dcp().flowControlBuffer().getBytes())).bufferAckWatermark(60);
if (config.secureConnection()) {
builder.securityConfig(SecurityConfig.builder().enableTls(true).trustStore(trustStore.get()).enableHostnameVerification(config.hostnameVerification()));
}
return builder.build();
}
Aggregations