Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * 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 Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * 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 Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 16 | package org.onlab.onos.foo; |
| 17 | |
| 18 | import static org.onlab.onos.foo.SimpleNettyClient.startStandalone; |
pankaj | 9fc8759 | 2014-10-10 15:40:43 -0700 | [diff] [blame] | 19 | import static org.onlab.onos.foo.SimpleNettyClient.stop; |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 20 | |
| 21 | import org.apache.karaf.shell.commands.Argument; |
| 22 | import org.apache.karaf.shell.commands.Command; |
| 23 | import org.onlab.onos.cli.AbstractShellCommand; |
| 24 | |
| 25 | /** |
| 26 | * Test Netty client performance. |
| 27 | */ |
| 28 | @Command(scope = "onos", name = "simple-netty-client", |
pankaj | 5364ca9 | 2014-10-09 14:11:58 -0700 | [diff] [blame] | 29 | description = "Starts simple Netty client") |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 30 | public class SimpleNettyClientCommand extends AbstractShellCommand { |
| 31 | |
pankaj | ea0acef | 2014-10-07 15:01:47 -0700 | [diff] [blame] | 32 | //FIXME: replace these arguments with proper ones needed for the test. |
pankaj | f0f80b2 | 2014-10-07 18:37:32 -0700 | [diff] [blame] | 33 | @Argument(index = 0, name = "hostname", description = "Server Hostname", |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 34 | required = false, multiValued = false) |
pankaj | 28c3564 | 2014-10-08 16:42:36 -0700 | [diff] [blame] | 35 | String hostname = "localhost"; |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 36 | |
pankaj | 31b8eab | 2014-10-08 18:14:08 -0700 | [diff] [blame] | 37 | @Argument(index = 1, name = "port", description = "Port", |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 38 | required = false, multiValued = false) |
pankaj | 13373b5 | 2014-10-07 18:26:07 -0700 | [diff] [blame] | 39 | String port = "8081"; |
| 40 | |
pankaj | 31b8eab | 2014-10-08 18:14:08 -0700 | [diff] [blame] | 41 | @Argument(index = 2, name = "warmupCount", description = "Warm-up count", |
pankaj | 13373b5 | 2014-10-07 18:26:07 -0700 | [diff] [blame] | 42 | required = false, multiValued = false) |
pankaj | 6245a7a | 2014-10-10 17:50:55 -0700 | [diff] [blame] | 43 | String warmupCount = "1000"; |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 44 | |
pankaj | 31b8eab | 2014-10-08 18:14:08 -0700 | [diff] [blame] | 45 | @Argument(index = 3, name = "messageCount", description = "Message count", |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 46 | required = false, multiValued = false) |
pankaj | 9fc8759 | 2014-10-10 15:40:43 -0700 | [diff] [blame] | 47 | String messageCount = "1000000"; |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 48 | |
| 49 | @Override |
| 50 | protected void execute() { |
| 51 | try { |
pankaj | 28c3564 | 2014-10-08 16:42:36 -0700 | [diff] [blame] | 52 | startStandalone(new String[]{hostname, port, warmupCount, messageCount}); |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 53 | } catch (Exception e) { |
| 54 | error("Unable to start client %s", e); |
| 55 | } |
pankaj | 9fc8759 | 2014-10-10 15:40:43 -0700 | [diff] [blame] | 56 | stop(); |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 57 | } |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 58 | } |