pankaj

Use arguments to simple client

...@@ -30,6 +30,10 @@ public final class SimpleNettyClient { ...@@ -30,6 +30,10 @@ public final class SimpleNettyClient {
30 System.exit(0); 30 System.exit(0);
31 } 31 }
32 public static void startStandalone(String... args) throws Exception { 32 public static void startStandalone(String... args) throws Exception {
33 + String host = args.length > 0 ? args[0] : "localhost";
34 + int port = args.length > 1 ? Integer.parseInt(args[1]) : 8081;
35 + int warmup = args.length > 2 ? Integer.parseInt(args[2]) : 1000;
36 + int iterations = args.length > 3 ? Integer.parseInt(args[3]) : 50 * 100000;
33 NettyMessagingService messaging = new TestNettyMessagingService(9081); 37 NettyMessagingService messaging = new TestNettyMessagingService(9081);
34 MetricsManager metrics = new MetricsManager(); 38 MetricsManager metrics = new MetricsManager();
35 messaging.activate(); 39 messaging.activate();
...@@ -37,28 +41,26 @@ public final class SimpleNettyClient { ...@@ -37,28 +41,26 @@ public final class SimpleNettyClient {
37 MetricsFeature feature = new MetricsFeature("latency"); 41 MetricsFeature feature = new MetricsFeature("latency");
38 MetricsComponent component = metrics.registerComponent("NettyMessaging"); 42 MetricsComponent component = metrics.registerComponent("NettyMessaging");
39 43
40 - final int warmup = 10000;
41 for (int i = 0; i < warmup; i++) { 44 for (int i = 0; i < warmup; i++) {
42 - messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes()); 45 + messaging.sendAsync(new Endpoint(host, port), "simple", "Hello World".getBytes());
43 Response response = messaging 46 Response response = messaging
44 - .sendAndReceive(new Endpoint("localhost", 8081), "echo", 47 + .sendAndReceive(new Endpoint(host, port), "echo",
45 "Hello World".getBytes()); 48 "Hello World".getBytes());
46 } 49 }
47 50
48 Timer sendAsyncTimer = metrics.createTimer(component, feature, "AsyncSender"); 51 Timer sendAsyncTimer = metrics.createTimer(component, feature, "AsyncSender");
49 Timer sendAndReceiveTimer = metrics.createTimer(component, feature, "SendAndReceive"); 52 Timer sendAndReceiveTimer = metrics.createTimer(component, feature, "SendAndReceive");
50 53
51 - final int iterations = 10000000;
52 for (int i = 0; i < iterations; i++) { 54 for (int i = 0; i < iterations; i++) {
53 Timer.Context context = sendAsyncTimer.time(); 55 Timer.Context context = sendAsyncTimer.time();
54 - messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes()); 56 + messaging.sendAsync(new Endpoint(host, port), "simple", "Hello World".getBytes());
55 context.stop(); 57 context.stop();
56 } 58 }
57 59
58 for (int i = 0; i < iterations; i++) { 60 for (int i = 0; i < iterations; i++) {
59 Timer.Context context = sendAndReceiveTimer.time(); 61 Timer.Context context = sendAndReceiveTimer.time();
60 Response response = messaging 62 Response response = messaging
61 - .sendAndReceive(new Endpoint("localhost", 8081), "echo", 63 + .sendAndReceive(new Endpoint(host, port), "echo",
62 "Hello World".getBytes()); 64 "Hello World".getBytes());
63 // System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS))); 65 // System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS)));
64 context.stop(); 66 context.stop();
......
...@@ -18,26 +18,22 @@ public class SimpleNettyClientCommand extends AbstractShellCommand { ...@@ -18,26 +18,22 @@ public class SimpleNettyClientCommand extends AbstractShellCommand {
18 required = false, multiValued = false) 18 required = false, multiValued = false)
19 String serverIp = "127.0.0.1"; 19 String serverIp = "127.0.0.1";
20 20
21 - @Argument(index = 1, name = "workers", description = "IO workers", 21 + @Argument(index = 3, name = "port", description = "Port",
22 required = false, multiValued = false) 22 required = false, multiValued = false)
23 - String workers = "6"; 23 + String port = "8081";
24 24
25 - @Argument(index = 2, name = "messageCount", description = "Message count", 25 + @Argument(index = 1, name = "warmupCount", description = "Warm-up count",
26 - required = false, multiValued = false)
27 - String messageCount = "1000000";
28 -
29 - @Argument(index = 3, name = "messageLength", description = "Message length (bytes)",
30 required = false, multiValued = false) 26 required = false, multiValued = false)
31 - String messageLength = "128"; 27 + String warmup = "10000";
32 28
33 - @Argument(index = 4, name = "timeoutSecs", description = "Test timeout (seconds)", 29 + @Argument(index = 2, name = "messageCount", description = "Message count",
34 required = false, multiValued = false) 30 required = false, multiValued = false)
35 - String timeoutSecs = "60"; 31 + String messageCount = "100000";
36 32
37 @Override 33 @Override
38 protected void execute() { 34 protected void execute() {
39 try { 35 try {
40 - startStandalone(new String[]{serverIp, workers, messageCount, messageLength, timeoutSecs}); 36 + startStandalone(new String[]{serverIp, port, warmup, messageCount});
41 } catch (Exception e) { 37 } catch (Exception e) {
42 error("Unable to start client %s", e); 38 error("Unable to start client %s", e);
43 } 39 }
......