Search in sources :

Example 1 with GremlinRequest

use of com.baidu.hugegraph.api.job.GremlinAPI.GremlinRequest in project incubator-hugegraph by apache.

the class TaskCoreTest method testGremlinJob.

@Test
public void testGremlinJob() throws TimeoutException {
    HugeGraph graph = graph();
    TaskScheduler scheduler = graph.taskScheduler();
    GremlinRequest request = new GremlinRequest();
    request.gremlin("sleep(100); 3 + 5");
    JobBuilder<Object> builder = JobBuilder.of(graph);
    builder.name("test-job-gremlin").input(request.toJson()).job(new GremlinJob());
    HugeTask<Object> task = builder.schedule();
    Assert.assertEquals("test-job-gremlin", task.name());
    Assert.assertEquals("gremlin", task.type());
    Assert.assertFalse(task.completed());
    Assert.assertNull(task.result());
    task = scheduler.waitUntilTaskCompleted(task.id(), 10);
    Assert.assertEquals("test-job-gremlin", task.name());
    Assert.assertEquals("gremlin", task.type());
    Assert.assertEquals(TaskStatus.SUCCESS, task.status());
    Assert.assertEquals("8", task.result());
    task = scheduler.task(task.id());
    Assert.assertEquals("test-job-gremlin", task.name());
    Assert.assertEquals("gremlin", task.type());
    Assert.assertEquals(TaskStatus.SUCCESS, task.status());
    Assert.assertEquals("8", task.result());
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) GremlinJob(com.baidu.hugegraph.job.GremlinJob) GremlinRequest(com.baidu.hugegraph.api.job.GremlinAPI.GremlinRequest) TaskScheduler(com.baidu.hugegraph.task.TaskScheduler) Test(org.junit.Test)

Example 2 with GremlinRequest

use of com.baidu.hugegraph.api.job.GremlinAPI.GremlinRequest in project incubator-hugegraph by apache.

the class TaskCoreTest method runGremlinJob.

private HugeTask<Object> runGremlinJob(String gremlin) {
    HugeGraph graph = graph();
    GremlinRequest request = new GremlinRequest();
    request.gremlin(gremlin);
    JobBuilder<Object> builder = JobBuilder.of(graph);
    builder.name("test-gremlin-job").input(request.toJson()).job(new GremlinJob());
    return builder.schedule();
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) GremlinJob(com.baidu.hugegraph.job.GremlinJob) GremlinRequest(com.baidu.hugegraph.api.job.GremlinAPI.GremlinRequest)

Aggregations

HugeGraph (com.baidu.hugegraph.HugeGraph)2 GremlinRequest (com.baidu.hugegraph.api.job.GremlinAPI.GremlinRequest)2 GremlinJob (com.baidu.hugegraph.job.GremlinJob)2 TaskScheduler (com.baidu.hugegraph.task.TaskScheduler)1 Test (org.junit.Test)1