Skip to content
Permalink
Browse files
Add http-connection options (#81)
  • Loading branch information
imbajin authored and javeme committed Jun 18, 2019
1 parent c368900 commit e62a18e7cb03f08ac2540dfc1b90a36d06fdb447
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
@@ -27,6 +27,8 @@

public final class LoadOptions {

private final int CPUS = Runtime.getRuntime().availableProcessors();

@Parameter(names = {"-f", "--file"}, required = true, arity = 1,
validateWith = {FileValidator.class},
description = "The path of the data source description file")
@@ -58,7 +60,15 @@ public final class LoadOptions {
@Parameter(names = {"--num-threads"}, arity = 1,
validateWith = {PositiveValidator.class},
description = "The number of threads to use")
public int numThreads = Runtime.getRuntime().availableProcessors();
public int numThreads = CPUS;

@Parameter(names = {"--max-conn"}, arity = 1,
description = "Max number of HTTP connections to server")
public int maxConnections = CPUS * 4;

@Parameter(names = {"--max-conn-per-route"}, arity = 1,
description = "Max number of HTTP connections to each route")
public int maxConnectionsPerRoute = CPUS * 2;

@Parameter(names = {"--batch-size"}, arity = 1,
validateWith = {PositiveValidator.class},
@@ -42,12 +42,15 @@ private HugeClientWrapper() {}
private static HugeClient newHugeClient(LoadOptions options) {
String address = options.host + ":" + options.port;
if (options.token == null) {
return new HugeClient(address, options.graph, options.timeout);
return new HugeClient(address, options.graph, options.timeout,
options.maxConnections,
options.maxConnectionsPerRoute);
} else {
// The username is same as graph name
return new HugeClient(address, options.graph,
options.graph, options.token,
options.timeout);
return new HugeClient(address, options.graph, options.graph,
options.token, options.timeout,
options.maxConnections,
options.maxConnectionsPerRoute);
}
}
}

0 comments on commit e62a18e

Please sign in to comment.