Modernize test-common's use of NotificationService 76/102676/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 13 Oct 2022 17:46:51 +0000 (19:46 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 13 Oct 2022 17:46:51 +0000 (19:46 +0200)
Do not user generated PacketProcessingServiceListener, but rather
rely on modernized Listener interface.

Change-Id: I6376aec57152f33b75f5b2806a39e70a67d4cda1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/AbstractDropTest.java
test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java
test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcSender.java

index 0b4d1a4b8318147af1ffe1683a8fd738e2a31cce..f0c47fb9510da3a2923f4a902df9efca8f4b6ab3 100644 (file)
@@ -16,6 +16,7 @@ import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+import org.opendaylight.mdsal.binding.api.NotificationService.Listener;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
@@ -35,7 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeCon
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
-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.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.Uint16;
@@ -44,7 +44,7 @@ import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseable {
+abstract class AbstractDropTest implements Listener<PacketReceived>, AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractDropTest.class);
 
     protected static final Uint16 PRIORITY = Uint16.valueOf(4);
@@ -90,8 +90,7 @@ abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseab
     protected volatile int runablesRejected;
 
     public final DropTestStats getStats() {
-        return new DropTestStats(this.sent, this.rcvd, this.excs, this.ftrFailed, this.ftrSuccess,
-                this.runablesExecuted, this.runablesRejected);
+        return new DropTestStats(sent, rcvd, excs, ftrFailed, ftrSuccess, runablesExecuted, runablesRejected);
     }
 
     AbstractDropTest() {
@@ -112,13 +111,13 @@ abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseab
     }
 
     public final void clearStats() {
-        this.sent = 0;
-        this.rcvd = 0;
-        this.excs = 0;
-        this.ftrSuccess = 0;
-        this.ftrFailed = 0;
-        this.runablesExecuted = 0;
-        this.runablesRejected = 0;
+        sent = 0;
+        rcvd = 0;
+        excs = 0;
+        ftrSuccess = 0;
+        ftrFailed = 0;
+        runablesExecuted = 0;
+        runablesRejected = 0;
     }
 
     private void incrementRunableExecuted() {
@@ -130,7 +129,7 @@ abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseab
     }
 
     @Override
-    public final void onPacketReceived(final PacketReceived notification) {
+    public final void onNotification(final PacketReceived notification) {
         LOG.debug("onPacketReceived - Entering - {}", notification);
 
         RCVD_UPDATER.incrementAndGet(this);
index 0bbee7d8faa5bc7fed74b7e429d90b33a68dcb76..0fbfcb0d769b7f6777bb745a15140a364c4a6618 100644 (file)
@@ -25,7 +25,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMo
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.Uint64;
 import org.opendaylight.yangtools.yang.common.Uint8;
@@ -61,7 +62,7 @@ public class DropTestCommiter extends AbstractDropTest {
 
     private NotificationService notificationService;
 
-    private ListenerRegistration<DropTestCommiter> notificationRegistration;
+    private Registration notificationRegistration;
 
     /**
      * start listening on packetIn.
@@ -71,8 +72,8 @@ public class DropTestCommiter extends AbstractDropTest {
         final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK,
                 STARTUP_LOOP_MAX_RETRIES);
         try {
-            notificationRegistration = looper.loopUntilNoException(() ->
-                notificationService.registerNotificationListener(DropTestCommiter.this));
+            notificationRegistration = looper.loopUntilNoException(
+                () -> notificationService.registerListener(PacketReceived.class, this));
         } catch (Exception e) {
             LOG.warn("DropTest committer notification listener registration fail!");
             LOG.debug("DropTest committer notification listener registration fail! ..", e);
index 9a75f9f63095652b993229e0c4890c37decc6e54..f1b263e4a1391c9e32c5abaab38d7bd84b7f0332 100644 (file)
@@ -23,7 +23,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.I
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.Uint64;
@@ -62,7 +63,7 @@ public class DropTestRpcSender extends AbstractDropTest {
 
     private NotificationService notificationService;
 
-    private ListenerRegistration<DropTestRpcSender> notificationRegistration;
+    private Registration notificationRegistration;
 
     /**
      * Start listening on packetIn.
@@ -73,7 +74,7 @@ public class DropTestRpcSender extends AbstractDropTest {
                 STARTUP_LOOP_MAX_RETRIES);
         try {
             notificationRegistration = looper.loopUntilNoException(
-                () -> notificationService.registerNotificationListener(DropTestRpcSender.this));
+                () -> notificationService.registerListener(PacketReceived.class, this));
         } catch (Exception e) {
             LOG.warn("DropTest sender notification listener registration fail!");
             LOG.debug("DropTest sender notification listener registration fail! ..", e);