use of com.datastax.oss.driver.internal.core.config.cloud.CloudConfigFactory in project dsbulk by datastax.
the class DefaultSNIProxyServer method start.
@Override
public void start() {
CommandLine run = CommandLine.parse(proxyPath.resolve("run.sh").toString());
execute(run);
running = true;
try {
config = new CloudConfigFactory().createCloudConfig(Files.newInputStream(getSecureBundlePath()));
} catch (IOException | GeneralSecurityException e) {
// should never happen, the bundle is always present and readable once the proxy is started
throw new RuntimeException(e);
}
}
use of com.datastax.oss.driver.internal.core.config.cloud.CloudConfigFactory in project java-driver by datastax.
the class SessionBuilder method buildDefaultSessionAsync.
@NonNull
protected final CompletionStage<CqlSession> buildDefaultSessionAsync() {
try {
ProgrammaticArguments programmaticArguments = programmaticArgumentsBuilder.build();
DriverConfigLoader configLoader = this.configLoader != null ? this.configLoader : defaultConfigLoader(programmaticArguments.getClassLoader());
DriverExecutionProfile defaultConfig = configLoader.getInitialConfig().getDefaultProfile();
if (cloudConfigInputStream == null) {
String configUrlString = defaultConfig.getString(DefaultDriverOption.CLOUD_SECURE_CONNECT_BUNDLE, null);
if (configUrlString != null) {
cloudConfigInputStream = () -> getURL(configUrlString).openStream();
}
}
List<String> configContactPoints = defaultConfig.getStringList(DefaultDriverOption.CONTACT_POINTS, Collections.emptyList());
if (cloudConfigInputStream != null) {
if (!programmaticContactPoints.isEmpty() || !configContactPoints.isEmpty()) {
LOG.info("Both a secure connect bundle and contact points were provided. These are mutually exclusive. The contact points from the secure bundle will have priority.");
// clear the contact points provided in the setting file and via addContactPoints
configContactPoints = Collections.emptyList();
programmaticContactPoints = new HashSet<>();
}
if (programmaticSslFactory || defaultConfig.isDefined(DefaultDriverOption.SSL_ENGINE_FACTORY_CLASS)) {
LOG.info("Both a secure connect bundle and SSL options were provided. They are mutually exclusive. The SSL options from the secure bundle will have priority.");
}
CloudConfig cloudConfig = new CloudConfigFactory().createCloudConfig(cloudConfigInputStream.call());
addContactEndPoints(cloudConfig.getEndPoints());
boolean localDataCenterDefined = anyProfileHasDatacenterDefined(configLoader.getInitialConfig());
if (programmaticLocalDatacenter || localDataCenterDefined) {
LOG.info("Both a secure connect bundle and a local datacenter were provided. They are mutually exclusive. The local datacenter from the secure bundle will have priority.");
programmaticArgumentsBuilder.clearDatacenters();
}
withLocalDatacenter(cloudConfig.getLocalDatacenter());
withSslEngineFactory(cloudConfig.getSslEngineFactory());
withCloudProxyAddress(cloudConfig.getProxyAddress());
programmaticArguments = programmaticArgumentsBuilder.build();
}
boolean resolveAddresses = defaultConfig.getBoolean(DefaultDriverOption.RESOLVE_CONTACT_POINTS, true);
Set<EndPoint> contactPoints = ContactPoints.merge(programmaticContactPoints, configContactPoints, resolveAddresses);
if (keyspace == null && defaultConfig.isDefined(DefaultDriverOption.SESSION_KEYSPACE)) {
keyspace = CqlIdentifier.fromCql(defaultConfig.getString(DefaultDriverOption.SESSION_KEYSPACE));
}
return DefaultSession.init((InternalDriverContext) buildContext(configLoader, programmaticArguments), contactPoints, keyspace);
} catch (Throwable t) {
// failed future if anything goes wrong. So wrap any error from that synchronous part.
return CompletableFutures.failedFuture(t);
}
}
Aggregations