使用hugeclient 出现超时Read timed out,貌似是因为数据量太大,十几万条边都不能返回了
Expected behavior 期望表现
能否更改超时设置
Actual behavior 实际表现
出现超时
Steps to reproduce the problem 复现步骤
- 使用List
list = graph.listEdges() 查询满足某个条件的所有边,发现数量在十几万时就会Read timed out Exception in thread "main" com.baidu.hugegraph.rest.ClientException: Failed to do request at com.baidu.hugegraph.rest.RestClient.request(RestClient.java:69) at com.baidu.hugegraph.rest.RestClient.get(RestClient.java:166) at com.baidu.hugegraph.api.graph.EdgeAPI.list(EdgeAPI.java:108) at com.baidu.hugegraph.driver.GraphManager.getEdges(GraphManager.java:273) at com.baidu.hugegraph.driver.GraphManager.listEdges(GraphManager.java:220) at BatchExample.delete_day_edge(BatchExample.java:26) at BatchExample.main(BatchExample.java:43) Caused by: javax.ws.rs.ProcessingException: java.net.SocketTimeoutException: Read timed out at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:287) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:252) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:684) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:681) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:228) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:681) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:411) at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:311) at com.baidu.hugegraph.rest.RestClient.lambda$get$3(RestClient.java:167) at com.baidu.hugegraph.rest.RestClient.request(RestClient.java:67) ... 6 more Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) at java.net.SocketInputStream.read(SocketInputStream.java:171) at java.net.SocketInputStream.read(SocketInputStream.java:141) at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) at java.io.BufferedInputStream.read1(BufferedInputStream.java:286) at java.io.BufferedInputStream.read(BufferedInputStream.java:345) at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:735) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1587) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:399) at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285) ... 18 more 2.其实我是想 删除这批边 for (Edge edge : list){ graph.removeEdge(edge.id()); } 3.如果有别的批量删除边的方法也麻烦提供一下
Status of loaded data 数据状态
Vertex/Edge summary 数据量
- loaded vertices amount: {like 10 million}
- loaded edges amount: {like 20 million}
- loaded time: {like 200s}
Vertex/Edge example 数据示例
{type something here...}
Schema(VertexLabel, EdgeLabel, IndexLabel) 元数据结构
{type something here...}
Specifications of environment 环境信息
- hugegraph version: {like v0.7.4}
- operating system: {like centos 7.4, 32 CPUs, 64G RAM}
- hugegraph backend: {like cassandra 3.10, cluster with 20 nodes, 3 x 1TB HDD disk each node}
HugeClient client = new HugeClient(server, graph, timeout)
第三个参数即为超时时间,单位为秒。
@Linary 感谢
@Linary 当graph.listEdges()的结果大于800000还是不行, 有什么设置可以解除这个限制吗
graph 有一系列 iterateEdges() 方法返回迭代器,可以以分页的方式获取边,你只要不停地调用 hasNext() 和 next() 获取下一条即可。
// 每次请求1000条边
Iterator<Edge> edges = graph.iterateEdges(1000);
while (edges.hasNext()) {
// 这一批的1000条迭代完会自动获取下一个1000条
Edge edge = edges.next();
}
@Linary 我用这个iterateEdges() 在while那一行报错了,麻烦帮我看看 Exception in thread "main" class java.lang.IllegalArgumentException: Not support quering edges based on paging and [vertex, direction, label, properties, offset] together at com.baidu.hugegraph.exception.ServerException.fromResponse(ServerException.java:44) at com.baidu.hugegraph.client.RestClient.checkStatus(RestClient.java:63) at com.baidu.hugegraph.rest.RestClient.get(RestClient.java:169) at com.baidu.hugegraph.api.graph.EdgeAPI.list(EdgeAPI.java:108) at com.baidu.hugegraph.driver.GraphManager.lambda$iterateEdges$1(GraphManager.java:294) at com.baidu.hugegraph.structure.graph.GraphIterator.hasNext(GraphIterator.java:53) at BatchExample.delete_day_edge(BatchExample.java:30) at BatchExample.main(BatchExample.java:54)