Enhance the use of cache in HwvtepDeviceInfo 27/88927/3
authorChandra Shekar S <chandra.shekar.s@ericsson.com>
Tue, 7 Apr 2020 07:44:40 +0000 (13:14 +0530)
committerChandra Shekar S <chandra.shekar.s@ericsson.com>
Wed, 8 Apr 2020 05:55:14 +0000 (11:25 +0530)
This review is to enhace the HwvtepDeviceInfo to use the Cache.
It has the following changes.
1. Enhanced to include the incoming update objects in the cache.
2. Check in the cache before deleting.
3. Update the cache when the updates are successfully submitted to db.

Signed-off-by: Chandra Shekar S <chandra.shekar.s@ericsson.com>
Change-Id: I70a923f2b58077e780b53c457b05bb2545a87d4f

15 files changed:
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDeviceInfo.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/AbstractTransactionCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepLogicalSwitchRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepLogicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepMacEntriesRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepMcastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalLocatorRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalLocatorUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalPortRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalPortUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepUcastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepUcastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/TransactionCommand.java

index 46e795e12868129e5c61356d98e9688a39c9783d..4e13e46dbc2d54d30bb288fd8c259dfa85b1ffe0 100644 (file)
@@ -337,6 +337,10 @@ public class HwvtepConnectionInstance {
 
     public void setHasDeviceOwnership(final Boolean hasDeviceOwnership) {
         if (hasDeviceOwnership != null) {
+            if (hasDeviceOwnership != this.hasDeviceOwnership) {
+                LOG.info("Ownership status changed for {} old {} new {}", instanceIdentifier,
+                        this.hasDeviceOwnership, hasDeviceOwnership);
+            }
             this.hasDeviceOwnership = hasDeviceOwnership;
         }
     }
index 7dfd368abc440f5e07065152de682f37d1f64baa..f31554248f1c342ad877ddf143ee57839a7e0a6a 100644 (file)
@@ -17,6 +17,8 @@ import java.util.Map;
 import java.util.Set;
 
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependencyQueue;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependentJob;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.TransactCommand;
@@ -57,6 +59,24 @@ public class HwvtepDeviceInfo {
 
     private static final Logger LOG = LoggerFactory.getLogger(HwvtepDeviceInfo.class);
 
+    private Map<Class<? extends Identifiable>, Map<InstanceIdentifier, Boolean>> availableInOperDs =
+            new ConcurrentHashMap<>();
+
+    public void markAvailableInOperDs(Class<? extends Identifiable> cls, InstanceIdentifier key) {
+        availableInOperDs.putIfAbsent(cls, new ConcurrentHashMap<>());
+        availableInOperDs.get(cls).put(key, Boolean.TRUE);
+    }
+
+    public Boolean isAvailableInOperDs(Class<? extends Identifiable> cls, InstanceIdentifier key) {
+        availableInOperDs.putIfAbsent(cls, new ConcurrentHashMap<>());
+        return availableInOperDs.get(cls).getOrDefault(key, Boolean.FALSE);
+    }
+
+    public Boolean clearOperDsAvailability(Class<? extends Identifiable> cls, InstanceIdentifier key) {
+        availableInOperDs.putIfAbsent(cls, new ConcurrentHashMap<>());
+        return availableInOperDs.get(cls).remove(key);
+    }
+
     public enum DeviceDataStatus {
         IN_TRANSIT,
         UNAVAILABLE,
@@ -104,8 +124,18 @@ public class HwvtepDeviceInfo {
         public boolean isInTransitState() {
             return status == DeviceDataStatus.IN_TRANSIT;
         }
+
+        public boolean isAvailableInOperDs() {
+            return false;
+        }
+
+        @Override
+        public String toString() {
+            return key + " uuid:" + uuid + " data:" + data + " status:" + status;
+        }
     }
 
+    private static AtomicInteger ZERO = new AtomicInteger(0);
     private final Map<InstanceIdentifier<?>, Set<InstanceIdentifier>> tepIdReferences = new ConcurrentHashMap<>();
     private final Map<InstanceIdentifier<LogicalSwitches>, Map<InstanceIdentifier<RemoteUcastMacs>, RemoteUcastMacs>>
             logicalSwitchVsUcasts = new ConcurrentHashMap<>();
@@ -270,6 +300,15 @@ public class HwvtepDeviceInfo {
         }
     }
 
+    public void clearDeviceOperUUID(Class<? extends Identifiable> cls, InstanceIdentifier key, UUID uuid) {
+        LOG.debug("Clearing device data {}", key);
+        if (uuidVsData.containsKey(cls) && uuidVsData.get(cls).containsKey(uuid)) {
+            LOG.debug("Remove {} {} from device data.", connectionInstance.getNodeId().getValue(), cls.getSimpleName());
+        }
+        HwvtepSouthboundUtil.clearData(uuidVsData, cls, uuid);
+        HwvtepSouthboundUtil.clearData(opKeyVsData, cls, key);
+    }
+
     public DeviceData getDeviceOperData(Class<? extends Identifiable> cls, UUID uuid) {
         return HwvtepSouthboundUtil.getData(uuidVsData, cls, uuid);
     }
@@ -442,4 +481,5 @@ public class HwvtepDeviceInfo {
     public Map<Class<? extends Identifiable>, Map<UUID, DeviceData>> getUuidData() {
         return Collections.unmodifiableMap(uuidVsData);
     }
+
 }
index 521bc08aed3e630e61f18230b15c4f74bd158544..c0874fddfc9e97e464421ad0871c40d075f09cd9 100644 (file)
@@ -76,11 +76,11 @@ public class PhysicalPortUpdateCommand extends AbstractTransactCommand {
             LOG.debug("Creating a physical port named: {}", port.getHwvtepNodeName().getValue());
             InstanceIdentifier<TerminationPoint> key = getTpIid(psNodeiid, port.getHwvtepNodeName().getValue());
 
-            getOperationalState().getDeviceInfo().updateConfigData(TerminationPoint.class, key, tp);
-            HwvtepDeviceInfo.DeviceData deviceOperdata = getDeviceInfo().getDeviceOperData(TerminationPoint.class, key);
+            getOperationalState().getDeviceInfo().updateConfigData(VlanBindings.class, key, tp);
+            HwvtepDeviceInfo.DeviceData deviceOperdata = getDeviceInfo().getDeviceOperData(VlanBindings.class, key);
             if (deviceOperdata == null || deviceOperdata.getData() == null) {
                 LOG.error("Updated the device oper cache for port from actual device {}", key);
-                deviceOperdata = super.fetchDeviceData(TerminationPoint.class, key);
+                deviceOperdata = super.fetchDeviceData(VlanBindings.class, key);
             }
             if (deviceOperdata == null || deviceOperdata.getData() == null) {
                 //create a physical port always happens from device
index b7d7131dfc89252b23186d6c5d7f67541a53f488..e73c246e234d8cd62dee084acdac5d54a8e73763 100644 (file)
@@ -8,19 +8,34 @@
 
 package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepDeviceInfo;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ConnectionInfo;
 import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public abstract class AbstractTransactionCommand<T extends DataObject> implements TransactionCommand {
 
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractTransactionCommand.class);
     private final TableUpdates updates;
     private final DatabaseSchema dbSchema;
-    private final HwvtepConnectionInstance key;
+    protected final HwvtepConnectionInstance key;
+    protected Set<Pair<Class<? extends Identifiable>, InstanceIdentifier>> addedKeys = new HashSet<>();
+    protected Set<Pair<Class<? extends Identifiable>, InstanceIdentifier>> deletedKeys = new HashSet<>();
+    protected HwvtepDeviceInfo deviceInfo;
+
 
     public TableUpdates getUpdates() {
         return updates;
@@ -42,6 +57,9 @@ public abstract class AbstractTransactionCommand<T extends DataObject> implement
         this.updates = updates;
         this.dbSchema = dbSchema;
         this.key = key;
+        if (key != null) {
+            this.deviceInfo = key.getDeviceInfo();
+        }
     }
 
     public HwvtepDeviceInfo getDeviceInfo() {
@@ -49,6 +67,44 @@ public abstract class AbstractTransactionCommand<T extends DataObject> implement
     }
 
     void addToDeviceUpdate(TransactionType transactionType, Object element) {
-        key.getDeviceInfo().addToDeviceUpdate(transactionType, element);
+        deviceInfo.addToDeviceUpdate(transactionType, element);
+    }
+
+    public void clearDeviceOpUUID(Class<? extends Identifiable> cls, InstanceIdentifier iid, UUID uuid) {
+        deviceInfo.clearDeviceOperUUID(cls, iid, uuid);
+    }
+
+    public void addToDeleteTx(ReadWriteTransaction tx, Class<? extends Identifiable> cls, InstanceIdentifier iid,
+                              UUID uuid) {
+        if (deviceInfo.isAvailableInOperDs(cls, iid)) {
+            tx.delete(LogicalDatastoreType.OPERATIONAL, iid);
+        }
+        deletedKeys.add(Pair.of(cls, iid));
+        clearDeviceOpUUID(cls, iid, uuid);
+    }
+
+    public void addToUpdateTx(Class<? extends Identifiable> cls, InstanceIdentifier iid, UUID uuid,
+                              Object southboundData) {
+        addedKeys.add(Pair.of(cls, iid));
+        deviceInfo.updateDeviceOperData(cls, iid, uuid, southboundData);
+    }
+
+    public void onSuccess() {
+        addedKeys.stream().forEach(pair -> {
+            deviceInfo.markAvailableInOperDs(pair.getLeft(), pair.getRight());
+        });
+        deletedKeys.stream().forEach(pair -> {
+            deviceInfo.clearOperDsAvailability(pair.getLeft(), pair.getRight());
+            deviceInfo.clearDeviceOperData(pair.getLeft(), pair.getRight());
+        });
+    }
+
+    public void onFailure() {
+        addedKeys.stream().forEach(pair -> {
+            LOG.error("Failed to add {}", pair.getLeft().getSimpleName());
+        });
+        deletedKeys.stream().forEach(pair -> {
+            LOG.error("Failed to delete {}", pair.getLeft().getSimpleName());
+        });
     }
 }
index a2b87a3b63003e7b672139132600f4dc7b06faca..967dc1a5273a5eda3ff1d485f814fbc7868bcfdf 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 
 import java.util.Collection;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
@@ -39,8 +38,7 @@ public class HwvtepLogicalSwitchRemoveCommand extends AbstractTransactionCommand
                     .augmentation(HwvtepGlobalAugmentation.class)
                     .child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName(logicalSwitch.getName())));
             // TODO Delete any references
-            transaction.delete(LogicalDatastoreType.OPERATIONAL, switchIid);
-            getOvsdbConnectionInstance().getDeviceInfo().clearDeviceOperData(LogicalSwitches.class, switchIid);
+            addToDeleteTx(transaction, LogicalSwitches.class, switchIid, logicalSwitch.getUuid());
             addToDeviceUpdate(TransactionType.DELETE, logicalSwitch);
         }
     }
index ed6bee0395f49aec0cf809e9c29f7e2deccb5907..fb275addca25e767dba5729099cf622fc89a4f1b 100644 (file)
@@ -64,8 +64,7 @@ public class HwvtepLogicalSwitchUpdateCommand extends AbstractTransactionCommand
             InstanceIdentifier<LogicalSwitches> switchIid = getOvsdbConnectionInstance().getInstanceIdentifier()
                     .augmentation(HwvtepGlobalAugmentation.class)
                     .child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName(logicalSwitch.getName())));
-            getOvsdbConnectionInstance().getDeviceInfo().updateDeviceOperData(LogicalSwitches.class, switchIid,
-                    logicalSwitch.getUuid(), logicalSwitch);
+            addToUpdateTx(LogicalSwitches.class, switchIid, logicalSwitch.getUuid(), logicalSwitch);
             addToDeviceUpdate(TransactionType.ADD, logicalSwitch);
             // TODO: Delete entries that are no longer needed
         }
index bb5ba8f191a4d5c1431b9625e129be9916059637..0eebf5f151aa3facb6b74e4424f4db3be8bade9b 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 
 import java.util.Collection;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
@@ -66,7 +65,7 @@ public class HwvtepMacEntriesRemoveCommand extends AbstractTransactionCommand {
                     .augmentation(HwvtepGlobalAugmentation.class).child(LocalUcastMacs.class,
                                     new LocalUcastMacsKey(getLogicalSwitchRef(lum.getLogicalSwitchColumn().getData()),
                                                     getMacAddress(lum.getMac())));
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+                addToDeleteTx(transaction, LocalUcastMacs.class, lumId, lum.getUuid());
             } else {
                 LOG.debug("Failed to delete UcastMacLocal entry {}", lum.getUuid());
             }
@@ -83,8 +82,7 @@ public class HwvtepMacEntriesRemoveCommand extends AbstractTransactionCommand {
                     .augmentation(HwvtepGlobalAugmentation.class).child(RemoteUcastMacs.class,
                                     new RemoteUcastMacsKey(getLogicalSwitchRef(rum.getLogicalSwitchColumn().getData()),
                                                     getMacAddress(rum.getMac())));
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, rumId);
-                getOvsdbConnectionInstance().getDeviceInfo().clearDeviceOperData(RemoteUcastMacs.class, rumId);
+                addToDeleteTx(transaction, RemoteUcastMacs.class, rumId, rum.getUuid());
             } else {
                 LOG.debug("Failed to delete UcastMacRemote entry {}", rum.getUuid());
             }
@@ -102,7 +100,7 @@ public class HwvtepMacEntriesRemoveCommand extends AbstractTransactionCommand {
                     .child(LocalMcastMacs.class,
                                     new LocalMcastMacsKey(getLogicalSwitchRef(lmm.getLogicalSwitchColumn().getData()),
                                                     getMacAddress(lmm.getMac())));
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+                addToDeleteTx(transaction, LocalMcastMacs.class, lumId, lmm.getUuid());
             } else {
                 LOG.debug("Failed to delete McastMacLocal entry {}", lmm.getUuid());
             }
@@ -120,7 +118,7 @@ public class HwvtepMacEntriesRemoveCommand extends AbstractTransactionCommand {
                     .child(RemoteMcastMacs.class,
                                     new RemoteMcastMacsKey(getLogicalSwitchRef(rmm.getLogicalSwitchColumn().getData()),
                                                     getMacAddress(rmm.getMac())));
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+                addToDeleteTx(transaction, RemoteMcastMacs.class, lumId, rmm.getUuid());
                 getOvsdbConnectionInstance().getDeviceInfo().clearDeviceOperData(RemoteMcastMacs.class, lumId);
             } else {
                 LOG.debug("Failed to delete McastMacRemote entry {}", rmm.getUuid());
index c7bb3abb16d33b9a00a4b37f2c326a638f33e4ed..cc212b76a4d4eebd06d1e0fe7802a3c0304b9f46 100644 (file)
@@ -101,8 +101,7 @@ public class HwvtepMcastMacsRemoteUpdateCommand extends AbstractTransactionComma
         connectionNode.addAugmentation(HwvtepGlobalAugmentation.class, hgAugmentationBuilder.build());
         InstanceIdentifier<RemoteMcastMacs> macIid = getOvsdbConnectionInstance().getInstanceIdentifier()
                 .augmentation(HwvtepGlobalAugmentation.class).child(RemoteMcastMacs.class, mac.key());
-        getOvsdbConnectionInstance().getDeviceInfo().updateDeviceOperData(RemoteMcastMacs.class,
-                macIid, macRemote.getUuid(), macRemote);
+        addToUpdateTx(RemoteMcastMacs.class, macIid, macRemote.getUuid(), macRemote);
         return connectionNode.build();
     }
 
index 4b59ab9e7d19e93909db8aaca3a961a6e043971b..6fd1636d4a17f7797095ab415d3956e8a551a815 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 
 import java.util.Collection;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
@@ -36,9 +35,7 @@ public class HwvtepPhysicalLocatorRemoveCommand extends AbstractTransactionComma
             final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
             final InstanceIdentifier<TerminationPoint> nodePath = HwvtepSouthboundMapper
                     .createInstanceIdentifier(connectionIId, locator);
-            transaction.delete(LogicalDatastoreType.OPERATIONAL, nodePath);
-            getOvsdbConnectionInstance().getDeviceInfo().clearDeviceOperData(TerminationPoint.class, nodePath);
-
+            addToDeleteTx(transaction, TerminationPoint.class, nodePath, locator.getUuid());
             //TODO: Check if any cleanup is required
         }
     }
index f721d6d9e14fdc504b3eb5dd23d8ad1f8d80852d..701b6a5d78cc7cd782ffef31598200bb017ef4c5 100644 (file)
@@ -79,8 +79,7 @@ public class HwvtepPhysicalLocatorUpdateCommand extends AbstractTransactionComma
                     transaction.put(LogicalDatastoreType.OPERATIONAL,
                             tpPath, tpBuilder.build());
                 }
-                getOvsdbConnectionInstance().getDeviceInfo().updateDeviceOperData(
-                        TerminationPoint.class, tpPath, locator.getUuid(), locator);
+                addToUpdateTx(TerminationPoint.class, tpPath, locator.getUuid(), locator);
             }
         }
     }
index 820ba9fdec9086f7a57defc4ee8050b85320855e..551ffd4e1439b70fc9073c21176f7f63f13d0f35 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 import java.util.Collection;
 import java.util.Map;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
 import org.opendaylight.ovsdb.hwvtepsouthbound.events.PortEvent;
@@ -22,6 +21,7 @@ import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalPort;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
 import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
@@ -67,7 +67,7 @@ public class HwvtepPhysicalPortRemoveCommand extends AbstractTransactionCommand
                         HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(),
                                 updatedPSwitchData).child(TerminationPoint.class,
                                 new TerminationPointKey(new TpId(portName)));
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, nodePath);
+                addToDeleteTx(transaction, VlanBindings.class, nodePath, port.getUuid());
                 addToDeviceUpdate(TransactionType.DELETE,
                         new PortEvent(port, nodePath.firstKeyOf(Node.class).getNodeId()));
                 getDeviceInfo().clearDeviceOperData(TerminationPoint.class, nodePath);
index 119596584e26ac50d3c85406a95c9ac788498f5b..76fa4035ccb58c77ff09da63a59afcd44f4c7190 100644 (file)
@@ -142,8 +142,7 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
                     addToDeviceUpdate(TransactionType.UPDATE, new PortEvent(portUpdate, psNodeId));
                 }
                 reconcileToPort(portUpdate, tpPath);
-                getDeviceInfo().updateDeviceOperData(TerminationPoint.class, tpPath,
-                        portUpdate.getUuid(), portUpdate);
+                addToUpdateTx(VlanBindings.class, tpPath, portUpdate.getUuid(), portUpdate);
                 // Update with Deleted VlanBindings
                 if (oldPPRows.get(portUpdateEntry.getKey()) != null
                         && oldPPRows.get(portUpdateEntry.getKey()).getVlanBindingsColumn() != null) {
@@ -175,21 +174,21 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
             //switch reconciliation will take care of this port along with other ports
             return;
         }
-        if (getDeviceInfo().getDeviceOperData(TerminationPoint.class, tpPath) != null) {
+        if (getDeviceInfo().getDeviceOperData(VlanBindings.class, tpPath) != null) {
             //case of port update not new port add
             return;
 
         }
         //case of individual port add , reconcile to this port
-        getDeviceInfo().updateDeviceOperData(TerminationPoint.class, tpPath, portUpdate.getUuid(), portUpdate);
-        HwvtepDeviceInfo.DeviceData data = getDeviceInfo().getConfigData(TerminationPoint.class, tpPath);
+        addToUpdateTx(VlanBindings.class, tpPath, portUpdate.getUuid(), portUpdate);
+        HwvtepDeviceInfo.DeviceData data = getDeviceInfo().getConfigData(VlanBindings.class, tpPath);
         if (data == null || data.getData() == null) {
             LOG.error("No config data present ");
         } else {
             addToDeviceUpdate(TransactionType.ADD,
                     new ReconcilePortEvent(portUpdate, tpPath.firstKeyOf(Node.class).getNodeId()));
             LOG.info("addToDeviceUpdate {}", portUpdate);
-            getDeviceInfo().updateDeviceOperData(TerminationPoint.class, tpPath,
+            getDeviceInfo().updateDeviceOperData(VlanBindings.class, tpPath,
                     portUpdate.getUuid(), portUpdate);
             getDeviceInfo().scheduleTransaction((transactionBuilder) -> {
                 InstanceIdentifier psIid = tpPath.firstIdentifierOf(Node.class);
index addcd8adf34b0cbb4c5ce4b525941a665ac26405..9c8c8c5f152e7c6c689a6de407f49a2eedbbf1fe 100644 (file)
@@ -108,6 +108,10 @@ public class HwvtepUcastMacsLocalUpdateCommand extends AbstractTransactionComman
                 ucmlBuilder.setLogicalSwitchRef(new HwvtepLogicalSwitchRef(switchIid));
             }
         }
-        return ucmlBuilder.build();
+        LocalUcastMacs ucastMacsLocal = ucmlBuilder.build();
+        InstanceIdentifier iid = key.getInstanceIdentifier().augmentation(HwvtepGlobalAugmentation.class)
+                .child(LocalUcastMacs.class, ucastMacsLocal.key());
+        addToUpdateTx(LocalUcastMacs.class, iid, ucml.getUuid(), ucastMacsLocal);
+        return ucastMacsLocal;
     }
 }
index 98fa5a514d1197d5558ff607f7ef13ebe6d6f63e..7bcdedfe3bfbcfb7e6c66c5856bc9b3c3260ba01 100644 (file)
@@ -108,8 +108,7 @@ public class HwvtepUcastMacsRemoteUpdateCommand extends AbstractTransactionComma
         }
         RemoteUcastMacs remoteUcastMacs = rumBuilder.build();
         InstanceIdentifier<RemoteUcastMacs> macIid = getMacIid(remoteUcastMacs);
-        getOvsdbConnectionInstance().getDeviceInfo().updateDeviceOperData(RemoteUcastMacs.class, macIid,
-                macRemote.getUuid(), macRemote);
+        addToUpdateTx(RemoteUcastMacs.class, macIid, macRemote.getUuid(), macRemote);
         return remoteUcastMacs;
     }
 
index 243a9c85fffa4c3ce3be146e38cf42e2a935c36a..9c2339b9a0316ec3e213183e978d294e26fdf4d4 100644 (file)
@@ -15,6 +15,12 @@ public interface TransactionCommand {
 
     void execute(ReadWriteTransaction transaction);
 
+    default void onSuccess() {
+    }
+
+    default void onFailure() {
+    }
+
     /**
      * Sets the result future of the executed/submitted transaction.
      */