本文整理汇总了Java中org.apache.beam.runners.dataflow.options.DataflowPipelineOptions.getDataflowClient方法的典型用法代码示例。如果您正苦于以下问题:Java DataflowPipelineOptions.getDataflowClient方法的具体用法?Java DataflowPipelineOptions.getDataflowClient怎么用?Java DataflowPipelineOptions.getDataflowClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.beam.runners.dataflow.options.DataflowPipelineOptions
的用法示例。
在下文中一共展示了DataflowPipelineOptions.getDataflowClient方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRunReturnDifferentRequestId
import org.apache.beam.runners.dataflow.options.DataflowPipelineOptions; //导入方法依赖的package包/类
@Test
public void testRunReturnDifferentRequestId() throws IOException {
DataflowPipelineOptions options = buildPipelineOptions();
Dataflow mockDataflowClient = options.getDataflowClient();
Dataflow.Projects.Locations.Jobs.Create mockRequest = mock(
Dataflow.Projects.Locations.Jobs.Create.class);
when(mockDataflowClient.projects().locations().jobs()
.create(eq(PROJECT_ID), eq(REGION_ID), any(Job.class)))
.thenReturn(mockRequest);
Job resultJob = new Job();
resultJob.setId("newid");
// Return a different request id.
resultJob.setClientRequestId("different_request_id");
when(mockRequest.execute()).thenReturn(resultJob);
Pipeline p = buildDataflowPipeline(options);
try {
p.run();
fail("Expected DataflowJobAlreadyExistsException");
} catch (DataflowJobAlreadyExistsException expected) {
assertThat(expected.getMessage(),
containsString("If you want to submit a second job, try again by setting a "
+ "different name using --jobName."));
assertEquals(expected.getJob().getJobId(), resultJob.getId());
}
}
示例2: testUpdateAlreadyUpdatedPipeline
import org.apache.beam.runners.dataflow.options.DataflowPipelineOptions; //导入方法依赖的package包/类
@Test
public void testUpdateAlreadyUpdatedPipeline() throws IOException {
DataflowPipelineOptions options = buildPipelineOptions();
options.setUpdate(true);
options.setJobName("oldJobName");
Dataflow mockDataflowClient = options.getDataflowClient();
Dataflow.Projects.Locations.Jobs.Create mockRequest = mock(
Dataflow.Projects.Locations.Jobs.Create.class);
when(mockDataflowClient.projects().locations().jobs()
.create(eq(PROJECT_ID), eq(REGION_ID), any(Job.class)))
.thenReturn(mockRequest);
final Job resultJob = new Job();
resultJob.setId("newid");
// Return a different request id.
resultJob.setClientRequestId("different_request_id");
when(mockRequest.execute()).thenReturn(resultJob);
Pipeline p = buildDataflowPipeline(options);
thrown.expect(DataflowJobAlreadyUpdatedException.class);
thrown.expect(new TypeSafeMatcher<DataflowJobAlreadyUpdatedException>() {
@Override
public void describeTo(Description description) {
description.appendText("Expected job ID: " + resultJob.getId());
}
@Override
protected boolean matchesSafely(DataflowJobAlreadyUpdatedException item) {
return resultJob.getId().equals(item.getJob().getJobId());
}
});
thrown.expectMessage("The job named oldjobname with id: oldJobId has already been updated "
+ "into job id: newid and cannot be updated again.");
p.run();
}
示例3: create
import org.apache.beam.runners.dataflow.options.DataflowPipelineOptions; //导入方法依赖的package包/类
public static DataflowClient create(DataflowPipelineOptions options) {
return new DataflowClient(options.getDataflowClient(), options);
}