use of com.amazonaws.services.glue.AWSGlueAsyncClientBuilder in project presto by prestodb.
the class GlueHiveMetastore method createAsyncGlueClient.
private static AWSGlueAsync createAsyncGlueClient(GlueHiveMetastoreConfig config, RequestMetricCollector metricsCollector) {
ClientConfiguration clientConfig = new ClientConfiguration().withMaxConnections(config.getMaxGlueConnections()).withMaxErrorRetry(config.getMaxGlueErrorRetries());
AWSGlueAsyncClientBuilder asyncGlueClientBuilder = AWSGlueAsyncClientBuilder.standard().withMetricsCollector(metricsCollector).withClientConfiguration(clientConfig);
if (config.getGlueEndpointUrl().isPresent()) {
checkArgument(config.getGlueRegion().isPresent(), "Glue region must be set when Glue endpoint URL is set");
asyncGlueClientBuilder.setEndpointConfiguration(new EndpointConfiguration(config.getGlueEndpointUrl().get(), config.getGlueRegion().get()));
} else if (config.getGlueRegion().isPresent()) {
asyncGlueClientBuilder.setRegion(config.getGlueRegion().get());
} else if (config.getPinGlueClientToCurrentRegion()) {
Region currentRegion = Regions.getCurrentRegion();
if (currentRegion != null) {
asyncGlueClientBuilder.setRegion(currentRegion.getName());
}
}
if (config.getAwsAccessKey().isPresent() && config.getAwsSecretKey().isPresent()) {
AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials(config.getAwsAccessKey().get(), config.getAwsSecretKey().get()));
asyncGlueClientBuilder.setCredentials(credentialsProvider);
} else if (config.getIamRole().isPresent()) {
AWSCredentialsProvider credentialsProvider = new STSAssumeRoleSessionCredentialsProvider.Builder(config.getIamRole().get(), "roleSessionName").build();
asyncGlueClientBuilder.setCredentials(credentialsProvider);
}
return asyncGlueClientBuilder.build();
}
use of com.amazonaws.services.glue.AWSGlueAsyncClientBuilder in project alluxio by Alluxio.
the class GlueDatabase method createAsyncGlueClient.
/**
* This method allows user to test udb glue client with remote glue server.
*
* @param config udbconfiguration
* @return glue async client
*/
protected static AWSGlueAsync createAsyncGlueClient(UdbConfiguration config) {
ClientConfiguration clientConfig = new ClientConfiguration().withMaxConnections(config.getInt(Property.MAX_GLUE_CONNECTION));
if (!config.get(Property.AWS_PROXY_HOST).isEmpty()) {
clientConfig.withProxyProtocol(getProtocol(config.get(Property.AWS_PROXY_PROTOCOL))).withProxyHost(config.get(Property.AWS_PROXY_HOST)).withProxyPort(config.getInt(Property.AWS_PROXY_PORT)).withProxyUsername(config.get(Property.AWS_PROXY_USER_NAME)).withProxyPassword(config.get(Property.AWS_PROXY_PASSWORD));
}
AWSGlueAsyncClientBuilder asyncClientBuilder = AWSGlueAsyncClientBuilder.standard().withClientConfiguration(clientConfig);
if (!config.get(Property.GLUE_REGION).isEmpty()) {
LOG.info("Set Glue region: {}.", config.get(Property.GLUE_REGION));
asyncClientBuilder.setRegion(config.get(Property.GLUE_REGION));
} else {
LOG.warn("GlueDatabase: Please setup the AWS region.");
}
asyncClientBuilder.setCredentials(getAWSCredentialsProvider(config));
return asyncClientBuilder.build();
}
Aggregations