blob: b1e14c6f7a090dbf1de5b7060089896a5dcb04cb [file] [log] [blame]
pankaj09b58382014-10-07 13:52:24 -07001package org.onlab.onos.foo;
2
pankaj09b58382014-10-07 13:52:24 -07003import org.onlab.netty.NettyMessagingService;
4import org.slf4j.Logger;
5import org.slf4j.LoggerFactory;
6
7/**
8 * Test to measure Messaging performance.
9 */
Madan Jampania5d0d782014-10-07 14:36:00 -070010 public final class SimpleNettyServer {
pankaj9c060c02014-10-08 10:21:29 -070011 private static Logger log = LoggerFactory.getLogger(SimpleNettyServer.class);
pankaj09b58382014-10-07 13:52:24 -070012
13 private SimpleNettyServer() {}
14
pankaj9fc87592014-10-10 15:40:43 -070015 /**
16 * The entry point of application.
17 *
18 * @param args the input arguments
19 * @throws Exception the exception
20 */
21 public static void main(String... args) throws Exception {
pankaj09b58382014-10-07 13:52:24 -070022 startStandalone(args);
23 System.exit(0);
24 }
25
pankaj9fc87592014-10-10 15:40:43 -070026 /**
27 * Start standalone server.
28 *
29 * @param args the args
30 * @throws Exception the exception
31 */
32 public static void startStandalone(String[] args) throws Exception {
pankaj9d7e4be2014-10-09 14:10:03 -070033 int port = args.length > 0 ? Integer.parseInt(args[0]) : 8081;
34 NettyMessagingService server = new NettyMessagingService(port);
pankajf49b45e2014-10-07 14:24:22 -070035 server.activate();
pankaj9fc87592014-10-10 15:40:43 -070036 server.registerHandler("simple", new NettyNothingHandler());
pankaj366ce8b2014-10-07 17:18:37 -070037 server.registerHandler("echo", new NettyEchoHandler());
pankaj9fc87592014-10-10 15:40:43 -070038 log.info("Netty Server server on port " + port);
pankaj09b58382014-10-07 13:52:24 -070039 }
40 }
41