Search in sources :

Example 1 with LatencyRecordingHttpRequestInitializer

use of org.apache.beam.sdk.extensions.gcp.util.LatencyRecordingHttpRequestInitializer 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());
}
Also used : RetryHttpRequestInitializer(org.apache.beam.sdk.extensions.gcp.util.RetryHttpRequestInitializer) HttpCredentialsAdapter(com.google.auth.http.HttpCredentialsAdapter) ImmutableList(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList) LatencyRecordingHttpRequestInitializer(org.apache.beam.sdk.extensions.gcp.util.LatencyRecordingHttpRequestInitializer) ChainingHttpRequestInitializer(com.google.cloud.hadoop.util.ChainingHttpRequestInitializer) RetryHttpRequestInitializer(org.apache.beam.sdk.extensions.gcp.util.RetryHttpRequestInitializer) LatencyRecordingHttpRequestInitializer(org.apache.beam.sdk.extensions.gcp.util.LatencyRecordingHttpRequestInitializer) HttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer) NullCredentialInitializer(org.apache.beam.sdk.extensions.gcp.auth.NullCredentialInitializer) Credentials(com.google.auth.Credentials) ChainingHttpRequestInitializer(com.google.cloud.hadoop.util.ChainingHttpRequestInitializer)

Aggregations

HttpRequestInitializer (com.google.api.client.http.HttpRequestInitializer)1 Credentials (com.google.auth.Credentials)1 HttpCredentialsAdapter (com.google.auth.http.HttpCredentialsAdapter)1 ChainingHttpRequestInitializer (com.google.cloud.hadoop.util.ChainingHttpRequestInitializer)1 NullCredentialInitializer (org.apache.beam.sdk.extensions.gcp.auth.NullCredentialInitializer)1 LatencyRecordingHttpRequestInitializer (org.apache.beam.sdk.extensions.gcp.util.LatencyRecordingHttpRequestInitializer)1 RetryHttpRequestInitializer (org.apache.beam.sdk.extensions.gcp.util.RetryHttpRequestInitializer)1 ImmutableList (org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList)1