livy-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bjoernlohrmann <...@git.apache.org>
Subject [GitHub] incubator-livy pull request #128: [LIVY-533] Use setJobGroup/cancelJobGroup ...
Date Wed, 28 Nov 2018 22:05:24 GMT
Github user bjoernlohrmann commented on a diff in the pull request:

    https://github.com/apache/incubator-livy/pull/128#discussion_r237280060
  
    --- Diff: rsc/src/main/java/org/apache/livy/rsc/driver/JobWrapper.java ---
    @@ -39,20 +39,27 @@
     
       private final RSCDriver driver;
       private final Job<T> job;
    -  private final AtomicInteger completed;
     
    -  private Future<?> future;
    +  private volatile Future<?> future;
     
       public JobWrapper(RSCDriver driver, String jobId, Job<T> job) {
         this.driver = driver;
         this.jobId = jobId;
         this.job = job;
    -    this.completed = new AtomicInteger();
       }
     
       @Override
       public Void call() throws Exception {
         try {
    +      // this is synchronized to avoid races with cancel()
    --- End diff --
    
    `future` will only be null for synchronous bypass jobs, but those cannot be cancelled
unless I am mistaken?
    
    For async bypass jobs, I think `future` should always be non-null during `call()/cancel()`,
because it is assigned in `submit()` which also has the synchronized modifier and always runs
before `call()` or `cancel()`.
    
    I can add a boolean cancelled flag if you prefer, but this feels like duplicating information
that is already available in the future.


---

Mime
View raw message