Skip to content

Commit b1915fd

Browse files
committed
fixed bug JPPF-594
1 parent 9749fdf commit b1915fd

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

server/src/java/org/jppf/server/protocol/ServerJob.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ public void taskCompleted(final ServerTaskBundleNode bundle, final Throwable thr
258258
if (debugEnabled) log.debug("submissionStatus={}, clientBundles={} for {}", getSubmissionStatus(), clientBundles.size(), this);
259259
}
260260

261-
/** //NioHelper.getGlobalexecutor().execute(r);
262-
261+
/**
263262
* Perform the necessary actions for when this job has been cancelled.
264263
*/
265264
private void handleCancelledStatus() {
@@ -287,8 +286,9 @@ public void cancelDispatch(final ServerTaskBundleNode nodeBundle) {
287286

288287
/**
289288
* Perform the necessary actions for when this job has been cancelled.
289+
* @return a mapping of client bundles to the tasks that belong to them and were cacelled.
290290
*/
291-
private void handleCancelledTasks() {
291+
private CollectionMap<ServerTaskBundleClient, ServerTask> handleCancelledTasks() {
292292
if (debugEnabled) log.debug("cancelling tasks for {}", this);
293293
final CollectionMap<ServerTaskBundleClient, ServerTask> clientMap = new SetIdentityMap<>();
294294
for (final ServerTask task: tasks) {
@@ -297,32 +297,33 @@ private void handleCancelledTasks() {
297297
clientMap.putValue(task.getBundle(), task);
298298
}
299299
}
300-
clientMap.forEach((clientBundle, tasks) -> clientBundle.resultReceived(tasks));
300+
return clientMap;
301301
}
302302

303303
/**
304304
* Cancel this job.
305305
* @param driver reference to the JPPF driver.
306-
* @param mayInterruptIfRunning <code>true</code> if the job may be interrupted.
307-
* @return <code>true</code> if the job was effectively cncelled, <code>false</code> if it was already cancelled previously.
306+
* @param mayInterruptIfRunning {@code true} if the job may be interrupted.
307+
* @return {@code true} if the job was effectively cancelled, {@code false} if it was already cancelled previously.
308308
*/
309309
public boolean cancel(final JPPFDriver driver, final boolean mayInterruptIfRunning) {
310310
if (debugEnabled) log.debug("request to cancel {}", this);
311311
boolean result = false;
312+
CollectionMap<ServerTaskBundleClient, ServerTask> clientMap = null;
312313
lock.lock();
313314
try {
314315
if (setCancelled(mayInterruptIfRunning)) {
315316
handleCancelledStatus();
316-
if (!getSLA().isBroadcastJob()) handleCancelledTasks();
317+
if (!getSLA().isBroadcastJob()) clientMap = handleCancelledTasks();
317318
setSubmissionStatus(SubmissionStatus.COMPLETE);
318-
//taskCompleted(null, null);
319319
final NodeReservationHandler handler = driver.getAsyncNodeNioServer().getNodeReservationHandler();
320320
handler.onJobCancelled(this);
321321
result = true;
322322
}
323323
} finally {
324324
lock.unlock();
325325
}
326+
if (clientMap != null) clientMap.forEach((clientBundle, tasks) -> clientBundle.resultReceived(tasks));
326327
if (result) setSubmissionStatus(SubmissionStatus.ENDED);
327328
return result;
328329
}

0 commit comments

Comments
 (0)