Connection pooling 我如何改变在耶拿的航线连接数量,超过5? 我想知道如何修改耶拿中PAR路由的连接数,当我尝试超过5个查询时,线程被锁定。我尝试在QueryEngineHTTP中修改一些参数,但没有成功(我尝试了qexec.addparam(“max connections”,10)和其他变体)。该项目是关于获取同义词库中的每个节点(与属性相关的节点)的,因此我使用了递归函数,经过5个递归循环后,我被锁定。非常感谢你 Query query = QueryFactory.create(queryString); if (!occurs.contains(entity)) { // print depth times "\t" to retrieve an explorer tree like output for (int i = 0; i < depth; i++) { System.out.print("\t"); } // print out the URI System.out.println(entity); try ( QueryExecution qexec = QueryExecutionFactory.sparqlService("http://data.bnf.fr/sparql", query); ) { QueryEngineHTTP objectToExec= (QueryEngineHTTP) QueryExecutionFactory.sparqlService("http://data.bnf.fr/sparql",query); // objectToExec.addParam("timeout","500000"); //5 sec objectToExec.addParam("http.conn-manager.timeout","10"); ResultSet results = qexec.execSelect(); while (results.hasNext()) { QuerySolution soln = results.nextSolution(); RDFNode sub = soln.get("pL"); // System.out.println("sub "+sub.toString()); if (!sub.isURIResource()) continue; // push this expression on the occurs list before we recurse to avoid loops occurs.add(entity); // traverse down and increase depth (used for logging tabs) traverse(sub.toString(), occurs, depth + 1); // after traversing the path, remove from occurs list occurs.remove(entity); } } } Query Query=QueryFactory.create(queryString); 如果(!occurs.contains(实体)){ //打印深度乘以“\t”以检索类似资源管理器树的输出 for(int i=0;i

Connection pooling 我如何改变在耶拿的航线连接数量,超过5? 我想知道如何修改耶拿中PAR路由的连接数,当我尝试超过5个查询时,线程被锁定。我尝试在QueryEngineHTTP中修改一些参数,但没有成功(我尝试了qexec.addparam(“max connections”,10)和其他变体)。该项目是关于获取同义词库中的每个节点(与属性相关的节点)的,因此我使用了递归函数,经过5个递归循环后,我被锁定。非常感谢你 Query query = QueryFactory.create(queryString); if (!occurs.contains(entity)) { // print depth times "\t" to retrieve an explorer tree like output for (int i = 0; i < depth; i++) { System.out.print("\t"); } // print out the URI System.out.println(entity); try ( QueryExecution qexec = QueryExecutionFactory.sparqlService("http://data.bnf.fr/sparql", query); ) { QueryEngineHTTP objectToExec= (QueryEngineHTTP) QueryExecutionFactory.sparqlService("http://data.bnf.fr/sparql",query); // objectToExec.addParam("timeout","500000"); //5 sec objectToExec.addParam("http.conn-manager.timeout","10"); ResultSet results = qexec.execSelect(); while (results.hasNext()) { QuerySolution soln = results.nextSolution(); RDFNode sub = soln.get("pL"); // System.out.println("sub "+sub.toString()); if (!sub.isURIResource()) continue; // push this expression on the occurs list before we recurse to avoid loops occurs.add(entity); // traverse down and increase depth (used for logging tabs) traverse(sub.toString(), occurs, depth + 1); // after traversing the path, remove from occurs list occurs.remove(entity); } } } Query Query=QueryFactory.create(queryString); 如果(!occurs.contains(实体)){ //打印深度乘以“\t”以检索类似资源管理器树的输出 for(int i=0;i,connection-pooling,jena,Connection Pooling,Jena,Apache Jena使用的默认HttpClient设置每个路由最多有5个连接(请参阅) 您需要通过创建所需的HttpClient并使用该方法将其设置为默认客户端,来配置默认的HttpClient实例 有关如何正确配置客户端的信息,请参阅文档。您可以使用前面提到的代码链接作为基础,并进行相应的修改。例如,每条路由最多20个连接,总共100个: HttpClient client = HttpClientBuilder.create() .useSystemProperti

Apache Jena使用的默认
HttpClient
设置每个路由最多有5个连接(请参阅)

您需要通过创建所需的
HttpClient
并使用该方法将其设置为默认客户端,来配置默认的
HttpClient
实例

有关如何正确配置客户端的信息,请参阅文档。您可以使用前面提到的代码链接作为基础,并进行相应的修改。例如,每条路由最多20个连接,总共100个:

HttpClient client =
    HttpClientBuilder.create()
        .useSystemProperties()
        .setRedirectStrategy(new LaxRedirectStrategy())
        .setMaxConnPerRoute(20)
        .setMaxConnTotal(100);
HttpOp.setDefaultHttpClient(client);
请注意,您还需要确保正确释放连接,我看到您在
QueryExecution
上使用了try with resources,它应该在释放基础连接的执行上自动调用
close()
。但是您永远不会调用
ResultSet
上的
close()
,该结果集也可能包含对连接的引用。因此,当您完成结果集或查询执行时,显式调用
close()
不会有什么坏处


由于您正在执行递归调用,因此您可能希望在递归之前调用
close()
,否则,如果层次结构很深,最终仍会遇到这种情况。由于您可能会在每个结果上重复出现,您可能无法立即关闭它,因此实际获取结果集的副本可能会很有用,这样您就可以在使用

对结果进行循环之前关闭执行Apache Jena使用的默认
HttpClient
设置每个路由最多有5个连接(请参阅)

您需要通过创建所需的
HttpClient
并使用该方法将其设置为默认客户端,来配置默认的
HttpClient
实例

有关如何正确配置客户端的信息,请参阅文档。您可以使用前面提到的代码链接作为基础,并进行相应的修改。例如,每条路由最多20个连接,总共100个:

HttpClient client =
    HttpClientBuilder.create()
        .useSystemProperties()
        .setRedirectStrategy(new LaxRedirectStrategy())
        .setMaxConnPerRoute(20)
        .setMaxConnTotal(100);
HttpOp.setDefaultHttpClient(client);
请注意,您还需要确保正确释放连接,我看到您在
QueryExecution
上使用了try with resources,它应该在释放基础连接的执行上自动调用
close()
。但是您永远不会调用
ResultSet
上的
close()
,该结果集也可能包含对连接的引用。因此,当您完成结果集或查询执行时,显式调用
close()
不会有什么坏处


由于您正在执行递归调用,因此您可能希望在递归之前调用
close()
,否则,如果层次结构很深,最终仍会遇到这种情况。由于您可能会在每个结果上重复出现,您可能无法立即关闭它,因此实际获取结果集的副本可能会很有用,这样您就可以在使用

循环结果之前关闭执行。非常感谢!最后,我使用了池连接管理器的配置:
poolighttpclientconnectionmanager cm=new-poolighttpclientconnectionmanager();cm.setMaxTotal(200);cm.setDefaultMaxPerRoute(20);HttpHost localhost=新的HttpHost(“locahost”,80);cm.setMaxPerRoute(新的HttpRoute(localhost),50);CloseableHttpClient httpClient=HttpClients.custom().setConnectionManager(cm.build();HttpOp.setDefaultHttpClient(httpClient)poolighttpclientconnectionmanager cm=new-poolighttpclientconnectionmanager();cm.setMaxTotal(200);cm.setDefaultMaxPerRoute(20);HttpHost localhost=新的HttpHost(“locahost”,80);cm.setMaxPerRoute(新的HttpRoute(localhost),50);CloseableHttpClient httpClient=HttpClients.custom().setConnectionManager(cm.build();HttpOp.setDefaultHttpClient(httpClient)