blob: b2c8b3f5b0f73e30b2d7937aa06e9c0c96edc984 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska781d18b2014-10-27 10:31:25 -070015 */
pankaj09b58382014-10-07 13:52:24 -070016package org.onlab.onos.foo;
17
pankaj09b58382014-10-07 13:52:24 -070018import org.onlab.netty.NettyMessagingService;
19import org.slf4j.Logger;
20import org.slf4j.LoggerFactory;
21
22/**
23 * Test to measure Messaging performance.
24 */
Madan Jampania5d0d782014-10-07 14:36:00 -070025 public final class SimpleNettyServer {
pankaj9c060c02014-10-08 10:21:29 -070026 private static Logger log = LoggerFactory.getLogger(SimpleNettyServer.class);
pankaj09b58382014-10-07 13:52:24 -070027
28 private SimpleNettyServer() {}
29
pankaj9fc87592014-10-10 15:40:43 -070030 /**
31 * The entry point of application.
32 *
33 * @param args the input arguments
34 * @throws Exception the exception
35 */
36 public static void main(String... args) throws Exception {
pankaj09b58382014-10-07 13:52:24 -070037 startStandalone(args);
38 System.exit(0);
39 }
40
pankaj9fc87592014-10-10 15:40:43 -070041 /**
42 * Start standalone server.
43 *
44 * @param args the args
45 * @throws Exception the exception
46 */
47 public static void startStandalone(String[] args) throws Exception {
pankaj9d7e4be2014-10-09 14:10:03 -070048 int port = args.length > 0 ? Integer.parseInt(args[0]) : 8081;
49 NettyMessagingService server = new NettyMessagingService(port);
pankajf49b45e2014-10-07 14:24:22 -070050 server.activate();
pankaj9fc87592014-10-10 15:40:43 -070051 server.registerHandler("simple", new NettyNothingHandler());
pankaj366ce8b2014-10-07 17:18:37 -070052 server.registerHandler("echo", new NettyEchoHandler());
pankaj9fc87592014-10-10 15:40:43 -070053 log.info("Netty Server server on port " + port);
pankaj09b58382014-10-07 13:52:24 -070054 }
55 }
56