如何从另一个管道中排出管道?

时间:2017-01-15 13:14:24

标签: java google-cloud-dataflow

我需要以编程方式从另一个管道中排出管道。 DataflowPipelineJob类没有实现drain方法。是否可以使用Java API在管道上调用drain

1 个答案:

答案 0 :(得分:4)

能够使用以下代码启动排水:

    // spawn child pipe
    DataflowPipelineRunner runner = DataflowPipelineRunner.fromOptions(options);
    DataflowPipelineJob job = runner.run(p);

    // under the some condition later, drain the spawned pipe:
    Dataflow client = com.google.cloud.dataflow.sdk.util.Transport.newDataflowClient(options).build();
    Job content = new Job();
    content.setProjectId(options.getProject());
    content.setId(job.getJobId());
    content.setRequestedState("JOB_STATE_DRAINING");
    client.projects().jobs()
            .update(options.getProject(), job.getJobId(), content)
            .execute();