|
14 | 14 |
|
15 | 15 | import com.esotericsoftware.kryo.serializers.DefaultArraySerializers;
|
16 | 16 |
|
| 17 | +import com.typesafe.config.Config; |
| 18 | +import com.typesafe.config.ConfigFactory; |
17 | 19 | import info.minzhou.lightning.rpc.Codecs;
|
18 | 20 | import info.minzhou.lightning.rpc.protocol.KryoUtils;
|
19 | 21 | import info.minzhou.lightning.rpc.protocol.PBDecoder;
|
@@ -72,24 +74,21 @@ public abstract class AbstractBenchmarkClient {
|
72 | 74 | private static long above1000sum;
|
73 | 75 |
|
74 | 76 | public void run(String[] args) throws Exception {
|
75 |
| - if (args == null || (args.length != 7 && args.length != 8)) { |
76 |
| - throw new IllegalArgumentException( |
77 |
| - "must give seven or eight args, serverIP serverPort concurrents timeout codectype requestSize runtime(seconds) clientNums"); |
78 |
| - } |
79 |
| - |
80 |
| - final String serverIP = args[0]; |
81 |
| - final int serverPort = Integer.parseInt(args[1]); |
82 |
| - final int concurrents = Integer.parseInt(args[2]); |
83 |
| - final int timeout = Integer.parseInt(args[3]); |
84 |
| - final int codectype = Integer.parseInt(args[4]); |
85 |
| - final int requestSize = Integer.parseInt(args[5]); |
86 |
| - runtime = Integer.parseInt(args[6]); |
| 77 | + Config conf = ConfigFactory.load(); |
| 78 | + // server config |
| 79 | + final String serverIP = conf.getString("server.host"); |
| 80 | + final int serverPort = conf.getInt("server.port"); |
| 81 | + // client config |
| 82 | + final int concurrents = conf.getInt("client.concurrency"); |
| 83 | + final int clientNums = conf.getInt("client.connections"); |
| 84 | + final int timeout = conf.getInt("client.timeout"); |
| 85 | + |
| 86 | + // reuqest config |
| 87 | + final int codectype = conf.getInt("client.request.type"); |
| 88 | + final int requestSize = conf.getInt("client.request.size"); |
| 89 | + runtime = conf.getInt("client.request.duration"); |
| 90 | + boolean isWriteResult = conf.getBoolean("client.request.statistics"); |
87 | 91 | final long endtime = System.currentTimeMillis() + runtime * 1000;
|
88 |
| - int tmpClientNums = 1; |
89 |
| - if (args.length == 8) { |
90 |
| - tmpClientNums = Integer.parseInt(args[7]); |
91 |
| - } |
92 |
| - final int clientNums = tmpClientNums; |
93 | 92 |
|
94 | 93 | // Print start info
|
95 | 94 | Date currentDate = new Date();
|
@@ -215,7 +214,7 @@ public void run(String[] args) throws Exception {
|
215 | 214 | }
|
216 | 215 | }
|
217 | 216 |
|
218 |
| - boolean isWriteResult = Boolean.parseBoolean(System.getProperty("write.statistics", "false")); |
| 217 | + |
219 | 218 | if (isWriteResult) {
|
220 | 219 | BufferedWriter writer = new BufferedWriter(new FileWriter(
|
221 | 220 | "benchmark.all.results"));
|
@@ -272,12 +271,12 @@ public abstract ClientRunnable getClientRunnable(String targetIP, int targetPort
|
272 | 271 | int clientNums, int rpcTimeout, int codecType, int requestSize,
|
273 | 272 | CyclicBarrier barrier, CountDownLatch latch, long endTime, long startTime);
|
274 | 273 |
|
275 |
| - protected void startRunnables(List<ClientRunnable> runnables) { |
276 |
| - for (int i = 0; i < runnables.size(); i++) { |
277 |
| - final ClientRunnable runnable = runnables.get(i); |
278 |
| - Thread thread = new Thread(runnable, "benchmarkclient-" + i); |
279 |
| - thread.start(); |
280 |
| -} |
| 274 | + protected void startRunnables(List<ClientRunnable> runnables) { |
| 275 | + for (int i = 0; i < runnables.size(); i++) { |
| 276 | + final ClientRunnable runnable = runnables.get(i); |
| 277 | + Thread thread = new Thread(runnable, "benchmarkclient-" + i); |
| 278 | + thread.start(); |
281 | 279 | }
|
| 280 | + } |
282 | 281 |
|
283 | 282 | }
|
0 commit comments