NETVIRT-1630 migrate to md-sal APIs
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / l2gw / ha / handlers / ConfigNodeUpdatedHandler.java
index 1e14636251d6d9adead3706573b86b5ec0459419..f8b7dd1e1f168257075936c1504b1059508db79a 100644 (file)
@@ -7,11 +7,9 @@
  */
 package org.opendaylight.netvirt.elan.l2gw.ha.handlers;
 
-import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
+import org.opendaylight.genius.infra.Datastore.Configuration;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
 import org.opendaylight.netvirt.elan.l2gw.ha.merge.GlobalAugmentationMerger;
 import org.opendaylight.netvirt.elan.l2gw.ha.merge.GlobalNodeMerger;
 import org.opendaylight.netvirt.elan.l2gw.ha.merge.PSAugmentationMerger;
@@ -30,54 +28,32 @@ public class ConfigNodeUpdatedHandler {
     /**
      * Copy updated data from HA node to child node of config data tree.
      *
-     * @param haUpdated HA node updated
-     * @param haOriginal HA node original
      * @param haChildNodeId HA child node which needs to be updated
+     * @param mod the data object modification
      * @param tx Transaction
-     * @throws ReadFailedException  Exception thrown if read fails
-     * @throws ExecutionException  Exception thrown if Execution fail
-     * @throws InterruptedException Thread interrupted Exception
      */
-    public void copyHAGlobalUpdateToChild(Node haUpdated,
-                                          Node haOriginal,
-                                          InstanceIdentifier<Node> haChildNodeId,
-                                          ReadWriteTransaction tx)
-            throws InterruptedException, ExecutionException, ReadFailedException {
-
-        Node existingNode = HwvtepHAUtil.readNode(tx, LogicalDatastoreType.CONFIGURATION, haChildNodeId);
-        HwvtepGlobalAugmentation updatedGlobal = HwvtepHAUtil.getGlobalAugmentationOfNode(haUpdated);
-        HwvtepGlobalAugmentation origGlobal = HwvtepHAUtil.getGlobalAugmentationOfNode(haOriginal);
-        HwvtepGlobalAugmentation existingData = HwvtepHAUtil.getGlobalAugmentationOfNode(existingNode);
-
-        globalAugmentationMerger.mergeConfigUpdate(existingData, updatedGlobal, origGlobal, haChildNodeId, tx);
-        globalNodeMerger.mergeConfigUpdate(existingNode, haUpdated, haOriginal, haChildNodeId, tx);
+    public void copyHAGlobalUpdateToChild(InstanceIdentifier<Node> haChildNodeId,
+                                          DataObjectModification<Node> mod,
+                                          TypedReadWriteTransaction<Configuration> tx) {
+        globalAugmentationMerger.mergeConfigUpdate(haChildNodeId,
+                mod.getModifiedAugmentation(HwvtepGlobalAugmentation.class), tx);
+        globalNodeMerger.mergeConfigUpdate(haChildNodeId, mod, tx);
     }
 
     /**
      * Copy HA ps node update to HA child ps node of config data tree.
      *
-     * @param haUpdated HA node updated
-     * @param haOriginal HA node original
      * @param haChildNodeId HA child node which needs to be updated
+     * @param mod the data object modification
      * @param tx Transaction
-     * @throws ReadFailedException  Exception thrown if read fails
-     * @throws ExecutionException  Exception thrown if Execution fail
-     * @throws InterruptedException Thread interrupted Exception
      */
-    public void copyHAPSUpdateToChild(Node haUpdated,
-                                      Node haOriginal,
-                                      InstanceIdentifier<Node> haChildNodeId,
-                                      ReadWriteTransaction tx)
-            throws InterruptedException, ExecutionException, ReadFailedException {
-
-        Node existingNode = HwvtepHAUtil.readNode(tx, LogicalDatastoreType.CONFIGURATION, haChildNodeId);
-
-        PhysicalSwitchAugmentation updated = HwvtepHAUtil.getPhysicalSwitchAugmentationOfNode(haUpdated);
-        PhysicalSwitchAugmentation orig = HwvtepHAUtil.getPhysicalSwitchAugmentationOfNode(haOriginal);
-        PhysicalSwitchAugmentation existingData = HwvtepHAUtil.getPhysicalSwitchAugmentationOfNode(existingNode);
+    public void copyHAPSUpdateToChild(InstanceIdentifier<Node> haChildNodeId,
+                                      DataObjectModification<Node> mod,
+                                      TypedReadWriteTransaction<Configuration> tx) {
 
-        psAugmentationMerger.mergeConfigUpdate(existingData, updated, orig, haChildNodeId, tx);
-        psNodeMerger.mergeConfigUpdate(existingNode, haUpdated, haOriginal, haChildNodeId, tx);
+        psAugmentationMerger.mergeConfigUpdate(haChildNodeId,
+                mod.getModifiedAugmentation(PhysicalSwitchAugmentation.class), tx);
+        psNodeMerger.mergeConfigUpdate(haChildNodeId, mod, tx);
     }
 
 }