Add port as for simple-netty-server

This commit is contained in:
pankaj 2014-10-09 14:10:03 -07:00
parent f1a2d0ed1b
commit 9d7e4be4af
2 changed files with 5 additions and 11 deletions

View File

@ -18,7 +18,8 @@ import org.slf4j.LoggerFactory;
} }
public static void startStandalone(String[] args) throws Exception { public static void startStandalone(String[] args) throws Exception {
NettyMessagingService server = new NettyMessagingService(8081); int port = args.length > 0 ? Integer.parseInt(args[0]) : 8081;
NettyMessagingService server = new NettyMessagingService(port);
server.activate(); server.activate();
server.registerHandler("simple", new NettyLoggingHandler()); server.registerHandler("simple", new NettyLoggingHandler());
server.registerHandler("echo", new NettyEchoHandler()); server.registerHandler("echo", new NettyEchoHandler());

View File

@ -14,22 +14,15 @@ import org.onlab.onos.cli.AbstractShellCommand;
public class SimpleNettyServerCommand extends AbstractShellCommand { public class SimpleNettyServerCommand extends AbstractShellCommand {
//FIXME: Replace these with parameters for //FIXME: Replace these with parameters for
@Argument(index = 0, name = "serverIp", description = "Server IP address", @Argument(index = 0, name = "port", description = "Port to listen",
required = false, multiValued = false) required = false, multiValued = false)
String serverIp = "127.0.0.1"; String port = "8081";
@Argument(index = 1, name = "workers", description = "IO workers",
required = false, multiValued = false)
String workers = "6";
@Argument(index = 2, name = "messageLength", description = "Message length (bytes)",
required = false, multiValued = false)
String messageLength = "128";
@Override @Override
protected void execute() { protected void execute() {
try { try {
startStandalone(new String[]{serverIp, workers, messageLength}); startStandalone(new String[]{port});
} catch (Exception e) { } catch (Exception e) {
error("Unable to start server %s", e); error("Unable to start server %s", e);
} }