Skip to content

Version 1.7 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot. For up-to-date documentation, see the latest version.

Task API

7.1 Task

7.1.1 List all async tasks in graph

Params
  • status: the status of asyncTasks
  • limit: the max number of tasks to return
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks?status=success
Response Status
1200
Response Body
 1{
 2	"tasks": [{
 3		"task_name": "hugegraph.traversal().V()",
 4		"task_progress": 0,
 5		"task_create": 1532943976585,
 6		"task_status": "success",
 7		"task_update": 1532943976736,
 8		"task_result": "0",
 9		"task_retries": 0,
10		"id": 2,
11		"task_type": "gremlin",
12		"task_callable": "org.apache.hugegraph.api.job.GremlinAPI$GremlinJob",
13		"task_input": "{\"gremlin\":\"hugegraph.traversal().V()\",\"bindings\":{},\"language\":\"gremlin-groovy\",\"aliases\":{\"hugegraph\":\"graph\"}}"
14	}]
15}

7.1.2 View the details of an async task

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2
Response Status
1200
Response Body
 1{
 2	"task_name": "hugegraph.traversal().V()",
 3	"task_progress": 0,
 4	"task_create": 1532943976585,
 5	"task_status": "success",
 6	"task_update": 1532943976736,
 7	"task_result": "0",
 8	"task_retries": 0,
 9	"id": 2,
10	"task_type": "gremlin",
11	"task_callable": "org.apache.hugegraph.api.job.GremlinAPI$GremlinJob",
12	"task_input": "{\"gremlin\":\"hugegraph.traversal().V()\",\"bindings\":{},\"language\":\"gremlin-groovy\",\"aliases\":{\"hugegraph\":\"graph\"}}"
13}

7.1.3 Delete task information of an async task,won’t delete the task itself

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2
Response Status
1204

7.1.4 Cancel an async task, the task should be able to be canceled

If you already created an async task via Gremlin API as follows:

1"for (int i = 0; i < 10; i++) {" +
2    "hugegraph.addVertex(T.label, 'man');" +
3    "hugegraph.tx().commit();" +
4    "try {" +
5        "sleep(1000);" +
6    "} catch (InterruptedException e) {" +
7        "break;" +
8    "}" +
9"}"
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2?action=cancel

cancel it in 10s. if more than 10s, the task may already be finished, then can’t be cancelled.

Response Status
1202
Response Body
1{
2    "cancelled": true
3}

At this point, the number of vertices whose label is man must be less than 10.