我需要以编程方式从另一个管道中排出管道。 DataflowPipelineJob
类没有实现drain
方法。是否可以使用Java API在管道上调用drain
?
答案 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();