Use a local for nodeId
[netconf.git] / netconf / callhome-provider / src / main / java / org / opendaylight / netconf / callhome / mount / CallHomeMountDispatcher.java
index 407fa8e60ee87ab37e7a5d25e067d28eb3f16506..80c8f1353d377e85e88fc0f8dc866da60d2541c6 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.netconf.client.NetconfClientDispatcher;
 import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
+import org.opendaylight.netconf.nettyutil.ReconnectFuture;
 import org.opendaylight.netconf.sal.connect.api.DeviceActionFactory;
 import org.opendaylight.netconf.sal.connect.api.SchemaResourceManager;
 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseNetconfSchemas;
@@ -51,8 +52,9 @@ public class CallHomeMountDispatcher implements NetconfClientDispatcher, CallHom
     protected CallHomeTopology topology;
 
     private final CloseCallback onCloseHandler = deviceContext -> {
-        LOG.info("Removing {} from Netconf Topology.", deviceContext.getId());
-        topology.disconnectNode(deviceContext.getId());
+        final var nodeId = deviceContext.getId();
+        LOG.info("Removing {} from Netconf Topology.", nodeId);
+        topology.disconnectNode(nodeId);
     };
 
     private final DeviceActionFactory deviceActionFactory;
@@ -92,18 +94,16 @@ public class CallHomeMountDispatcher implements NetconfClientDispatcher, CallHom
     }
 
     @Override
-    public Future<Void> createReconnectingClient(final NetconfReconnectingClientConfiguration clientConfiguration) {
-        return activateChannel(clientConfiguration);
+    public ReconnectFuture createReconnectingClient(final NetconfReconnectingClientConfiguration clientConfiguration) {
+        return new SingleReconnectFuture(eventExecutor, activateChannel(clientConfiguration));
     }
 
-    private <V> Future<V> activateChannel(final NetconfClientConfiguration conf) {
+    private Future<NetconfClientSession> activateChannel(final NetconfClientConfiguration conf) {
         final InetSocketAddress remoteAddr = conf.getAddress();
         final CallHomeMountSessionContext context = getSessionManager().getByAddress(remoteAddr);
         LOG.info("Activating NETCONF channel for ip {} device context {}", remoteAddr, context);
-        if (context == null) {
-            return new FailedFuture<>(eventExecutor, new NullPointerException());
-        }
-        return context.activateNetconfChannel(conf.getSessionListener());
+        return context == null ? new FailedFuture<>(eventExecutor, new NullPointerException())
+            : context.activateNetconfChannel(conf.getSessionListener());
     }
 
     void createTopology() {