Search in sources :

Example 1 with JobServerDriver

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();
    }
}
Also used : PortablePipelineOptions(org.apache.beam.sdk.options.PortablePipelineOptions) JobServerDriver(org.apache.beam.runners.jobsubmission.JobServerDriver) PipelineResult(org.apache.beam.sdk.PipelineResult) IOException(java.io.IOException) PortableRunner(org.apache.beam.runners.portability.PortableRunner)

Aggregations

IOException (java.io.IOException)1 JobServerDriver (org.apache.beam.runners.jobsubmission.JobServerDriver)1 PortableRunner (org.apache.beam.runners.portability.PortableRunner)1 PipelineResult (org.apache.beam.sdk.PipelineResult)1 PortablePipelineOptions (org.apache.beam.sdk.options.PortablePipelineOptions)1