@@ -258,8 +258,7 @@ public void taskCompleted(final ServerTaskBundleNode bundle, final Throwable thr
258
258
if (debugEnabled ) log .debug ("submissionStatus={}, clientBundles={} for {}" , getSubmissionStatus (), clientBundles .size (), this );
259
259
}
260
260
261
- /** //NioHelper.getGlobalexecutor().execute(r);
262
-
261
+ /**
263
262
* Perform the necessary actions for when this job has been cancelled.
264
263
*/
265
264
private void handleCancelledStatus () {
@@ -287,8 +286,9 @@ public void cancelDispatch(final ServerTaskBundleNode nodeBundle) {
287
286
288
287
/**
289
288
* 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.
290
290
*/
291
- private void handleCancelledTasks () {
291
+ private CollectionMap < ServerTaskBundleClient , ServerTask > handleCancelledTasks () {
292
292
if (debugEnabled ) log .debug ("cancelling tasks for {}" , this );
293
293
final CollectionMap <ServerTaskBundleClient , ServerTask > clientMap = new SetIdentityMap <>();
294
294
for (final ServerTask task : tasks ) {
@@ -297,32 +297,33 @@ private void handleCancelledTasks() {
297
297
clientMap .putValue (task .getBundle (), task );
298
298
}
299
299
}
300
- clientMap . forEach (( clientBundle , tasks ) -> clientBundle . resultReceived ( tasks )) ;
300
+ return clientMap ;
301
301
}
302
302
303
303
/**
304
304
* Cancel this job.
305
305
* @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.
308
308
*/
309
309
public boolean cancel (final JPPFDriver driver , final boolean mayInterruptIfRunning ) {
310
310
if (debugEnabled ) log .debug ("request to cancel {}" , this );
311
311
boolean result = false ;
312
+ CollectionMap <ServerTaskBundleClient , ServerTask > clientMap = null ;
312
313
lock .lock ();
313
314
try {
314
315
if (setCancelled (mayInterruptIfRunning )) {
315
316
handleCancelledStatus ();
316
- if (!getSLA ().isBroadcastJob ()) handleCancelledTasks ();
317
+ if (!getSLA ().isBroadcastJob ()) clientMap = handleCancelledTasks ();
317
318
setSubmissionStatus (SubmissionStatus .COMPLETE );
318
- //taskCompleted(null, null);
319
319
final NodeReservationHandler handler = driver .getAsyncNodeNioServer ().getNodeReservationHandler ();
320
320
handler .onJobCancelled (this );
321
321
result = true ;
322
322
}
323
323
} finally {
324
324
lock .unlock ();
325
325
}
326
+ if (clientMap != null ) clientMap .forEach ((clientBundle , tasks ) -> clientBundle .resultReceived (tasks ));
326
327
if (result ) setSubmissionStatus (SubmissionStatus .ENDED );
327
328
return result ;
328
329
}
0 commit comments