X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-persister-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fpersist%2Fimpl%2FConfigPersisterNotificationHandler.java;h=d390161affd49ac510ac66fe7cca699b2418f2eb;hp=c01a225a330688991bdb6c524e4de57f2df8290b;hb=d105455084f43d9423b7c0e6af785302e6a3ea93;hpb=a92d9d6a21a0f6ca8d2153795721f500eaf29ee9 diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java index c01a225a33..d390161aff 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java @@ -17,6 +17,7 @@ import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification; import org.opendaylight.controller.netconf.api.jmx.DefaultCommitOperationMXBean; import org.opendaylight.controller.netconf.api.jmx.NetconfJMXNotification; import org.opendaylight.controller.netconf.client.NetconfClient; +import org.opendaylight.controller.netconf.client.NetconfClientDispatcher; import org.opendaylight.controller.netconf.util.xml.XmlElement; import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.util.xml.XmlUtil; @@ -27,7 +28,12 @@ import org.w3c.dom.Element; import org.xml.sax.SAXException; import javax.annotation.concurrent.ThreadSafe; -import javax.management.*; +import javax.management.InstanceNotFoundException; +import javax.management.MBeanServerConnection; +import javax.management.Notification; +import javax.management.NotificationListener; +import javax.management.ObjectName; +import javax.net.ssl.SSLContext; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; @@ -46,6 +52,7 @@ public class ConfigPersisterNotificationHandler implements NotificationListener, private static final Logger logger = LoggerFactory.getLogger(ConfigPersisterNotificationHandler.class); private final InetSocketAddress address; + private final NetconfClientDispatcher dispatcher; private NetconfClient netconfClient; @@ -69,6 +76,7 @@ public class ConfigPersisterNotificationHandler implements NotificationListener, this.address = address; this.mbeanServer = mbeanServer; this.timeout = timeout; + this.dispatcher = new NetconfClientDispatcher(Optional.absent()); } public void init() throws InterruptedException { @@ -113,7 +121,7 @@ public class ConfigPersisterNotificationHandler implements NotificationListener, attempt++; try { - netconfClient = new NetconfClient(this.toString(), address, delay); + netconfClient = new NetconfClient(this.toString(), address, delay, dispatcher); // TODO is this correct ex to catch ? } catch (IllegalStateException e) { logger.debug("Netconf {} was not initialized or is not stable, attempt {}", address, attempt, e); @@ -305,6 +313,12 @@ public class ConfigPersisterNotificationHandler implements NotificationListener, } } + try { + dispatcher.close(); + } catch (Exception e) { + logger.warn("Unable to close netconf client dispatcher {}", dispatcher, e); + } + // unregister from JMX try { if (mbeanServer.isRegistered(on)) {