Search in sources :

Example 21 with TaskScheduler

use of com.baidu.hugegraph.task.TaskScheduler in project incubator-hugegraph by apache.

the class VertexLabelCoreTest method testRemoveVertexLabelUsedByEdgeLabel.

@Test
public void testRemoveVertexLabelUsedByEdgeLabel() {
    super.initPropertyKeys();
    SchemaManager schema = graph().schema();
    schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("city").create();
    schema.vertexLabel("book").properties("name").primaryKeys("name").create();
    schema.edgeLabel("write").link("person", "book").properties("time", "weight").create();
    Vertex marko = graph().addVertex(T.label, "person", "name", "marko", "age", 22);
    Vertex java = graph().addVertex(T.label, "book", "name", "java in action");
    marko.addEdge("write", java, "time", "2016-12-12", "weight", 0.3);
    TaskScheduler scheduler = graph().taskScheduler();
    Id id = schema.vertexLabel("person").remove();
    sleepAWhile(100L);
    HugeTask<?> task = scheduler.task(id);
    Assert.assertEquals(TaskStatus.FAILED, task.status());
    Assert.assertContains("Not allowed to remove vertex label " + "'person' because the edge label 'write' " + "still link with it", task.result());
    id = schema.vertexLabel("book").remove();
    sleepAWhile(100L);
    task = scheduler.task(id);
    Assert.assertEquals(TaskStatus.FAILED, task.status());
    Assert.assertContains("Not allowed to remove vertex label 'book' " + "because the edge label 'write' still link " + "with it", task.result());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Id(com.baidu.hugegraph.backend.id.Id) TaskScheduler(com.baidu.hugegraph.task.TaskScheduler) Test(org.junit.Test)

Aggregations

TaskScheduler (com.baidu.hugegraph.task.TaskScheduler)21 HugeGraph (com.baidu.hugegraph.HugeGraph)10 Test (org.junit.Test)10 HugeTask (com.baidu.hugegraph.task.HugeTask)8 Id (com.baidu.hugegraph.backend.id.Id)7 Timed (com.codahale.metrics.annotation.Timed)4 Path (jakarta.ws.rs.Path)3 Produces (jakarta.ws.rs.Produces)3 HugeException (com.baidu.hugegraph.HugeException)2 GremlinJob (com.baidu.hugegraph.job.GremlinJob)2 SchemaManager (com.baidu.hugegraph.schema.SchemaManager)2 TaskCallable (com.baidu.hugegraph.task.TaskCallable)2 GET (jakarta.ws.rs.GET)2 TimeoutException (java.util.concurrent.TimeoutException)2 Status (com.baidu.hugegraph.api.filter.StatusFilter.Status)1 GremlinRequest (com.baidu.hugegraph.api.job.GremlinAPI.GremlinRequest)1 NotFoundException (com.baidu.hugegraph.exception.NotFoundException)1 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)1 TaskStatus (com.baidu.hugegraph.task.TaskStatus)1 BadRequestException (jakarta.ws.rs.BadRequestException)1