GET http://localhost:8080/graphs/hugegraph/tasks?status=success
200
{ "tasks": [{ "task_name": "hugegraph.traversal().V()", "task_progress": 0, "task_create": 1532943976585, "task_status": "success", "task_update": 1532943976736, "task_result": "0", "task_retries": 0, "id": 2, "task_type": "gremlin", "task_callable": "com.baidu.hugegraph.api.job.GremlinAPI$GremlinJob", "task_input": "{\"gremlin\":\"hugegraph.traversal().V()\",\"bindings\":{},\"language\":\"gremlin-groovy\",\"aliases\":{\"hugegraph\":\"graph\"}}" }] }
GET http://localhost:8080/graphs/hugegraph/tasks/2
200
{ "task_name": "hugegraph.traversal().V()", "task_progress": 0, "task_create": 1532943976585, "task_status": "success", "task_update": 1532943976736, "task_result": "0", "task_retries": 0, "id": 2, "task_type": "gremlin", "task_callable": "com.baidu.hugegraph.api.job.GremlinAPI$GremlinJob", "task_input": "{\"gremlin\":\"hugegraph.traversal().V()\",\"bindings\":{},\"language\":\"gremlin-groovy\",\"aliases\":{\"hugegraph\":\"graph\"}}" }
DELETE http://localhost:8080/graphs/hugegraph/tasks/2
204
假设已经通过Gremlin API创建了一个异步任务如下:
"for (int i = 0; i < 10; i++) {" + "hugegraph.addVertex(T.label, 'man');" + "hugegraph.tx().commit();" + "try {" + "sleep(1000);" + "} catch (InterruptedException e) {" + "break;" + "}" + "}"
PUT http://localhost:8080/graphs/hugegraph/tasks/2?action=cancel
请保证在10秒内发送该请求,如果超过10秒发送,任务可能已经执行完成,无法取消。
202
{ "cancelled": true }
此时查询 label 为 man 的顶点数目,一定是小于 10 的。