Resetting variables of a NetconfSession before reopening the underlying transport SSH connection and session.
Change-Id: I34fb61d8ec28a05d4a9148df853c1be98bd3559f
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
index 07f7c98..f46c42f 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
@@ -167,7 +167,7 @@
this.addDeviceOutputListener(new NetconfDeviceOutputEventListenerImpl(deviceInfo));
sendHello();
} catch (IOException e) {
- log.error("Failed to create ch.ethz.ssh2.Session session.", e);
+ log.error("Failed to create ch.ethz.ssh2.Session session {} ", e.getMessage());
throw new NetconfException("Failed to create ch.ethz.ssh2.Session session with device" +
deviceInfo, e);
}
@@ -257,13 +257,17 @@
private void checkAndRestablishSession() throws NetconfException {
if (sshSession.getState() != 2) {
try {
+ log.debug("The session with {} was reopened", deviceInfo.getDeviceId());
startSshSession();
} catch (IOException e) {
log.debug("The connection with {} was reopened", deviceInfo.getDeviceId());
try {
+ connectionActive = false;
+ replies.clear();
+ messageIdInteger.set(0);
startConnection();
} catch (IOException e2) {
- log.error("No connection {} for device", netconfConnection, e2);
+ log.error("No connection {} for device {}", netconfConnection, e.getMessage());
throw new NetconfException("Cannot re-open the connection with device" + deviceInfo, e);
}
}
@@ -610,7 +614,8 @@
@Override
public void notify(NetconfDeviceOutputEvent event) {
Optional<Integer> messageId = event.getMessageID();
-
+ log.debug("messageID {}, waiting replies messageIDs {}", messageId,
+ replies.keySet());
if (!messageId.isPresent()) {
errorReplies.add(event.getMessagePayload());
log.error("Device {} sent error reply {}",