pankaj

endpoint needs to be created once

...@@ -41,6 +41,7 @@ private static Logger log = LoggerFactory.getLogger(SimpleNettyClient.class); ...@@ -41,6 +41,7 @@ private static Logger log = LoggerFactory.getLogger(SimpleNettyClient.class);
41 int iterations = args.length > 3 ? Integer.parseInt(args[3]) : 50 * 100000; 41 int iterations = args.length > 3 ? Integer.parseInt(args[3]) : 50 * 100000;
42 NettyMessagingService messaging = new TestNettyMessagingService(9081); 42 NettyMessagingService messaging = new TestNettyMessagingService(9081);
43 MetricsManager metrics = new MetricsManager(); 43 MetricsManager metrics = new MetricsManager();
44 + Endpoint endpoint = new Endpoint(host, port);
44 messaging.activate(); 45 messaging.activate();
45 metrics.activate(); 46 metrics.activate();
46 MetricsFeature feature = new MetricsFeature("latency"); 47 MetricsFeature feature = new MetricsFeature("latency");
...@@ -48,9 +49,9 @@ private static Logger log = LoggerFactory.getLogger(SimpleNettyClient.class); ...@@ -48,9 +49,9 @@ private static Logger log = LoggerFactory.getLogger(SimpleNettyClient.class);
48 log.info("warmup...."); 49 log.info("warmup....");
49 50
50 for (int i = 0; i < warmup; i++) { 51 for (int i = 0; i < warmup; i++) {
51 - messaging.sendAsync(new Endpoint(host, port), "simple", "Hello World".getBytes()); 52 + messaging.sendAsync(endpoint, "simple", "Hello World".getBytes());
52 Response response = messaging 53 Response response = messaging
53 - .sendAndReceive(new Endpoint(host, port), "echo", 54 + .sendAndReceive(endpoint, "echo",
54 "Hello World".getBytes()); 55 "Hello World".getBytes());
55 } 56 }
56 57
...@@ -59,7 +60,7 @@ private static Logger log = LoggerFactory.getLogger(SimpleNettyClient.class); ...@@ -59,7 +60,7 @@ private static Logger log = LoggerFactory.getLogger(SimpleNettyClient.class);
59 60
60 for (int i = 0; i < iterations; i++) { 61 for (int i = 0; i < iterations; i++) {
61 Timer.Context context = sendAsyncTimer.time(); 62 Timer.Context context = sendAsyncTimer.time();
62 - messaging.sendAsync(new Endpoint(host, port), "simple", "Hello World".getBytes()); 63 + messaging.sendAsync(endpoint, "simple", "Hello World".getBytes());
63 context.stop(); 64 context.stop();
64 } 65 }
65 66
...@@ -67,7 +68,7 @@ private static Logger log = LoggerFactory.getLogger(SimpleNettyClient.class); ...@@ -67,7 +68,7 @@ private static Logger log = LoggerFactory.getLogger(SimpleNettyClient.class);
67 for (int i = 0; i < iterations; i++) { 68 for (int i = 0; i < iterations; i++) {
68 Timer.Context context = sendAndReceiveTimer.time(); 69 Timer.Context context = sendAndReceiveTimer.time();
69 Response response = messaging 70 Response response = messaging
70 - .sendAndReceive(new Endpoint(host, port), "echo", 71 + .sendAndReceive(endpoint, "echo",
71 "Hello World".getBytes()); 72 "Hello World".getBytes());
72 // System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS))); 73 // System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS)));
73 context.stop(); 74 context.stop();
......
...@@ -16,7 +16,7 @@ public class SimpleNettyClientCommand extends AbstractShellCommand { ...@@ -16,7 +16,7 @@ public class SimpleNettyClientCommand extends AbstractShellCommand {
16 //FIXME: replace these arguments with proper ones needed for the test. 16 //FIXME: replace these arguments with proper ones needed for the test.
17 @Argument(index = 0, name = "hostname", description = "Server Hostname", 17 @Argument(index = 0, name = "hostname", description = "Server Hostname",
18 required = false, multiValued = false) 18 required = false, multiValued = false)
19 - String host = "localhost"; 19 + String hostname = "localhost";
20 20
21 @Argument(index = 3, name = "port", description = "Port", 21 @Argument(index = 3, name = "port", description = "Port",
22 required = false, multiValued = false) 22 required = false, multiValued = false)
...@@ -24,7 +24,7 @@ public class SimpleNettyClientCommand extends AbstractShellCommand { ...@@ -24,7 +24,7 @@ public class SimpleNettyClientCommand extends AbstractShellCommand {
24 24
25 @Argument(index = 1, name = "warmupCount", description = "Warm-up count", 25 @Argument(index = 1, name = "warmupCount", description = "Warm-up count",
26 required = false, multiValued = false) 26 required = false, multiValued = false)
27 - String warmup = "1000"; 27 + String warmupCount = "1000";
28 28
29 @Argument(index = 2, name = "messageCount", description = "Message count", 29 @Argument(index = 2, name = "messageCount", description = "Message count",
30 required = false, multiValued = false) 30 required = false, multiValued = false)
...@@ -33,10 +33,9 @@ public class SimpleNettyClientCommand extends AbstractShellCommand { ...@@ -33,10 +33,9 @@ public class SimpleNettyClientCommand extends AbstractShellCommand {
33 @Override 33 @Override
34 protected void execute() { 34 protected void execute() {
35 try { 35 try {
36 - startStandalone(new String[]{host, port, warmup, messageCount}); 36 + startStandalone(new String[]{hostname, port, warmupCount, messageCount});
37 } catch (Exception e) { 37 } catch (Exception e) {
38 error("Unable to start client %s", e); 38 error("Unable to start client %s", e);
39 } 39 }
40 } 40 }
41 -
42 } 41 }
......