2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.netconf.test.tool.client.stress;
11 import com.google.common.base.Preconditions;
13 import java.net.InetAddress;
14 import java.net.InetSocketAddress;
15 import java.net.UnknownHostException;
16 import net.sourceforge.argparse4j.ArgumentParsers;
17 import net.sourceforge.argparse4j.annotation.Arg;
18 import net.sourceforge.argparse4j.inf.ArgumentParser;
20 public class Parameters {
28 @Arg(dest = "edit-count")
31 @Arg(dest = "edit-content")
32 public File editContent;
34 @Arg(dest = "edit-batch-size")
35 public int editBatchSize;
40 @Arg(dest = "legacy-framing")
41 public boolean legacyFraming;
52 @Arg(dest = "msg-timeout")
53 public long msgTimeout;
55 @Arg(dest = "tcp-header")
56 public String tcpHeader;
58 static ArgumentParser getParser() {
59 final ArgumentParser parser = ArgumentParsers.newArgumentParser("netconf stress client");
61 parser.description("Netconf stress client");
63 parser.addArgument("--ip")
65 .setDefault("127.0.0.1")
67 .help("Netconf server IP")
70 parser.addArgument("--port")
74 .help("Netconf server port")
77 parser.addArgument("--edits")
81 .help("Netconf edit rpcs to be sent")
84 parser.addArgument("--edit-content")
86 .setDefault(new File("edit.txt"))
88 .dest("edit-content");
90 parser.addArgument("--edit-batch-size")
95 .dest("edit-batch-size");
97 parser.addArgument("--debug")
100 .help("Whether to use debug log level instead of INFO")
103 parser.addArgument("--legacy-framing")
106 .dest("legacy-framing");
108 parser.addArgument("--exi")
113 parser.addArgument("--async-requests")
118 parser.addArgument("--msg-timeout")
121 .dest("msg-timeout");
123 parser.addArgument("--ssh")
128 parser.addArgument("--tcp-header")
133 // TODO add get-config option instead of edit + commit
134 // TODO different edit config content
140 Preconditions.checkArgument(port > 0, "Port =< 0");
141 Preconditions.checkArgument(editCount > 0, "Edit count =< 0");
142 if (editBatchSize == -1) {
143 editBatchSize = editCount;
145 Preconditions.checkArgument(editBatchSize <= editCount, "Edit count =< 0");
148 Preconditions.checkArgument(editContent.exists(), "Edit content file missing");
149 Preconditions.checkArgument(editContent.isDirectory() == false, "Edit content file is a dir");
150 Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
154 public InetSocketAddress getInetAddress() {
156 return new InetSocketAddress(InetAddress.getByName(ip), port);
157 } catch (final UnknownHostException e) {
158 throw new IllegalArgumentException("Unknown ip", e);