Skip to content

Commit

Permalink
bug JPPF-537 adding missing cancellation checks (b_5_2)
Browse files Browse the repository at this point in the history
  • Loading branch information
lolocohen committed Jul 4, 2018
1 parent 70d6ca5 commit c7f2689
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion client/src/java/org/jppf/client/balancer/AbstractClientJob.java
Expand Up @@ -377,7 +377,7 @@ public void removeChannel(final ExecutorChannel channel) {
public boolean acceptsChannel(final ExecutorChannel channel) {
if (traceEnabled) log.trace(String.format("job '%s' : cancelled=%b, cancelling=%b, pending=%b, expired=%b, nb channels=%d, max channels=%d",
job.getName(), isCancelled(), isCancelling(), isPending(), isJobExpired(), channelsCount.get(), clientSla.getMaxChannels()));
if (isCancelled() || isPending() || isJobExpired() || (channelsCount.get() >= clientSla.getMaxChannels())) return false;
if (isCancelling() || isCancelled() || isPending() || isJobExpired() || (channelsCount.get() >= clientSla.getMaxChannels())) return false;
ExecutionPolicy policy = clientSla.getExecutionPolicy();
boolean b = true;
if (policy != null) {
Expand Down Expand Up @@ -428,4 +428,12 @@ boolean isChildBroadcastJob() {
public boolean isCancelling() {
return (job == null) ? false : job.getCancellingFlag().get();
}

/**
* Whether this job is being cancelled or has already been cancelled.
* @return {@code true} a cancellation request is being or has been processed, {@code false} otherwise.
*/
public boolean isCancellingOrCancelled() {
return isCancelling() || isCancelled();
}
}
Expand Up @@ -225,12 +225,13 @@ public boolean dispatch() {
Iterator<ClientJob> it = queue.iterator();
while ((channel == null) && it.hasNext() && !idleChannels.isEmpty()) {
ClientJob bundleWrapper = it.next();
if (bundleWrapper.isCancelled() || bundleWrapper.isCancelling()) continue;
if (bundleWrapper.isCancellingOrCancelled()) continue;
channel = findIdleChannelIndex(bundleWrapper);
if (bundleWrapper.isCancellingOrCancelled()) continue;
if (channel != null) selectedBundle = bundleWrapper;
}
if (debugEnabled) log.debug((channel == null) ? "no channel found for bundle" : "channel found for bundle: " + channel);
if (channel != null) {
if ((channel != null) && !selectedBundle.isCancellingOrCancelled()) {
dispatchJobToChannel(channel, selectedBundle);
dispatched = true;
}
Expand Down

0 comments on commit c7f2689

Please sign in to comment.