import ch.qos.logback.classic.Level;
import com.google.common.base.Stopwatch;
import com.google.common.io.Files;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import java.util.concurrent.TimeoutException;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
+@SuppressFBWarnings("DM_EXIT")
public final class StressClient {
private static final Logger LOG = LoggerFactory.getLogger(StressClient.class);
private static Parameters params;
+ private StressClient() {
+
+ }
+
public static void main(final String[] args) {
params = parseArgs(args, Parameters.getParser());
root.setLevel(params.debug ? Level.DEBUG : Level.INFO);
final int threadAmount = params.threadAmount;
- LOG.info("thread amount: " + threadAmount);
+ LOG.info("thread amount: {}", threadAmount);
final int requestsPerThread = params.editCount / params.threadAmount;
- LOG.info("requestsPerThread: " + requestsPerThread);
+ LOG.info("requestsPerThread: {}", requestsPerThread);
final int leftoverRequests = params.editCount % params.threadAmount;
- LOG.info("leftoverRequests: " + leftoverRequests);
-
+ LOG.info("leftoverRequests: {}", leftoverRequests);
LOG.info("Preparing messages");
// Prepare all msgs up front
final List<List<NetconfMessage>> allPreparedMessages = new ArrayList<>(threadAmount);
for (int i = 0; i < threadAmount; i++) {
if (i != threadAmount - 1) {
- allPreparedMessages.add(new ArrayList<NetconfMessage>(requestsPerThread));
+ allPreparedMessages.add(new ArrayList<>(requestsPerThread));
} else {
- allPreparedMessages.add(new ArrayList<NetconfMessage>(requestsPerThread + leftoverRequests));
+ allPreparedMessages.add(new ArrayList<>(requestsPerThread + leftoverRequests));
}
}
final String editContentString;
try {
- editContentString = Files.toString(params.editContent, StandardCharsets.UTF_8);
+ editContentString = Files.asCharSource(params.editContent, StandardCharsets.UTF_8).read();
} catch (final IOException e) {
- throw new IllegalArgumentException("Cannot read content of " + params.editContent);
+ throw new IllegalArgumentException("Cannot read content of " + params.editContent, e);
}
for (int i = 0; i < threadAmount; i++) {
padding = leftoverRequests;
}
for (int j = 0; j < requestsPerThread + padding; j++) {
- LOG.debug("id: " + (i * requestsPerThread + j));
+ LOG.debug("id: {}", i * requestsPerThread + j);
preparedMessages.add(prepareMessage(i * requestsPerThread + j, editContentString));
}
}
final NioEventLoopGroup nioGroup = new NioEventLoopGroup();
final Timer timer = new HashedWheelTimer();
- final NetconfClientDispatcherImpl netconfClientDispatcher = configureClientDispatcher(params, nioGroup, timer);
+ final NetconfClientDispatcherImpl netconfClientDispatcher = configureClientDispatcher(nioGroup, timer);
final List<StressClientCallable> callables = new ArrayList<>(threadAmount);
for (final List<NetconfMessage> messages : allPreparedMessages) {
started.stop();
LOG.info("FINISHED. Execution time: {}", started);
- LOG.info("Requests per second: {}", (params.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS)));
+ LOG.info("Requests per second: {}", params.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS));
// Cleanup
timer.stop();
return netconfMessage;
}
- private static NetconfClientDispatcherImpl configureClientDispatcher(final Parameters params,
- final NioEventLoopGroup nioGroup, final Timer timer) {
+ private static NetconfClientDispatcherImpl configureClientDispatcher(final NioEventLoopGroup nioGroup,
+ final Timer timer) {
final NetconfClientDispatcherImpl netconfClientDispatcher;
if (params.exi) {
if (params.legacyFraming) {