Search in sources :

Example 1 with ReadFromTableFn

use of bigtable.WorkloadGenerator.ReadFromTableFn in project java-docs-samples by GoogleCloudPlatform.

the class WorkloadGeneratorTest method testGenerateWorkload.

@Test
public void testGenerateWorkload() {
    BigtableWorkloadOptions options = PipelineOptionsFactory.create().as(BigtableWorkloadOptions.class);
    options.setBigtableInstanceId(instanceId);
    options.setBigtableTableId(TABLE_ID);
    options.setRegion(REGION_ID);
    Pipeline p = Pipeline.create(options);
    CloudBigtableTableConfiguration bigtableTableConfig = new CloudBigtableTableConfiguration.Builder().withProjectId(options.getProject()).withInstanceId(options.getBigtableInstanceId()).withTableId(options.getBigtableTableId()).build();
    // Initiates a new pipeline every second
    p.apply(Create.of(1L)).apply(ParDo.of(new ReadFromTableFn(bigtableTableConfig)));
    p.run().waitUntilFinish();
    String output = bout.toString();
    assertThat(output.contains("Connected to table"));
}
Also used : CloudBigtableTableConfiguration(com.google.cloud.bigtable.beam.CloudBigtableTableConfiguration) BigtableWorkloadOptions(bigtable.WorkloadGenerator.BigtableWorkloadOptions) ReadFromTableFn(bigtable.WorkloadGenerator.ReadFromTableFn) Pipeline(org.apache.beam.sdk.Pipeline) Test(org.junit.Test)

Aggregations

BigtableWorkloadOptions (bigtable.WorkloadGenerator.BigtableWorkloadOptions)1 ReadFromTableFn (bigtable.WorkloadGenerator.ReadFromTableFn)1 CloudBigtableTableConfiguration (com.google.cloud.bigtable.beam.CloudBigtableTableConfiguration)1 Pipeline (org.apache.beam.sdk.Pipeline)1 Test (org.junit.Test)1