Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Bug 2410: Use generated serialVersionUID for messages
[controller.git]
/
opendaylight
/
netconf
/
netconf-testtool
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
netconf
/
test
/
tool
/
NetconfDeviceSimulator.java
diff --git
a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/NetconfDeviceSimulator.java
b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/NetconfDeviceSimulator.java
index adcdea6073860b5f6b660faa356baf9cf7455df4..287ff2dca77a60a4a8f3cac0569c96fad233aac4 100644
(file)
--- a/
opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/NetconfDeviceSimulator.java
+++ b/
opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/NetconfDeviceSimulator.java
@@
-30,6
+30,7
@@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
+import java.net.BindException;
import java.net.Inet4Address;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.Inet4Address;
import java.net.InetSocketAddress;
import java.net.URI;
@@
-185,6
+186,10
@@
public class NetconfDeviceSimulator implements Closeable {
final PEMGeneratorHostKeyProvider keyPairProvider = getPemGeneratorHostKeyProvider();
for (int i = 0; i < params.deviceCount; i++) {
final PEMGeneratorHostKeyProvider keyPairProvider = getPemGeneratorHostKeyProvider();
for (int i = 0; i < params.deviceCount; i++) {
+ if (currentPort > 65535) {
+ LOG.warn("Port cannot be greater than 65535, stopping further attempts.");
+ break;
+ }
final InetSocketAddress address = getAddress(currentPort);
final ChannelFuture server;
final InetSocketAddress address = getAddress(currentPort);
final ChannelFuture server;
@@
-195,16
+200,19
@@
public class NetconfDeviceSimulator implements Closeable {
server = dispatcher.createLocalServer(tcpLocalAddress);
try {
final SshProxyServer sshServer = new SshProxyServer(minaTimerExecutor, nettyThreadgroup, nioExecutor);
server = dispatcher.createLocalServer(tcpLocalAddress);
try {
final SshProxyServer sshServer = new SshProxyServer(minaTimerExecutor, nettyThreadgroup, nioExecutor);
- sshServer.bind(getSshConfiguration(bindingAddress, tcpLocalAddress));
+ sshServer.bind(getSshConfiguration(bindingAddress, tcpLocalAddress
, keyPairProvider
));
sshWrappers.add(sshServer);
sshWrappers.add(sshServer);
- } catch (final Exception e) {
- LOG.warn("Cannot start simulated device on {},
skipping", address, e
);
+ } catch (final
Bind
Exception e) {
+ LOG.warn("Cannot start simulated device on {},
port already in use. Skipping.", address
);
// Close local server and continue
server.cancel(true);
if(server.isDone()) {
server.channel().close();
}
continue;
// Close local server and continue
server.cancel(true);
if(server.isDone()) {
server.channel().close();
}
continue;
+ } catch (final IOException e) {
+ LOG.warn("Cannot start simulated device on {} due to IOException.", address, e);
+ break;
} finally {
currentPort++;
}
} finally {
currentPort++;
}
@@
-242,6
+250,8
@@
public class NetconfDeviceSimulator implements Closeable {
if(openDevices.size() == params.deviceCount) {
LOG.info("All simulated devices started successfully from port {} to {}", params.startingPort, currentPort - 1);
if(openDevices.size() == params.deviceCount) {
LOG.info("All simulated devices started successfully from port {} to {}", params.startingPort, currentPort - 1);
+ } else if (openDevices.size() == 0) {
+ LOG.warn("No simulated devices started.");
} else {
LOG.warn("Not all simulated devices started successfully. Started devices ar on ports {}", openDevices);
}
} else {
LOG.warn("Not all simulated devices started successfully. Started devices ar on ports {}", openDevices);
}
@@
-249,7
+259,7
@@
public class NetconfDeviceSimulator implements Closeable {
return openDevices;
}
return openDevices;
}
- private SshProxyServerConfiguration getSshConfiguration(final InetSocketAddress bindingAddress, final LocalAddress tcpLocalAddress) throws IOException {
+ private SshProxyServerConfiguration getSshConfiguration(final InetSocketAddress bindingAddress, final LocalAddress tcpLocalAddress
, final PEMGeneratorHostKeyProvider keyPairProvider
) throws IOException {
return new SshProxyServerConfigurationBuilder()
.setBindingAddress(bindingAddress)
.setLocalAddress(tcpLocalAddress)
return new SshProxyServerConfigurationBuilder()
.setBindingAddress(bindingAddress)
.setLocalAddress(tcpLocalAddress)
@@
-259,7
+269,7
@@
public class NetconfDeviceSimulator implements Closeable {
return true;
}
})
return true;
}
})
- .setKeyPairProvider(
new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString())
)
+ .setKeyPairProvider(
keyPairProvider
)
.setIdleTimeout(Integer.MAX_VALUE)
.createSshProxyServerConfiguration();
}
.setIdleTimeout(Integer.MAX_VALUE)
.createSshProxyServerConfiguration();
}