You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@livy.apache.org by bjoernlohrmann <gi...@git.apache.org> on 2018/11/28 22:05:24 UTC
[GitHub] incubator-livy pull request #128: [LIVY-533] Use setJobGroup/cancelJobGroup ...
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.
---