diff --git a/hugegraph-api/pom.xml b/hugegraph-api/pom.xml
index a78ffe3263..36b837946e 100644
--- a/hugegraph-api/pom.xml
+++ b/hugegraph-api/pom.xml
@@ -101,7 +101,7 @@
- 0.29.0.0
+ 0.30.0.0
diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/job/TaskAPI.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/job/TaskAPI.java
index 56b85a42f1..f55eb4e113 100644
--- a/hugegraph-api/src/main/java/com/baidu/hugegraph/api/job/TaskAPI.java
+++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/api/job/TaskAPI.java
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import javax.inject.Singleton;
import javax.ws.rs.BadRequestException;
@@ -42,6 +43,7 @@
import com.baidu.hugegraph.api.API;
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
+import com.baidu.hugegraph.backend.id.Id;
import com.baidu.hugegraph.backend.id.IdGenerator;
import com.baidu.hugegraph.core.GraphManager;
import com.baidu.hugegraph.server.RestServer;
@@ -58,6 +60,7 @@
public class TaskAPI extends API {
private static final Logger LOG = Log.logger(RestServer.class);
+ private static final long NO_LIMIT = -1L;
public static final String ACTION_CANCEL = "cancel";
@@ -67,6 +70,7 @@ public class TaskAPI extends API {
public Map> list(@Context GraphManager manager,
@PathParam("graph") String graph,
@QueryParam("status") String status,
+ @QueryParam("ids") List ids,
@QueryParam("limit")
@DefaultValue("100") long limit) {
LOG.debug("Graph [{}] list tasks with status {}, limit {}",
@@ -75,16 +79,35 @@ public Map> list(@Context GraphManager manager,
TaskScheduler scheduler = graph(manager, graph).taskScheduler();
Iterator> itor;
- if (status == null) {
- itor = scheduler.findAllTask(limit);
+
+ if (!ids.isEmpty()) {
+ LOG.debug("Graph [{}] list tasks with ids {}, limit {}",
+ graph, ids, limit);
+ E.checkArgument(status == null,
+ "Not support status when query task by ids, " +
+ "but got status='%s'", status);
+ // Set limit to NO_LIMIT to ignore limit when query task by ids
+ limit = NO_LIMIT;
+ List idList = ids.stream().map(IdGenerator::of)
+ .collect(Collectors.toList());
+ itor = scheduler.tasks(idList);
} else {
- itor = scheduler.findTask(parseStatus(status), limit);
+ LOG.debug("Graph [{}] list tasks with status {}, limit {}",
+ graph, status, limit);
+ if (status == null) {
+ itor = scheduler.findAllTask(limit);
+ } else {
+ itor = scheduler.findTask(parseStatus(status), limit);
+ }
}
List