File tree Expand file tree Collapse file tree
hugegraph-core/src/main/java/org/apache/hugegraph/task
hugegraph-test/src/main/java/org/apache/hugegraph/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -295,6 +295,12 @@ protected <V> void initTaskParams(HugeTask<V> task) {
295295 }
296296 }
297297
298+ /**
299+ * Note: This method will update the status of the input task.
300+ *
301+ * @param task
302+ * @param <V>
303+ */
298304 @ Override
299305 public <V > void cancel (HugeTask <V > task ) {
300306 E .checkArgumentNotNull (task , "Task can't be null" );
@@ -309,6 +315,9 @@ public <V> void cancel(HugeTask<V> task) {
309315 HugeTask <?> runningTask = this .runningTasks .get (task .id ());
310316 if (runningTask != null ) {
311317 boolean cancelled = runningTask .cancel (true );
318+ if (cancelled ) {
319+ task .overwriteStatus (TaskStatus .CANCELLED );
320+ }
312321 LOG .info ("Cancel local running task '{}' result: {}" , task .id (), cancelled );
313322 return ;
314323 }
@@ -319,6 +328,8 @@ public <V> void cancel(HugeTask<V> task) {
319328 if (!this .updateStatus (task .id (), currentStatus , TaskStatus .CANCELLING )) {
320329 LOG .info ("Failed to cancel task '{}', status may have changed from {}" ,
321330 task .id (), currentStatus );
331+ } else {
332+ task .overwriteStatus (TaskStatus .CANCELLING );
322333 }
323334 }
324335
Original file line number Diff line number Diff line change 2929import org .apache .hugegraph .job .EphemeralJobBuilder ;
3030import org .apache .hugegraph .job .GremlinJob ;
3131import org .apache .hugegraph .job .JobBuilder ;
32- import org .apache .hugegraph .task .*;
32+ import org .apache .hugegraph .task .StandardTaskScheduler ;
33+ import org .apache .hugegraph .task .HugeTask ;
34+ import org .apache .hugegraph .task .TaskCallable ;
35+ import org .apache .hugegraph .task .TaskScheduler ;
36+ import org .apache .hugegraph .task .TaskStatus ;
3337import org .apache .hugegraph .testutil .Assert ;
3438import org .apache .hugegraph .testutil .Whitebox ;
3539import org .junit .Before ;
You can’t perform that action at this time.
0 commit comments