import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
+import org.opendaylight.netconf.client.mdsal.NetconfDeviceCommunicator;
+import org.opendaylight.netconf.client.mdsal.api.NetconfSessionPreferences;
+import org.opendaylight.netconf.client.mdsal.api.RemoteDevice;
import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
-import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
-import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
-import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
import org.opendaylight.netconf.test.tool.TestToolUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.CommitInput;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditConfigInput;
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, e);
}
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));
}
}
try {
future.get(4L, TimeUnit.MINUTES);
} catch (ExecutionException | TimeoutException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
executorService.shutdownNow();
} catch (final InterruptedException e) {
- throw new RuntimeException("Unable to execute requests", e);
+ throw new IllegalStateException("Unable to execute requests", e);
}
started.stop();
} else {
netconfClientDispatcher = ConfigurableClientDispatcher.createChunkedExi(nioGroup, nioGroup, timer);
}
+ } else if (params.legacyFraming) {
+ netconfClientDispatcher = ConfigurableClientDispatcher.createLegacy(nioGroup, nioGroup, timer);
} else {
- if (params.legacyFraming) {
- netconfClientDispatcher = ConfigurableClientDispatcher.createLegacy(nioGroup, nioGroup, timer);
- } else {
- netconfClientDispatcher = ConfigurableClientDispatcher.createChunked(nioGroup, nioGroup, timer);
- }
+ netconfClientDispatcher = ConfigurableClientDispatcher.createChunked(nioGroup, nioGroup, timer);
}
return netconfClientDispatcher;
}
return null;
}
- static class LoggingRemoteDevice
- implements RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> {
+ static class LoggingRemoteDevice implements RemoteDevice<NetconfDeviceCommunicator> {
@Override
public void onRemoteSessionUp(final NetconfSessionPreferences remoteSessionCapabilities,
final NetconfDeviceCommunicator netconfDeviceCommunicator) {
LOG.info("Session down");
}
- @Override
- public void onRemoteSessionFailed(final Throwable throwable) {
- LOG.info("Session failed");
- }
-
@Override
public void onNotification(final NetconfMessage notification) {
- LOG.info("Notification received: {}", notification.toString());
+ LOG.info("Notification received: {}", notification);
}
}
-
}