use of org.apache.beam.runners.jobsubmission.JobServerDriver in project beam by apache.
the class TestPortableRunner method run.
@Override
public PipelineResult run(Pipeline pipeline) {
TestPortablePipelineOptions testPortablePipelineOptions = options.as(TestPortablePipelineOptions.class);
String jobServerHostPort;
JobServerDriver jobServerDriver;
Class<JobServerDriver> jobServerDriverClass = testPortablePipelineOptions.getJobServerDriver();
String[] parameters = testPortablePipelineOptions.getJobServerConfig();
try {
jobServerDriver = InstanceBuilder.ofType(jobServerDriverClass).fromFactoryMethod("fromParams").withArg(String[].class, parameters).build();
jobServerHostPort = jobServerDriver.start();
} catch (IOException e) {
throw new RuntimeException("Failed to start job server", e);
}
try {
PortablePipelineOptions portableOptions = options.as(PortablePipelineOptions.class);
portableOptions.setRunner(PortableRunner.class);
portableOptions.setJobEndpoint(jobServerHostPort);
PortableRunner runner = PortableRunner.fromOptions(portableOptions);
PipelineResult result = runner.run(pipeline);
assertThat("Pipeline did not succeed.", result.waitUntilFinish(), Matchers.is(State.DONE));
return result;
} finally {
jobServerDriver.stop();
}
}
Aggregations