当前位置: 首页>>代码示例>>Java>>正文


Java DataflowPipelineOptions.getDataflowClient方法代码示例

本文整理汇总了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());
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:27,代码来源:DataflowRunnerTest.java

示例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();
}
 
开发者ID:apache,项目名称:beam,代码行数:36,代码来源:DataflowRunnerTest.java

示例3: create

import org.apache.beam.runners.dataflow.options.DataflowPipelineOptions; //导入方法依赖的package包/类
public static DataflowClient create(DataflowPipelineOptions options) {
  return new DataflowClient(options.getDataflowClient(), options);
}
 
开发者ID:apache,项目名称:beam,代码行数:4,代码来源:DataflowClient.java


注:本文中的org.apache.beam.runners.dataflow.options.DataflowPipelineOptions.getDataflowClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。