Migrate users of deprecated methods 64/110464/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Mar 2024 13:26:51 +0000 (14:26 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Mar 2024 13:26:51 +0000 (14:26 +0100)
Drop the get prefix from DataObjectModification method callers and
migrate to registerTreeChangeListener().

Change-Id: I878b6969e9dfe65ad82c23541178e61f44381914
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractNodeConnectorCommitter.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManager.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java

index 7634e13a4066c08a84775ac9bf85223f1b0de19d..0cb80cede70d5933a30f1d88dca8b1de35a70d32 100644 (file)
@@ -64,47 +64,46 @@ public abstract class AbstractListeningCommiter<T extends DataObject>
         LOG.trace("Received data changes :{}", requireNonNull(changes, "Changes may not be null!"));
 
         for (DataTreeModification<T> change : changes) {
-            final InstanceIdentifier<T> key = change.getRootPath().getRootIdentifier();
+            final InstanceIdentifier<T> key = change.getRootPath().path();
             final DataObjectModification<T> mod = change.getRootNode();
             final InstanceIdentifier<FlowCapableNode> nodeIdent =
                     key.firstIdentifierOf(FlowCapableNode.class);
             try {
                 if (preConfigurationCheck(nodeIdent)) {
-                    switch (mod.getModificationType()) {
+                    switch (mod.modificationType()) {
                         case DELETE:
-                            remove(key, mod.getDataBefore(), nodeIdent);
+                            remove(key, mod.dataBefore(), nodeIdent);
                             break;
                         case SUBTREE_MODIFIED:
-                            update(key, mod.getDataBefore(), mod.getDataAfter(), nodeIdent);
+                            update(key, mod.dataBefore(), mod.dataAfter(), nodeIdent);
                             break;
                         case WRITE:
-                            if (mod.getDataBefore() == null) {
-                                add(key, mod.getDataAfter(), nodeIdent);
+                            final var dataBefore = mod.dataBefore();
+                            if (dataBefore == null) {
+                                add(key, mod.dataAfter(), nodeIdent);
                             } else {
-                                update(key, mod.getDataBefore(), mod.getDataAfter(), nodeIdent);
+                                update(key, dataBefore, mod.dataAfter(), nodeIdent);
                             }
                             break;
                         default:
-                            throw new IllegalArgumentException(
-                                "Unhandled modification type " + mod.getModificationType());
+                            throw new IllegalArgumentException("Unhandled modification type " + mod.modificationType());
                     }
                 } else if (provider.isStaleMarkingEnabled()) {
                     LOG.info("Stale-Marking ENABLED and switch {} is NOT connected, storing stale entities", nodeIdent);
                     // Switch is NOT connected
-                    switch (mod.getModificationType()) {
+                    switch (mod.modificationType()) {
                         case DELETE:
-                            createStaleMarkEntity(key, mod.getDataBefore(), nodeIdent);
+                            createStaleMarkEntity(key, mod.dataBefore(), nodeIdent);
                             break;
                         case SUBTREE_MODIFIED:
                         case WRITE:
                             break;
                         default:
-                            throw new IllegalArgumentException(
-                                "Unhandled modification type " + mod.getModificationType());
+                            throw new IllegalArgumentException("Unhandled modification type " + mod.modificationType());
                     }
                 }
             } catch (RuntimeException e) {
-                LOG.error("Failed to handle event {} key {} due to error ", mod.getModificationType(), key, e);
+                LOG.error("Failed to handle event {} key {} due to error ", mod.modificationType(), key, e);
             }
         }
     }
index 1f4145cba520460d132ec232a24799d1d294e876..42634ac39e1ca2a871e4064570048eaac93a09ee 100644 (file)
@@ -25,28 +25,29 @@ public abstract class AbstractNodeConnectorCommitter<T extends DataObject>
         requireNonNull(changes, "Changes may not be null!");
 
         for (DataTreeModification<T> change : changes) {
-            final InstanceIdentifier<T> key = change.getRootPath().getRootIdentifier();
+            final InstanceIdentifier<T> key = change.getRootPath().path();
             final DataObjectModification<T> mod = change.getRootNode();
             final InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent = key
                     .firstIdentifierOf(FlowCapableNodeConnector.class);
 
             if (preConfigurationCheck(nodeConnIdent)) {
-                switch (mod.getModificationType()) {
+                switch (mod.modificationType()) {
                     case DELETE:
-                        remove(key, mod.getDataBefore(), nodeConnIdent);
+                        remove(key, mod.dataBefore(), nodeConnIdent);
                         break;
                     case SUBTREE_MODIFIED:
-                        update(key, mod.getDataBefore(), mod.getDataAfter(), nodeConnIdent);
+                        update(key, mod.dataBefore(), mod.dataAfter(), nodeConnIdent);
                         break;
                     case WRITE:
-                        if (mod.getDataBefore() == null) {
-                            add(key, mod.getDataAfter(), nodeConnIdent);
+                        final var dataBefore = mod.dataBefore();
+                        if (dataBefore == null) {
+                            add(key, mod.dataAfter(), nodeConnIdent);
                         } else {
-                            update(key, mod.getDataBefore(), mod.getDataAfter(), nodeConnIdent);
+                            update(key, dataBefore, mod.dataAfter(), nodeConnIdent);
                         }
                         break;
                     default:
-                        throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
+                        throw new IllegalArgumentException("Unhandled modification type " + mod.modificationType());
                 }
             }
         }
index 35c764223c1c9ba4df7fedc12198f332788d143d..08a1943bad5899646d54edc62f8f20281944628f 100644 (file)
@@ -21,9 +21,9 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.ReentrantLock;
 import org.checkerframework.checker.lock.qual.Holding;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
 import org.opendaylight.mdsal.binding.api.DataTreeModification;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
@@ -53,7 +53,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Manager for clustering service registrations of {@link DeviceMastership}.
  */
-public class DeviceMastershipManager implements ClusteredDataTreeChangeListener<FlowCapableNode>, AutoCloseable,
+public class DeviceMastershipManager implements DataTreeChangeListener<FlowCapableNode>, AutoCloseable,
         MastershipChangeService {
     private static final Logger LOG = LoggerFactory.getLogger(DeviceMastershipManager.class);
     private static final InstanceIdentifier<FlowCapableNode> II_TO_FLOW_CAPABLE_NODE = InstanceIdentifier
@@ -75,8 +75,8 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener<
                                    final RpcProviderService rpcProviderService) {
         this.reconcliationAgent = reconcliationAgent;
         this.rpcProviderService = rpcProviderService;
-        listenerRegistration = dataBroker.registerDataTreeChangeListener(
-            DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+        listenerRegistration = dataBroker.registerTreeChangeListener(
+            DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL,
                 InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)), this);
         mastershipChangeServiceRegistration = mastershipChangeServiceManager.register(this);
     }
@@ -99,26 +99,26 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener<
     @Override
     public void onDataTreeChanged(final List<DataTreeModification<FlowCapableNode>> changes) {
         for (DataTreeModification<FlowCapableNode> change : changes) {
-            final InstanceIdentifier<FlowCapableNode> key = change.getRootPath().getRootIdentifier();
+            final InstanceIdentifier<FlowCapableNode> key = change.getRootPath().path();
             final DataObjectModification<FlowCapableNode> mod = change.getRootNode();
             final InstanceIdentifier<FlowCapableNode> nodeIdent = key.firstIdentifierOf(FlowCapableNode.class);
 
-            switch (mod.getModificationType()) {
+            switch (mod.modificationType()) {
                 case DELETE:
-                    if (mod.getDataAfter() == null) {
-                        remove(key, mod.getDataBefore(), nodeIdent);
+                    if (mod.dataAfter() == null) {
+                        remove(key, mod.dataBefore(), nodeIdent);
                     }
                     break;
                 case SUBTREE_MODIFIED:
                     // NO-OP since we do not need to reconcile on Node-updated
                     break;
                 case WRITE:
-                    if (mod.getDataBefore() == null) {
-                        add(key, mod.getDataAfter(), nodeIdent);
+                    if (mod.dataBefore() == null) {
+                        add(key, mod.dataAfter(), nodeIdent);
                     }
                     break;
                 default:
-                    throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
+                    throw new IllegalArgumentException("Unhandled modification type " + mod.modificationType());
             }
         }
     }
index b3b1519ea5df8edf3984cfd68a6b972b8bf89162..36298e6814cdcee05072c4f1af6a67e0b62dc198 100644 (file)
@@ -47,7 +47,7 @@ public final class FlowNodeConnectorInventoryTranslatorImpl
     public FlowNodeConnectorInventoryTranslatorImpl(final DataBroker dataBroker) {
         requireNonNull(dataBroker, "DataBroker can not be null!");
         listenerRegistration = dataBroker.registerDataTreeChangeListener(
-            DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, getWildCardPath()), this);
+            DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, getWildCardPath()), this);
     }
 
     @Override