pankaj | 09b5838 | 2014-10-07 13:52:24 -0700 | [diff] [blame] | 1 | package org.onlab.onos.foo; |
| 2 | |
pankaj | 09b5838 | 2014-10-07 13:52:24 -0700 | [diff] [blame] | 3 | import org.onlab.netty.NettyMessagingService; |
| 4 | import org.slf4j.Logger; |
| 5 | import org.slf4j.LoggerFactory; |
| 6 | |
| 7 | /** |
| 8 | * Test to measure Messaging performance. |
| 9 | */ |
Madan Jampani | a5d0d78 | 2014-10-07 14:36:00 -0700 | [diff] [blame] | 10 | public final class SimpleNettyServer { |
pankaj | 9c060c0 | 2014-10-08 10:21:29 -0700 | [diff] [blame] | 11 | private static Logger log = LoggerFactory.getLogger(SimpleNettyServer.class); |
pankaj | 09b5838 | 2014-10-07 13:52:24 -0700 | [diff] [blame] | 12 | |
| 13 | private SimpleNettyServer() {} |
| 14 | |
pankaj | 9fc8759 | 2014-10-10 15:40:43 -0700 | [diff] [blame^] | 15 | /** |
| 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 { |
pankaj | 09b5838 | 2014-10-07 13:52:24 -0700 | [diff] [blame] | 22 | startStandalone(args); |
| 23 | System.exit(0); |
| 24 | } |
| 25 | |
pankaj | 9fc8759 | 2014-10-10 15:40:43 -0700 | [diff] [blame^] | 26 | /** |
| 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 { |
pankaj | 9d7e4be | 2014-10-09 14:10:03 -0700 | [diff] [blame] | 33 | int port = args.length > 0 ? Integer.parseInt(args[0]) : 8081; |
| 34 | NettyMessagingService server = new NettyMessagingService(port); |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 35 | server.activate(); |
pankaj | 9fc8759 | 2014-10-10 15:40:43 -0700 | [diff] [blame^] | 36 | server.registerHandler("simple", new NettyNothingHandler()); |
pankaj | 366ce8b | 2014-10-07 17:18:37 -0700 | [diff] [blame] | 37 | server.registerHandler("echo", new NettyEchoHandler()); |
pankaj | 9fc8759 | 2014-10-10 15:40:43 -0700 | [diff] [blame^] | 38 | log.info("Netty Server server on port " + port); |
pankaj | 09b5838 | 2014-10-07 13:52:24 -0700 | [diff] [blame] | 39 | } |
| 40 | } |
| 41 | |