X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fconnect%2Fnetconf%2FNotificationHandler.java;h=2d47c6ae1bbe11f5863d66c97db5301208fa29ae;hb=e433e0aa67cc6d144cd3d8d6117de864eb7ebf97;hp=bc3326e1ae5b58dc23dc7c14927a83d5d34d1fcf;hpb=32b25203819eb02df22abfecdcc86896c068f778;p=controller.git diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NotificationHandler.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NotificationHandler.java index bc3326e1ae..2d47c6ae1b 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NotificationHandler.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NotificationHandler.java @@ -11,12 +11,12 @@ import com.google.common.base.Optional; import com.google.common.base.Preconditions; import java.util.LinkedList; import java.util.List; +import org.opendaylight.controller.md.sal.dom.api.DOMNotification; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.opendaylight.controller.sal.connect.api.MessageTransformer; import org.opendaylight.controller.sal.connect.api.RemoteDeviceHandler; import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,14 +29,14 @@ final class NotificationHandler { private final RemoteDeviceHandler salFacade; private final List queue = new LinkedList<>(); - private final MessageTransformer messageTransformer; private final RemoteDeviceId id; private boolean passNotifications = false; + private NotificationFilter filter; + private MessageTransformer messageTransformer; - NotificationHandler(final RemoteDeviceHandler salFacade, final MessageTransformer messageTransformer, final RemoteDeviceId id) { + NotificationHandler(final RemoteDeviceHandler salFacade, final RemoteDeviceId id) { this.salFacade = Preconditions.checkNotNull(salFacade); - this.messageTransformer = Preconditions.checkNotNull(messageTransformer); this.id = Preconditions.checkNotNull(id); } @@ -50,8 +50,11 @@ final class NotificationHandler { /** * Forward all cached notifications and pass all notifications from this point directly to sal facade. + * @param messageTransformer */ - synchronized void onRemoteSchemaUp() { + synchronized void onRemoteSchemaUp(final MessageTransformer messageTransformer) { + this.messageTransformer = Preconditions.checkNotNull(messageTransformer); + passNotifications = true; for (final NetconfMessage cachedNotification : queue) { @@ -61,8 +64,8 @@ final class NotificationHandler { queue.clear(); } - private CompositeNode transformNotification(final NetconfMessage cachedNotification) { - final CompositeNode parsedNotification = messageTransformer.toNotification(cachedNotification); + private DOMNotification transformNotification(final NetconfMessage cachedNotification) { + final DOMNotification parsedNotification = messageTransformer.toNotification(cachedNotification); Preconditions.checkNotNull(parsedNotification, "%s: Unable to parse received notification: %s", id, cachedNotification); return parsedNotification; } @@ -78,7 +81,7 @@ final class NotificationHandler { queue.add(notification); } - private synchronized void passNotification(final CompositeNode parsedNotification) { + private synchronized void passNotification(final DOMNotification parsedNotification) { logger.debug("{}: Forwarding notification {}", id, parsedNotification); if(filter == null || filter.filterNotification(parsedNotification).isPresent()) { @@ -93,10 +96,11 @@ final class NotificationHandler { synchronized void onRemoteSchemaDown() { queue.clear(); passNotifications = false; + messageTransformer = null; } static interface NotificationFilter { - Optional filterNotification(CompositeNode notification); + Optional filterNotification(DOMNotification notification); } }