use of com.google.cloud.hadoop.util.ChainingHttpRequestInitializer in project beam by apache.
the class BigQueryServicesImpl method newBigQueryClient.
/**
* Returns a BigQuery client builder using the specified {@link BigQueryOptions}.
*/
private static Bigquery.Builder newBigQueryClient(BigQueryOptions options) {
// Do not log 404. It clutters the output and is possibly even required by the
// caller.
RetryHttpRequestInitializer httpRequestInitializer = new RetryHttpRequestInitializer(ImmutableList.of(404));
httpRequestInitializer.setCustomErrors(createBigQueryClientCustomErrors());
httpRequestInitializer.setWriteTimeout(options.getHTTPWriteTimeout());
ImmutableList.Builder<HttpRequestInitializer> initBuilder = ImmutableList.builder();
Credentials credential = options.getGcpCredential();
initBuilder.add(credential == null ? new NullCredentialInitializer() : new HttpCredentialsAdapter(credential));
initBuilder.add(new LatencyRecordingHttpRequestInitializer(API_METRIC_LABEL));
initBuilder.add(httpRequestInitializer);
HttpRequestInitializer chainInitializer = new ChainingHttpRequestInitializer(Iterables.toArray(initBuilder.build(), HttpRequestInitializer.class));
return new Bigquery.Builder(Transport.getTransport(), Transport.getJsonFactory(), chainInitializer).setApplicationName(options.getAppName()).setGoogleClientRequestInitializer(options.getGoogleApiTrace());
}
use of com.google.cloud.hadoop.util.ChainingHttpRequestInitializer in project beam by apache.
the class V1TestUtil method getDatastore.
/**
* Build a new datastore client.
*/
static Datastore getDatastore(PipelineOptions pipelineOptions, String projectId) {
Credentials credential = pipelineOptions.as(GcpOptions.class).getGcpCredential();
HttpRequestInitializer initializer;
if (credential != null) {
initializer = new ChainingHttpRequestInitializer(new HttpCredentialsAdapter(credential), new RetryHttpRequestInitializer());
} else {
initializer = new RetryHttpRequestInitializer();
}
DatastoreOptions.Builder builder = new DatastoreOptions.Builder().projectId(projectId).initializer(initializer);
return DatastoreFactory.get().create(builder.build());
}
Aggregations