wonook commented on a change in pull request #187: [NEMO-324] Distinguish Beam's run and waitUntilFinish methods URL: https://github.com/apache/incubator-nemo/pull/187#discussion_r377466751
########## File path: examples/beam/src/main/java/org/apache/nemo/examples/beam/WordCountTimeOut1Sec.java ########## @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.nemo.examples.beam; + +import org.apache.beam.sdk.Pipeline; +import org.apache.beam.sdk.options.PipelineOptions; + +import static org.apache.nemo.examples.beam.WordCount.generateWordCountPipeline; + +/** + * WordCount application, but with a timeout of 1 second. + */ +public final class WordCountTimeOut1Sec { + + /** + * Private constructor. + */ + private WordCountTimeOut1Sec() { + } + + /** + * Main function for the MR BEAM program. + * + * @param args arguments. + */ + public static void main(final String[] args) { + final String inputFilePath = args[0]; + final String outputFilePath = args[1]; + final PipelineOptions options = NemoPipelineOptionsFactory.create(); + options.setJobName("WordCountTimeOut1Sec"); + + final Pipeline p = generateWordCountPipeline(options, inputFilePath, outputFilePath); + p.run().waitUntilFinish(org.joda.time.Duration.standardSeconds(1)); Review comment: Sorry for the belated reply. As mentioned in line 84 of `NemoPipelineResult` file, `LOG.warn("Job timed out before {}ms, while waiting until finish. Call 'cancel' to cancel the job."` the timeout and cancelling of the job happens separately. I think you have been expecting the job to have been automatically cancelled on timeout, but to provide more control I think Beam separates these two functionalities distinctly. In order to cancel upon timeout, we should call: ``` final NemoPipelineResult pr = p.run(); final Status s1 = pr.waitUntilFinish((org.joda.time.Duration.standardSeconds(1)); // PipelineResult is in status 'RUNNING' final Status s2 = pr.cancel(); // status is 'CANCELLED' ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
