bug 8257 handling back to back mcast mac updates 16/55116/8
authorK.V Suneelu Verma <k.v.suneelu.verma@ericsson.com>
Mon, 17 Apr 2017 11:25:13 +0000 (16:55 +0530)
committerAnil Vishnoi <vishnoianil@gmail.com>
Fri, 19 May 2017 08:05:08 +0000 (08:05 +0000)
Making the remove mcast mac participate in depenency resolution
flow.

Put the delete event on hold while the previous add/update on
the same key is still in transit.

Delete mcast mac event resumes after we receive the
 response for the previous create.

Mark the state of the mcast mac key in transit while we execute its delete/add/update.

Change-Id: I0b15d82dad346bd2c35c0368b4d7f63dc3bfa09d
Signed-off-by: K.V Suneelu Verma <k.v.suneelu.verma@ericsson.com>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/AbstractTransactCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteRemoveCommand.java

index 2688a20003946007766fa51ac13d13cf7684318d..32c07889ffeb4d18493e1501ba85c10399745b1d 100644 (file)
@@ -62,21 +62,25 @@ public abstract class AbstractTransactCommand<T extends Identifiable, Aug extend
 
     void updateCurrentTxData(Class<? extends Identifiable> cls, InstanceIdentifier key, UUID uuid, Object data) {
         operationalState.updateCurrentTxData(cls, key, uuid);
-        operationalState.getDeviceInfo().markKeyAsInTransit(cls, key);
         operationalState.getDeviceInfo().updateConfigData(cls, key, data);
     }
 
-    void processDependencies(UnMetDependencyGetter<T> unMetDependencyGetter,
-                             TransactionBuilder transaction,
+    void processDependencies(final UnMetDependencyGetter<T> unMetDependencyGetter,
+                             final TransactionBuilder transaction,
                              final InstanceIdentifier<Node> nodeIid,
                              final InstanceIdentifier key,
                              final T data, final Object... extraData) {
 
         HwvtepDeviceInfo deviceInfo = operationalState.getDeviceInfo();
-        Map inTransitDependencies = unMetDependencyGetter.getInTransitDependencies(operationalState, data);
-        Map confingDependencies = unMetDependencyGetter.getUnMetConfigDependencies(operationalState, data);
-        //we can skip the config termination point dependency as we can create them in device as part of this tx
-        confingDependencies.remove(TerminationPoint.class);
+        Map inTransitDependencies = Collections.EMPTY_MAP;
+        Map confingDependencies = Collections.EMPTY_MAP;
+
+        if (!isRemoveCommand() && unMetDependencyGetter != null) {
+            inTransitDependencies = unMetDependencyGetter.getInTransitDependencies(operationalState, data);
+            confingDependencies = unMetDependencyGetter.getUnMetConfigDependencies(operationalState, data);
+            //we can skip the config termination point dependency as we can create them in device as part of this tx
+            confingDependencies.remove(TerminationPoint.class);
+        }
 
         Type type = getClass().getGenericSuperclass();
         Type classType = ((ParameterizedType)type).getActualTypeArguments()[0];
@@ -88,7 +92,6 @@ public abstract class AbstractTransactCommand<T extends Identifiable, Aug extend
 
         if (HwvtepSouthboundUtil.isEmptyMap(confingDependencies) && HwvtepSouthboundUtil.isEmptyMap(inTransitDependencies)) {
             doDeviceTransaction(transaction, nodeIid, data, key, extraData);
-            //TODO put proper uuid
             updateCurrentTxData((Class<? extends Identifiable>) classType, key, new UUID("uuid"), data);
         }
         if (!HwvtepSouthboundUtil.isEmptyMap(confingDependencies)) {
@@ -299,4 +302,8 @@ public abstract class AbstractTransactCommand<T extends Identifiable, Aug extend
     protected boolean cascadeDelete() {
         return false;
     }
+
+    protected boolean isRemoveCommand() {
+        return false;
+    }
 }
index 0dadf6792b23253cc68b6ca9ab5b0693276dbf3f..48abea1481e8157e664bf50affad6fe50afcf0cb 100644 (file)
@@ -104,4 +104,9 @@ public class LogicalSwitchRemoveCommand extends AbstractTransactCommand<LogicalS
     protected boolean areEqual(LogicalSwitches a , LogicalSwitches b) {
         return a.getKey().equals(b.getKey()) && Objects.equals(a.getTunnelKey(), b.getTunnelKey());
     }
+
+    @Override
+    protected boolean isRemoveCommand() {
+        return true;
+    }
 }
index fc10a3b5644fb978419efe63b86022cc31b3a6d4..63e1603cd52b23cbcdd7b75a06970a2e19e5727a 100644 (file)
@@ -100,4 +100,9 @@ public class McastMacsLocalRemoveCommand extends AbstractTransactCommand<LocalMc
             return Collections.emptyList();
         }
     }
+
+    @Override
+    protected boolean isRemoveCommand() {
+        return true;
+    }
 }
index 95814f61741b47e38f66e8ab69e13c0ac780281b..8aeff6a790b651d2030bd450c73c172d9bc0cb19 100644 (file)
@@ -70,9 +70,30 @@ public class McastMacsRemoteRemoveCommand extends AbstractTransactCommand<Remote
         }
     }
 
-    private void removeMcastMacRemote(TransactionBuilder transaction,
-            InstanceIdentifier<Node> instanceIdentifier, List<RemoteMcastMacs> macList) {
-        for (RemoteMcastMacs mac: macList) {
+    private void removeMcastMacRemote(final TransactionBuilder transaction,
+                                      final InstanceIdentifier<Node> nodeIid, final List<RemoteMcastMacs> macList) {
+        for (RemoteMcastMacs mac : macList) {
+            InstanceIdentifier<RemoteMcastMacs> macKey = nodeIid.augmentation(HwvtepGlobalAugmentation.class).
+                    child(RemoteMcastMacs.class, mac.getKey());
+            onConfigUpdate(transaction, nodeIid, mac, macKey);
+        }
+    }
+
+    @Override
+    public void onConfigUpdate(final TransactionBuilder transaction,
+                               final InstanceIdentifier<Node> nodeIid,
+                               final RemoteMcastMacs remoteMcastMac,
+                               final InstanceIdentifier macKey,
+                               final Object... extraData) {
+        processDependencies(null, transaction, nodeIid, macKey, remoteMcastMac);
+    }
+
+    @Override
+    public void doDeviceTransaction(final TransactionBuilder transaction,
+                                    final InstanceIdentifier<Node> instanceIdentifier,
+                                    final RemoteMcastMacs mac,
+                                    final InstanceIdentifier macIid,
+                                    final Object... extraData) {
             LOG.debug("Removing remoteMcastMacs, mac address: {}", mac.getMacEntryKey().getValue());
             Optional<RemoteMcastMacs> operationalMacOptional =
                     getOperationalState().getRemoteMcastMacs(instanceIdentifier, mac.getKey());
@@ -86,14 +107,12 @@ public class McastMacsRemoteRemoveCommand extends AbstractTransactCommand<Remote
                 transaction.add(op.delete(mcastMacsRemote.getSchema()).
                         where(mcastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
                 transaction.add(op.comment("McastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
+                getOperationalState().getDeviceInfo().markKeyAsInTransit(RemoteMcastMacs.class, macIid);
             } else {
                 LOG.warn("Unable to delete remoteMcastMacs {} because it was not found in the operational store",
                         mac.getMacEntryKey().getValue());
             }
-            InstanceIdentifier<RemoteMcastMacs> macIid = instanceIdentifier.augmentation(HwvtepGlobalAugmentation.class).
-                    child(RemoteMcastMacs.class, mac.getKey());
             updateCurrentTxDeleteData(RemoteMcastMacs.class, macIid, mac);
-        }
     }
 
     @Override
@@ -105,4 +124,9 @@ public class McastMacsRemoteRemoveCommand extends AbstractTransactCommand<Remote
     protected boolean areEqual(RemoteMcastMacs a, RemoteMcastMacs b) {
         return a.getKey().equals(b.getKey()) && Objects.equals(a.getLocatorSet(), b.getLocatorSet());
     }
+
+    @Override
+    protected boolean isRemoveCommand() {
+        return true;
+    }
 }
index 4f986e0cb1c58715c18f5958851fef2999ac0778..6d6538faca9cbce7a4371c903f054c8c7785cde7 100644 (file)
@@ -97,6 +97,7 @@ public class McastMacsRemoteUpdateCommand extends AbstractTransactCommand<Remote
                 LOG.trace("execute: create RemoteMcastMac entry: {}", mcastMacsRemote);
                 transaction.add(op.insert(mcastMacsRemote));
                 transaction.add(op.comment("McastMacRemote: Creating " + mac.getMacEntryKey().getValue()));
+                getOperationalState().getDeviceInfo().markKeyAsInTransit(RemoteMcastMacs.class, macKey);
             } else if (operationalMacOptional.get().getMacEntryUuid() != null) {
                 UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
                 McastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
index 557040049bffbcdcd605c0caceae7a0ae763128d..918c28dd6320a251ac127b5c445702fb9d363414 100644 (file)
@@ -101,4 +101,9 @@ public class UcastMacsLocalRemoveCommand extends AbstractTransactCommand<LocalUc
             return Collections.emptyList();
         }
     }
+
+    @Override
+    protected boolean isRemoveCommand() {
+        return true;
+    }
 }
\ No newline at end of file
index c757f6abbde614237037d16ea1fd88e6624eb86b..7f068b4279445b26412e68254b283bb65537bfd7 100644 (file)
@@ -78,4 +78,8 @@ public class UcastMacsRemoteRemoveCommand extends AbstractTransactCommand<Remote
         return augmentation.getRemoteUcastMacs();
     }
 
+    @Override
+    protected boolean isRemoveCommand() {
+        return true;
+    }
 }