Skip to content

Commit 5807fb7

Browse files
committed
fix(server): fix some issues of the distributed scheduler
1 parent d89b9bd commit 5807fb7

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/DistributedTaskScheduler.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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

hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/TaskCoreTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
import org.apache.hugegraph.job.EphemeralJobBuilder;
3030
import org.apache.hugegraph.job.GremlinJob;
3131
import 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;
3337
import org.apache.hugegraph.testutil.Assert;
3438
import org.apache.hugegraph.testutil.Whitebox;
3539
import org.junit.Before;

0 commit comments

Comments
 (0)