nemo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-nemo] alapha23 commented on a change in pull request #187: [NEMO-324] Distinguish Beam's run and waitUntilFinish methods
Date Mon, 09 Sep 2019 06:18:36 GMT
alapha23 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_r322077917
 
 

 ##########
 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:
   Why do we have this line commented out here?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message