pankaj

Use arguments to simple client

......@@ -30,6 +30,10 @@ public final class SimpleNettyClient {
System.exit(0);
}
public static void startStandalone(String... args) throws Exception {
String host = args.length > 0 ? args[0] : "localhost";
int port = args.length > 1 ? Integer.parseInt(args[1]) : 8081;
int warmup = args.length > 2 ? Integer.parseInt(args[2]) : 1000;
int iterations = args.length > 3 ? Integer.parseInt(args[3]) : 50 * 100000;
NettyMessagingService messaging = new TestNettyMessagingService(9081);
MetricsManager metrics = new MetricsManager();
messaging.activate();
......@@ -37,28 +41,26 @@ public final class SimpleNettyClient {
MetricsFeature feature = new MetricsFeature("latency");
MetricsComponent component = metrics.registerComponent("NettyMessaging");
final int warmup = 10000;
for (int i = 0; i < warmup; i++) {
messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes());
messaging.sendAsync(new Endpoint(host, port), "simple", "Hello World".getBytes());
Response response = messaging
.sendAndReceive(new Endpoint("localhost", 8081), "echo",
.sendAndReceive(new Endpoint(host, port), "echo",
"Hello World".getBytes());
}
Timer sendAsyncTimer = metrics.createTimer(component, feature, "AsyncSender");
Timer sendAndReceiveTimer = metrics.createTimer(component, feature, "SendAndReceive");
final int iterations = 10000000;
for (int i = 0; i < iterations; i++) {
Timer.Context context = sendAsyncTimer.time();
messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes());
messaging.sendAsync(new Endpoint(host, port), "simple", "Hello World".getBytes());
context.stop();
}
for (int i = 0; i < iterations; i++) {
Timer.Context context = sendAndReceiveTimer.time();
Response response = messaging
.sendAndReceive(new Endpoint("localhost", 8081), "echo",
.sendAndReceive(new Endpoint(host, port), "echo",
"Hello World".getBytes());
// System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS)));
context.stop();
......
......@@ -18,26 +18,22 @@ public class SimpleNettyClientCommand extends AbstractShellCommand {
required = false, multiValued = false)
String serverIp = "127.0.0.1";
@Argument(index = 1, name = "workers", description = "IO workers",
@Argument(index = 3, name = "port", description = "Port",
required = false, multiValued = false)
String workers = "6";
String port = "8081";
@Argument(index = 2, name = "messageCount", description = "Message count",
required = false, multiValued = false)
String messageCount = "1000000";
@Argument(index = 3, name = "messageLength", description = "Message length (bytes)",
@Argument(index = 1, name = "warmupCount", description = "Warm-up count",
required = false, multiValued = false)
String messageLength = "128";
String warmup = "10000";
@Argument(index = 4, name = "timeoutSecs", description = "Test timeout (seconds)",
@Argument(index = 2, name = "messageCount", description = "Message count",
required = false, multiValued = false)
String timeoutSecs = "60";
String messageCount = "100000";
@Override
protected void execute() {
try {
startStandalone(new String[]{serverIp, workers, messageCount, messageLength, timeoutSecs});
startStandalone(new String[]{serverIp, port, warmup, messageCount});
} catch (Exception e) {
error("Unable to start client %s", e);
}
......