X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fconnect%2Fnetconf%2FNotificationHandler.java;h=bc3326e1ae5b58dc23dc7c14927a83d5d34d1fcf;hp=b5927f0bd540519ca60aadd4b095df3e81acbc89;hb=b42eff1340aee9b4c29265de40296926d88b9525;hpb=bd8beb1bfee9f421ad8f2d07b1424b21038234a2 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 b5927f0bd5..bc3326e1ae 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 @@ -42,7 +42,7 @@ final class NotificationHandler { synchronized void handleNotification(final NetconfMessage notification) { if(passNotifications) { - passNotification(messageTransformer.toNotification(notification)); + passNotification(transformNotification(notification)); } else { queueNotification(notification); } @@ -55,12 +55,18 @@ final class NotificationHandler { passNotifications = true; for (final NetconfMessage cachedNotification : queue) { - passNotification(messageTransformer.toNotification(cachedNotification)); + passNotification(transformNotification(cachedNotification)); } queue.clear(); } + private CompositeNode transformNotification(final NetconfMessage cachedNotification) { + final CompositeNode parsedNotification = messageTransformer.toNotification(cachedNotification); + Preconditions.checkNotNull(parsedNotification, "%s: Unable to parse received notification: %s", id, cachedNotification); + return parsedNotification; + } + private void queueNotification(final NetconfMessage notification) { Preconditions.checkState(passNotifications == false); @@ -74,7 +80,6 @@ final class NotificationHandler { private synchronized void passNotification(final CompositeNode parsedNotification) { logger.debug("{}: Forwarding notification {}", id, parsedNotification); - Preconditions.checkNotNull(parsedNotification); if(filter == null || filter.filterNotification(parsedNotification).isPresent()) { salFacade.onNotification(parsedNotification); @@ -85,6 +90,11 @@ final class NotificationHandler { this.filter = filter; } + synchronized void onRemoteSchemaDown() { + queue.clear(); + passNotifications = false; + } + static interface NotificationFilter { Optional filterNotification(CompositeNode notification);