It validates some new parameters.Also thread pool size
and Ip of socket address is configurable. We can set
them using program arguments.
Change-Id: I4af24500ca0650c0c5a922d41b292c573ac78400
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
final ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(params.debug ? Level.DEBUG : Level.INFO);
final ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(params.debug ? Level.DEBUG : Level.INFO);
- final NetconfDeviceSimulator netconfDeviceSimulator = new NetconfDeviceSimulator();
+ final NetconfDeviceSimulator netconfDeviceSimulator = new NetconfDeviceSimulator(params.threadPoolSize);
try {
final List<Integer> openDevices = netconfDeviceSimulator.start(params);
if (openDevices.size() == 0) {
try {
final List<Integer> openDevices = netconfDeviceSimulator.start(params);
if (openDevices.size() == 0) {
private boolean sendFakeSchema = false;
private boolean sendFakeSchema = false;
- public NetconfDeviceSimulator() {
- // TODO make pool size configurable
+ public NetconfDeviceSimulator(final int ThreadPoolSize) {
this(new NioEventLoopGroup(), new HashedWheelTimer(),
this(new NioEventLoopGroup(), new HashedWheelTimer(),
- Executors.newScheduledThreadPool(8, new ThreadFactoryBuilder().setNameFormat("netconf-ssh-server-mina-timers-%d").build()),
- ThreadUtils.newFixedThreadPool("netconf-ssh-server-nio-group", 8));
+ Executors.newScheduledThreadPool(ThreadPoolSize, new ThreadFactoryBuilder().setNameFormat("netconf-ssh-server-mina-timers-%d").build()),
+ ThreadUtils.newFixedThreadPool("netconf-ssh-server-nio-group", ThreadPoolSize));
}
private NetconfDeviceSimulator(final NioEventLoopGroup eventExecutors, final HashedWheelTimer hashedWheelTimer, final ScheduledExecutorService minaTimerExecutor, final ExecutorService nioExecutor) {
}
private NetconfDeviceSimulator(final NioEventLoopGroup eventExecutors, final HashedWheelTimer hashedWheelTimer, final ScheduledExecutorService minaTimerExecutor, final ExecutorService nioExecutor) {
final AggregatedNetconfOperationServiceFactory aggregatedNetconfOperationServiceFactory = new AggregatedNetconfOperationServiceFactory();
final NetconfOperationServiceFactory operationProvider = mdSal ? new MdsalOperationProvider(idProvider, transformedCapabilities, schemaContext, sourceProvider) :
final AggregatedNetconfOperationServiceFactory aggregatedNetconfOperationServiceFactory = new AggregatedNetconfOperationServiceFactory();
final NetconfOperationServiceFactory operationProvider = mdSal ? new MdsalOperationProvider(idProvider, transformedCapabilities, schemaContext, sourceProvider) :
- new SimulatedOperationProvider(idProvider, transformedCapabilities, notificationsFile, initialConfigXMLFile);
+ new SimulatedOperationProvider(idProvider, transformedCapabilities, notificationsFile, initialConfigXMLFile);
transformedCapabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0"));
transformedCapabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0"));
LOG.warn("Port cannot be greater than 65535, stopping further attempts.");
break;
}
LOG.warn("Port cannot be greater than 65535, stopping further attempts.");
break;
}
- final InetSocketAddress address = getAddress(currentPort);
+ final InetSocketAddress address = getAddress(params.ip, currentPort);
final ChannelFuture server;
if(params.ssh) {
final ChannelFuture server;
if(params.ssh) {
}, PotentialSchemaSource.create(sourceId, YangTextSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
}
}, PotentialSchemaSource.create(sourceId, YangTextSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
}
- private static InetSocketAddress getAddress(final int port) {
+ private static InetSocketAddress getAddress(final String ip, final int port) {
- // TODO make address configurable
- return new InetSocketAddress(Inet4Address.getByName("0.0.0.0"), port);
+ return new InetSocketAddress(Inet4Address.getByName(ip), port);
} catch (final UnknownHostException e) {
throw new RuntimeException(e);
}
} catch (final UnknownHostException e) {
throw new RuntimeException(e);
}
while (true) {
root.warn("Starting scale test with {} devices", params.deviceCount);
timeoutGuardFuture = executor.schedule(new TimeoutGuard(), timeout, TimeUnit.MINUTES);
while (true) {
root.warn("Starting scale test with {} devices", params.deviceCount);
timeoutGuardFuture = executor.schedule(new TimeoutGuard(), timeout, TimeUnit.MINUTES);
- final NetconfDeviceSimulator netconfDeviceSimulator = new NetconfDeviceSimulator();
+ final NetconfDeviceSimulator netconfDeviceSimulator = new NetconfDeviceSimulator(params.threadAmount);
try {
final List<Integer> openDevices = netconfDeviceSimulator.start(params);
if (openDevices.size() == 0) {
try {
final List<Integer> openDevices = netconfDeviceSimulator.start(params);
if (openDevices.size() == 0) {
@Arg(dest = "time-out")
public long timeOut;
@Arg(dest = "time-out")
public long timeOut;
+ @Arg(dest = "ip")
+ public String ip;
+
+ @Arg(dest = "thread-pool-size")
+ public int threadPoolSize;
+
static ArgumentParser getParser() {
final ArgumentParser parser = ArgumentParsers.newArgumentParser("netconf testtool");
static ArgumentParser getParser() {
final ArgumentParser parser = ArgumentParsers.newArgumentParser("netconf testtool");
parser.addArgument("--thread-amount")
.type(Integer.class)
.setDefault(1)
parser.addArgument("--thread-amount")
.type(Integer.class)
.setDefault(1)
- .dest("thread-amount");
+ .dest("thread-amount")
+ .help("The number of threads to use for configuring devices.");
parser.addArgument("--throttle")
.type(Integer.class)
parser.addArgument("--throttle")
.type(Integer.class)
.help("the maximum time in seconds for executing each PUT request")
.dest("time-out");
.help("the maximum time in seconds for executing each PUT request")
.dest("time-out");
+ parser.addArgument("-ip")
+ .type(String.class)
+ .setDefault("0.0.0.0")
+ .help("Ip address which will be used for creating a socket address." +
+ "It can either be a machine name, such as " +
+ "java.sun.com, or a textual representation of its IP address.")
+ .dest("ip");
+
+ parser.addArgument("--thread-pool-size")
+ .type(Integer.class)
+ .setDefault(8)
+ .help("The number of threads to keep in the pool, when creating a device simulator. Even if they are idle.")
+ .dest("thread-pool-size");
+
Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
Preconditions.checkArgument(destination.startsWith("/"), "Destination should start with a '/'");
Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
Preconditions.checkArgument(destination.startsWith("/"), "Destination should start with a '/'");
+ Preconditions.checkArgument(threadAmount > 0, "Parameter thread-amount must be greater than 0");
}
public InetSocketAddress getInetAddress() {
}
public InetSocketAddress getInetAddress() {
.setDefault(1)
.dest("thread-amount");
.setDefault(1)
.dest("thread-amount");
- // TODO add get-config option instead of edit + commit
- // TODO different edit config content
-
Preconditions.checkArgument(editContent.exists(), "Edit content file missing");
Preconditions.checkArgument(editContent.isDirectory() == false, "Edit content file is a dir");
Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
Preconditions.checkArgument(editContent.exists(), "Edit content file missing");
Preconditions.checkArgument(editContent.isDirectory() == false, "Edit content file is a dir");
Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
+ Preconditions.checkArgument(threadAmount > 0, "Parameter thread-amount must be greater than 0");
+ Preconditions.checkArgument(msgTimeout >= 0, "Parameter msg-timeout must be greater than 0");
}
public InetSocketAddress getInetAddress() {
}
public InetSocketAddress getInetAddress() {