From: Robert Varga Date: Thu, 13 Oct 2022 18:06:54 +0000 (+0200) Subject: Migrate topology-lldp-discovery to simplified Listener X-Git-Tag: release/argon~14 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=74cf4be1dfb6eb18093919f3bd3d4ace11a69170;p=openflowplugin.git Migrate topology-lldp-discovery to simplified Listener Rather than using the composite notification service, use the simpler NotificationService.Listener. Change-Id: Icdd28937645c74c5a5a268103409790473937c55 Signed-off-by: Robert Varga --- diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java index 5d6f82dfa9..4221f3427b 100644 --- a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java +++ b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java @@ -12,9 +12,9 @@ import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfig; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.concepts.Registration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,7 +24,7 @@ public class LLDPActivator implements AutoCloseable { private static String lldpSecureKey; - private final ListenerRegistration lldpNotificationRegistration; + private final Registration lldpNotificationRegistration; @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") @Inject @@ -35,7 +35,8 @@ public class LLDPActivator implements AutoCloseable { LOG.info("Starting LLDPActivator with lldpSecureKey: {}", lldpSecureKey); - lldpNotificationRegistration = notificationService.registerNotificationListener(lldpDiscoveryListener); + lldpNotificationRegistration = + notificationService.registerListener(PacketReceived.class, lldpDiscoveryListener); LOG.info("LLDPDiscoveryListener started."); } diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java index 2766e169ee..bde92720cd 100644 --- a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java +++ b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java @@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.applications.topology.lldp; import javax.inject.Inject; import javax.inject.Singleton; import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationService.Listener; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.openflowplugin.applications.topology.lldp.utils.LLDPDiscoveryUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered; @@ -17,13 +18,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Singleton -public class LLDPDiscoveryListener implements PacketProcessingListener { +public class LLDPDiscoveryListener implements Listener { private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryListener.class); private final LLDPLinkAger lldpLinkAger; @@ -35,11 +35,11 @@ public class LLDPDiscoveryListener implements PacketProcessingListener { final LLDPLinkAger lldpLinkAger, final EntityOwnershipService entityOwnershipService) { this.notificationService = notificationService; this.lldpLinkAger = lldpLinkAger; - this.eos = entityOwnershipService; + eos = entityOwnershipService; } @Override - public void onPacketReceived(final PacketReceived lldp) { + public void onNotification(final PacketReceived lldp) { NodeConnectorRef src = LLDPDiscoveryUtils.lldpToNodeConnectorRef(lldp.getPayload(), true); if (src != null) { final NodeKey nodeKey = lldp.getIngress().getValue().firstKeyOf(Node.class); @@ -51,7 +51,7 @@ public class LLDPDiscoveryListener implements PacketProcessingListener { final LinkDiscovered ld = ldb.build(); final boolean linkWasPresent = lldpLinkAger.isLinkPresent(ld); lldpLinkAger.put(ld); - if (LLDPDiscoveryUtils.isEntityOwned(this.eos, nodeKey.getId().getValue())) { + if (LLDPDiscoveryUtils.isEntityOwned(eos, nodeKey.getId().getValue())) { if (linkWasPresent) { LOG.trace("Link {} already present in the cache, skip publishing the notification.", ld); } else {