aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Mitsura <oleg.mitsura@amdocs.com>2019-11-05 15:37:15 -0500
committerOleg Mitsura <oleg.mitsura@amdocs.com>2019-11-05 15:37:15 -0500
commitc2d06ed4d1d85674277a2225b5999967cf59a432 (patch)
treee5ba08ac24c070b047b45121b2db819ffa04fdcc
parentfe3cd654fa059670be9d7c7ca762c83a0960c308 (diff)
netconf retry disconnect()
Issue-ID: CCSDK-1908 Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com> Change-Id: I90ca822c042ec84fda717a152c4f699bacdd87ad
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt14
1 files changed, 11 insertions, 3 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
index 03f20080c..dac977bdd 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
@@ -76,8 +76,15 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
}
override fun disconnect() {
- if (rpcService.closeSession(false).status.equals(
- RpcStatus.FAILURE, true)) {
+ var retryNum = 3
+ while(rpcService.closeSession(false).status
+ .equals(RpcStatus.FAILURE, true) &&retryNum>0) {
+ log.error("disconnect: graceful disconnect failed, attempt $retryNum")
+ retryNum--;
+ }
+ //if we can't close the session, try to force terminate.
+ if(retryNum == 0) {
+ log.error("disconnect: trying to force-terminate the session.")
rpcService.closeSession(true)
}
try {
@@ -287,6 +294,7 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
*/
@Throws(IOException::class)
private fun close() {
+ log.debug("close was called.")
session.close()
// Closes the socket which should interrupt the streamHandler
channel.close()
@@ -307,4 +315,4 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
internal fun setClient(client: SshClient) { this.client = client }
internal fun setSession(session: ClientSession) { this.session = session }
internal fun setChannel(channel: ClientChannel) { this.channel = channel }
-} \ No newline at end of file
+}