Search in sources :

Example 1 with Shard

use of com.baidu.hugegraph.structure.graph.Shard in project incubator-hugegraph-toolchain by apache.

the class CommonTraverserApiTest method testScanEdgeInPagingWithNegativeLimit.

@Test
public void testScanEdgeInPagingWithNegativeLimit() {
    List<Shard> shards = edgesAPI.shards(1 * 1024 * 1024);
    for (Shard shard : shards) {
        String page = "";
        Assert.assertThrows(ServerException.class, () -> {
            edgesAPI.scan(shard, page, -1);
        }, e -> {
            String expect = "Invalid limit -1";
            Assert.assertContains(expect, e.getMessage());
        });
    }
}
Also used : Shard(com.baidu.hugegraph.structure.graph.Shard) Test(org.junit.Test) BaseApiTest(com.baidu.hugegraph.api.BaseApiTest)

Example 2 with Shard

use of com.baidu.hugegraph.structure.graph.Shard in project incubator-hugegraph-toolchain by apache.

the class CommonTraverserApiTest method testScanVertexInPagingWithNegativeLimit.

@Test
public void testScanVertexInPagingWithNegativeLimit() {
    List<Shard> shards = verticesAPI.shards(1 * 1024 * 1024);
    for (Shard shard : shards) {
        String page = "";
        Assert.assertThrows(ServerException.class, () -> {
            verticesAPI.scan(shard, page, -1);
        }, e -> {
            Assert.assertContains("Invalid limit -1", e.getMessage());
        });
    }
}
Also used : Shard(com.baidu.hugegraph.structure.graph.Shard) Test(org.junit.Test) BaseApiTest(com.baidu.hugegraph.api.BaseApiTest)

Example 3 with Shard

use of com.baidu.hugegraph.structure.graph.Shard in project incubator-hugegraph-toolchain by apache.

the class CommonTraverserApiTest method testScanEdgeInPaging.

@Test
public void testScanEdgeInPaging() {
    List<Shard> shards = edgesAPI.shards(1 * 1024 * 1024);
    List<Edge> edges = new LinkedList<>();
    for (Shard shard : shards) {
        String page = "";
        while (page != null) {
            Edges results = edgesAPI.scan(shard, page, DEFAULT_PAGE_LIMIT);
            edges.addAll(ImmutableList.copyOf(results.results()));
            page = results.page();
        }
    }
    Assert.assertEquals(6, edges.size());
}
Also used : Shard(com.baidu.hugegraph.structure.graph.Shard) Edge(com.baidu.hugegraph.structure.graph.Edge) Edges(com.baidu.hugegraph.structure.graph.Edges) LinkedList(java.util.LinkedList) Test(org.junit.Test) BaseApiTest(com.baidu.hugegraph.api.BaseApiTest)

Example 4 with Shard

use of com.baidu.hugegraph.structure.graph.Shard in project incubator-hugegraph-toolchain by apache.

the class CommonTraverserApiTest method testScanEdge.

@Test
public void testScanEdge() {
    List<Shard> shards = edgesAPI.shards(1 * 1024 * 1024);
    List<Edge> edges = new LinkedList<>();
    for (Shard shard : shards) {
        Edges results = edgesAPI.scan(shard, null, 0L);
        Assert.assertNull(results.page());
        edges.addAll(ImmutableList.copyOf(results.results()));
    }
    Assert.assertEquals(6, edges.size());
}
Also used : Shard(com.baidu.hugegraph.structure.graph.Shard) Edge(com.baidu.hugegraph.structure.graph.Edge) Edges(com.baidu.hugegraph.structure.graph.Edges) LinkedList(java.util.LinkedList) Test(org.junit.Test) BaseApiTest(com.baidu.hugegraph.api.BaseApiTest)

Example 5 with Shard

use of com.baidu.hugegraph.structure.graph.Shard in project incubator-hugegraph-toolchain by apache.

the class BackupManager method backupVertices.

protected void backupVertices() {
    Printer.print("Vertices backup started");
    Printer.printInBackward("Vertices has been backup: ");
    List<Shard> shards = retry(() -> this.client.traverser().vertexShards(splitSize()), "querying shards of vertices");
    this.writeShards(this.allShardsLog(HugeType.VERTEX), shards);
    for (Shard shard : shards) {
        this.backupVertexShardAsync(shard);
    }
    this.awaitTasks();
    this.postProcessFailedShard(HugeType.VERTEX);
    Printer.print("%d", this.vertexCounter.get());
    Printer.print("Vertices backup finished: %d", this.vertexCounter.get());
}
Also used : Shard(com.baidu.hugegraph.structure.graph.Shard)

Aggregations

Shard (com.baidu.hugegraph.structure.graph.Shard)13 Test (org.junit.Test)8 BaseApiTest (com.baidu.hugegraph.api.BaseApiTest)6 LinkedList (java.util.LinkedList)6 Edge (com.baidu.hugegraph.structure.graph.Edge)3 Vertex (com.baidu.hugegraph.structure.graph.Vertex)3 ArrayList (java.util.ArrayList)3 BaseClientTest (com.baidu.hugegraph.BaseClientTest)2 InputSplit (com.baidu.hugegraph.computer.core.input.InputSplit)2 Edges (com.baidu.hugegraph.structure.graph.Edges)2 Vertices (com.baidu.hugegraph.structure.graph.Vertices)2 ToolsException (com.baidu.hugegraph.exception.ToolsException)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1