Search in sources :

Example 1 with RetryHttpRequestInitializer

use of org.apache.beam.sdk.util.RetryHttpRequestInitializer in project beam by apache.

the class BigQueryServicesImplTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    // A mock transport that lets us mock the API responses.
    MockHttpTransport transport = new MockHttpTransport.Builder().setLowLevelHttpRequest(new MockLowLevelHttpRequest() {

        @Override
        public LowLevelHttpResponse execute() throws IOException {
            return response;
        }
    }).build();
    // A sample BigQuery API client that uses default JsonFactory and RetryHttpInitializer.
    bigquery = new Bigquery.Builder(transport, Transport.getJsonFactory(), new RetryHttpRequestInitializer()).build();
}
Also used : RetryHttpRequestInitializer(org.apache.beam.sdk.util.RetryHttpRequestInitializer) MockHttpTransport(com.google.api.client.testing.http.MockHttpTransport) MockLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest) Before(org.junit.Before)

Example 2 with RetryHttpRequestInitializer

use of org.apache.beam.sdk.util.RetryHttpRequestInitializer 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());
}
Also used : RetryHttpRequestInitializer(org.apache.beam.sdk.util.RetryHttpRequestInitializer) GcpOptions(org.apache.beam.sdk.extensions.gcp.options.GcpOptions) HttpCredentialsAdapter(com.google.auth.http.HttpCredentialsAdapter) DatastoreOptions(com.google.datastore.v1.client.DatastoreOptions) RetryHttpRequestInitializer(org.apache.beam.sdk.util.RetryHttpRequestInitializer) HttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer) ChainingHttpRequestInitializer(com.google.cloud.hadoop.util.ChainingHttpRequestInitializer) Credentials(com.google.auth.Credentials) ChainingHttpRequestInitializer(com.google.cloud.hadoop.util.ChainingHttpRequestInitializer)

Aggregations

RetryHttpRequestInitializer (org.apache.beam.sdk.util.RetryHttpRequestInitializer)2 HttpRequestInitializer (com.google.api.client.http.HttpRequestInitializer)1 MockHttpTransport (com.google.api.client.testing.http.MockHttpTransport)1 MockLowLevelHttpRequest (com.google.api.client.testing.http.MockLowLevelHttpRequest)1 Credentials (com.google.auth.Credentials)1 HttpCredentialsAdapter (com.google.auth.http.HttpCredentialsAdapter)1 ChainingHttpRequestInitializer (com.google.cloud.hadoop.util.ChainingHttpRequestInitializer)1 DatastoreOptions (com.google.datastore.v1.client.DatastoreOptions)1 GcpOptions (org.apache.beam.sdk.extensions.gcp.options.GcpOptions)1 Before (org.junit.Before)1