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_r326232033
##########
File path:
client/src/main/java/org/apache/nemo/client/beam/NemoPipelineResult.java
##########
@@ -44,14 +59,36 @@ public State getState() {
@Override
public State cancel() throws IOException {
- throw new UnsupportedOperationException("cancel() in
frontend.beam.NemoPipelineResult");
+ try {
+ JobLauncher.shutdown();
+ this.jobDone.await();
+ return State.CANCELLED;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
@Override
public State waitUntilFinish(final Duration duration) {
- throw new UnsupportedOperationException();
- // TODO #208: NemoPipelineResult#waitUntilFinish hangs
- // Previous code that hangs the job:
+ try {
+ if (duration.getMillis() < 1) {
+ this.jobDone.await();
+ return State.DONE;
+ } else {
+ final boolean finished = this.jobDone.await(duration.getMillis(),
TimeUnit.MILLISECONDS);
+ if (finished) {
+ LOG.info("Job successfully finished before timeout of {}ms, while
waiting until finish",
+ duration.getMillis());
+ return State.DONE;
+ } else {
+ LOG.warn("Job timed out before {}ms, while waiting until finish.
Call 'cancel' to cancel the job.",
+ duration.getMillis());
+ return State.RUNNING;
+ }
+ }
+ } catch (final Exception e) {
+ throw new RuntimeException(e);
+ }
// return (State) super.waitUntilJobFinish(duration.getMillis(),
TimeUnit.MILLISECONDS);
Review comment:
Yes, this wasn't part of the PR, so I think it could be handled on a
separate issue.
----------------------------------------------------------------
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