blob: 63639702fcd22be7a5bca4749d2ce02e8cd8a565 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
pankaj09b58382014-10-07 13:52:24 -070019package org.onlab.onos.foo;
20
pankaj09b58382014-10-07 13:52:24 -070021import org.onlab.netty.NettyMessagingService;
22import org.slf4j.Logger;
23import org.slf4j.LoggerFactory;
24
25/**
26 * Test to measure Messaging performance.
27 */
Madan Jampania5d0d782014-10-07 14:36:00 -070028 public final class SimpleNettyServer {
pankaj9c060c02014-10-08 10:21:29 -070029 private static Logger log = LoggerFactory.getLogger(SimpleNettyServer.class);
pankaj09b58382014-10-07 13:52:24 -070030
31 private SimpleNettyServer() {}
32
pankaj9fc87592014-10-10 15:40:43 -070033 /**
34 * The entry point of application.
35 *
36 * @param args the input arguments
37 * @throws Exception the exception
38 */
39 public static void main(String... args) throws Exception {
pankaj09b58382014-10-07 13:52:24 -070040 startStandalone(args);
41 System.exit(0);
42 }
43
pankaj9fc87592014-10-10 15:40:43 -070044 /**
45 * Start standalone server.
46 *
47 * @param args the args
48 * @throws Exception the exception
49 */
50 public static void startStandalone(String[] args) throws Exception {
pankaj9d7e4be2014-10-09 14:10:03 -070051 int port = args.length > 0 ? Integer.parseInt(args[0]) : 8081;
52 NettyMessagingService server = new NettyMessagingService(port);
pankajf49b45e2014-10-07 14:24:22 -070053 server.activate();
pankaj9fc87592014-10-10 15:40:43 -070054 server.registerHandler("simple", new NettyNothingHandler());
pankaj366ce8b2014-10-07 17:18:37 -070055 server.registerHandler("echo", new NettyEchoHandler());
pankaj9fc87592014-10-10 15:40:43 -070056 log.info("Netty Server server on port " + port);
pankaj09b58382014-10-07 13:52:24 -070057 }
58 }
59