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.netconf.test.tool.client.http.perf;
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 = "destination")
29 public String destination;
31 @Arg(dest = "edit-count")
34 @Arg(dest = "edit-content")
35 public File editContent;
40 @Arg(dest = "thread-amount")
41 public int threadAmount;
43 @Arg(dest = "same-device")
44 public boolean sameDevice;
46 @Arg(dest = "device-port-range-start")
47 public int devicePortRangeStart;
49 @Arg(dest = "throttle")
52 static ArgumentParser getParser() {
53 final ArgumentParser parser = ArgumentParsers.newArgumentParser("netconf stress client");
55 parser.description("Netconf stress client");
57 parser.addArgument("--ip")
59 .setDefault("127.0.0.1")
60 .help("Restconf server IP")
63 parser.addArgument("--port")
66 .help("Restconf server port")
69 parser.addArgument("--destination")
71 .setDefault("/restconf/config/network-topology:network-topology/topology/topology-netconf/node/" +
72 "{DEVICE_PORT}-sim-device/yang-ext:mount/cisco-vpp:vpp/bridge-domains/bridge-domain/a")
73 .help("Destination to send the requests to after the ip:port part of the uri. " +
74 "Use {DEVICE_PORT} tag to use the device-port-range-start argument")
77 parser.addArgument("--edits")
80 .help("Amount requests to be sent")
83 parser.addArgument("--edit-content")
85 .setDefault(new File("edit.txt"))
86 .dest("edit-content");
88 parser.addArgument("--async-requests")
93 parser.addArgument("--thread-amount")
96 .dest("thread-amount");
98 parser.addArgument("--same-device")
101 .help("If true, every thread edits the device at the first port. If false, n-th thread edits device at n-th port.")
102 .dest("same-device");
104 parser.addArgument("--device-port-range-start")
107 .dest("device-port-range-start");
109 parser.addArgument("--throttle")
112 .help("Maximum amount of async requests that can be open at a time, " +
113 "with mutltiple threads this gets divided among all threads")
120 Preconditions.checkArgument(port > 0, "Port =< 0");
121 Preconditions.checkArgument(editCount > 0, "Edit count =< 0");
123 Preconditions.checkArgument(editContent.exists(), "Edit content file missing");
124 Preconditions.checkArgument(editContent.isDirectory() == false, "Edit content file is a dir");
125 Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
129 public InetSocketAddress getInetAddress() {
131 return new InetSocketAddress(InetAddress.getByName(ip), port);
132 } catch (final UnknownHostException e) {
133 throw new IllegalArgumentException("Unknown ip", e);