use of com.couchbase.client.core.env.NetworkResolution in project couchbase-elasticsearch-connector by couchbase.
the class SeedNodeHelper method getKvNodes.
/**
* Returns complete host and port information for every node running the KV service.
*/
public static Set<SeedNode> getKvNodes(Bucket bucket, String connectionString, boolean tls, NetworkResolution networkResolution, Duration timeout) {
// Bucket config is most reliable way to determine KV ports
BucketConfig config = CouchbaseHelper.getConfig(bucket, timeout);
// so the actual node names can be used.
if (networkResolution.equals(NetworkResolution.AUTO)) {
EventBus eventBus = bucket.environment().eventBus();
// The Java client calls seedNodesFromConnectionString during bootstrap, but the results
// are not accessible here. Call it again.
Set<String> seedHosts = ConnectionStringUtil.seedNodesFromConnectionString(connectionString, true, tls, eventBus).stream().map(SeedNode::address).collect(toSet());
networkResolution = inferNetwork(config, networkResolution, seedHosts);
}
// Resolve alternate addresses
// so lambda can access it
NetworkResolution finalNetworkResolution = networkResolution;
return config.nodes().stream().map(node -> new ResolvedNodeInfo(node, tls, finalNetworkResolution)).map(node -> SeedNode.create(node.host(), node.port(KV), node.port(MANAGER))).filter(node -> node.kvPort().isPresent()).collect(toSet());
}
use of com.couchbase.client.core.env.NetworkResolution in project kafka-connect-couchbase by couchbase.
the class SeedNodeHelper method getKvNodes.
/**
* Returns complete host and port information for every node running the KV service.
*/
public static Set<SeedNode> getKvNodes(Bucket bucket, String connectionString, boolean tls, NetworkResolution networkResolution, Duration timeout) {
// Bucket config is most reliable way to determine KV ports
BucketConfig config = CouchbaseHelper.getConfig(bucket, timeout);
// so the actual node names can be used.
if (networkResolution.equals(NetworkResolution.AUTO)) {
EventBus eventBus = bucket.environment().eventBus();
// The Java client calls seedNodesFromConnectionString during bootstrap, but the results
// are not accessible here. Call it again.
Set<String> seedHosts = ConnectionStringUtil.seedNodesFromConnectionString(connectionString, true, tls, eventBus).stream().map(SeedNode::address).collect(toSet());
networkResolution = inferNetwork(config, networkResolution, seedHosts);
}
// Resolve alternate addresses
// so lambda can access it
NetworkResolution finalNetworkResolution = networkResolution;
return config.nodes().stream().map(node -> new ResolvedNodeInfo(node, tls, finalNetworkResolution)).map(node -> SeedNode.create(node.host(), node.port(KV), node.port(MANAGER))).filter(node -> node.kvPort().isPresent()).collect(toSet());
}
use of com.couchbase.client.core.env.NetworkResolution in project kafka-connect-couchbase by couchbase.
the class CouchbaseSourceConnector method start.
@Override
public void start(Map<String, String> properties) {
try {
configProperties = properties;
CouchbaseSourceConfig config = ConfigHelper.parse(CouchbaseSourceConfig.class, properties);
try (KafkaCouchbaseClient client = new KafkaCouchbaseClient(config)) {
Bucket bucket = client.bucket();
bucketConfig = (CouchbaseBucketConfig) CouchbaseHelper.getConfig(bucket, config.bootstrapTimeout());
String connectionString = String.join(",", config.seedNodes());
NetworkResolution network = NetworkResolution.valueOf(config.network());
seedNodes = SeedNodeHelper.getKvNodes(bucket, connectionString, config.enableTls(), network, config.bootstrapTimeout());
}
} catch (ConfigException e) {
throw new ConnectException("Cannot start CouchbaseSourceConnector due to configuration error", e);
}
}
Aggregations