use of com.google.cloud.bigquery.BigQueryOptions in project google-cloud-java by GoogleCloudPlatform.
the class RemoteBigQueryHelperTest method testCreateFromStream.
@Test
public void testCreateFromStream() {
RemoteBigQueryHelper helper = RemoteBigQueryHelper.create(PROJECT_ID, JSON_KEY_STREAM);
BigQueryOptions options = helper.getOptions();
assertEquals(PROJECT_ID, options.getProjectId());
assertEquals(60000, ((HttpTransportOptions) options.getTransportOptions()).getConnectTimeout());
assertEquals(60000, ((HttpTransportOptions) options.getTransportOptions()).getReadTimeout());
assertEquals(10, options.getRetrySettings().getMaxAttempts());
assertEquals(Duration.ofMillis(30000), options.getRetrySettings().getMaxRetryDelay());
assertEquals(Duration.ofMillis(120000), options.getRetrySettings().getTotalTimeout());
assertEquals(Duration.ofMillis(250), options.getRetrySettings().getInitialRetryDelay());
}
use of com.google.cloud.bigquery.BigQueryOptions in project beam by apache.
the class BigQueryIOIT method tearDown.
@AfterClass
public static void tearDown() {
BigQueryOptions options = BigQueryOptions.newBuilder().build();
BigQuery client = options.getService();
TableId tableId = TableId.of(options.getProjectId(), testBigQueryDataset, testBigQueryTable);
client.delete(tableId);
}
use of com.google.cloud.bigquery.BigQueryOptions in project google-cloud-java by GoogleCloudPlatform.
the class RemoteBigQueryHelper method create.
/**
* Creates a {@code RemoteBigQueryHelper} object using default project id and authentication
* credentials.
*/
public static RemoteBigQueryHelper create() {
HttpTransportOptions transportOptions = BigQueryOptions.getDefaultHttpTransportOptions();
transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
BigQueryOptions bigqueryOptions = BigQueryOptions.newBuilder().setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
return new RemoteBigQueryHelper(bigqueryOptions);
}
use of com.google.cloud.bigquery.BigQueryOptions in project google-cloud-java by GoogleCloudPlatform.
the class RemoteBigQueryHelper method create.
/**
* Creates a {@code RemoteBigQueryHelper} object for the given project id and JSON key input
* stream.
*
* @param projectId id of the project to be used for running the tests
* @param keyStream input stream for a JSON key
* @return A {@code RemoteBigQueryHelper} object for the provided options
* @throws BigQueryHelperException if {@code keyStream} is not a valid JSON key stream
*/
public static RemoteBigQueryHelper create(String projectId, InputStream keyStream) throws BigQueryHelperException {
try {
HttpTransportOptions transportOptions = BigQueryOptions.getDefaultHttpTransportOptions();
transportOptions = transportOptions.toBuilder().setConnectTimeout(60000).setReadTimeout(60000).build();
BigQueryOptions bigqueryOptions = BigQueryOptions.newBuilder().setCredentials(ServiceAccountCredentials.fromStream(keyStream)).setProjectId(projectId).setRetrySettings(retrySettings()).setTransportOptions(transportOptions).build();
return new RemoteBigQueryHelper(bigqueryOptions);
} catch (IOException ex) {
if (log.isLoggable(Level.WARNING)) {
log.log(Level.WARNING, ex.getMessage());
}
throw BigQueryHelperException.translate(ex);
}
}
use of com.google.cloud.bigquery.BigQueryOptions in project beam by apache.
the class BigQueryIOIT method setup.
@BeforeClass
public static void setup() throws IOException {
options = IOITHelper.readIOTestPipelineOptions(BigQueryPerfTestOptions.class);
tempRoot = options.getTempRoot();
sourceOptions = SyntheticOptions.fromJsonString(options.getSourceOptions(), SyntheticSourceOptions.class);
testBigQueryDataset = options.getTestBigQueryDataset();
testBigQueryTable = options.getTestBigQueryTable();
writeFormat = WriteFormat.valueOf(options.getWriteFormat());
BigQueryOptions bigQueryOptions = BigQueryOptions.newBuilder().build();
tableQualifier = String.format("%s:%s.%s", bigQueryOptions.getProjectId(), testBigQueryDataset, testBigQueryTable);
settings = InfluxDBSettings.builder().withHost(options.getInfluxHost()).withDatabase(options.getInfluxDatabase()).withMeasurement(options.getInfluxMeasurement()).get();
}
Aggregations