Use seperate txn when quering multiple shards 20/86820/5
authorChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Thu, 9 Jan 2020 09:05:20 +0000 (14:35 +0530)
committerStephen Kitt <skitt@redhat.com>
Thu, 9 Jan 2020 18:04:09 +0000 (18:04 +0000)
Description:
The txn which been used for updating oper topo been also used to query
config topo. Changes done to use a new transaction while querying
different shards.

Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Change-Id: I90befb242c47df2bcbdcb09b92708c20a97e78c0
Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Signed-off-by: xcheara <chetan.arakere@altencalsoftlabs.com>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalPortUpdateCommand.java

index df6240737dd62dc770a0ca279c6ad8400ffda405..73ce80bbabd53497ca50c6d91ca9b0f461e709f6 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalPort;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
+import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
 import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
@@ -70,6 +71,7 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
     private final Map<UUID, PhysicalPort> oldPPRows;
     private final Map<UUID, PhysicalSwitch> switchUpdatedRows;
     private final Set<UUID> skipReconciliationPorts;
+    private final ControllerMdsalUtils mdsalUtils;
 
     public HwvtepPhysicalPortUpdateCommand(final HwvtepConnectionInstance key, final TableUpdates updates,
             final DatabaseSchema dbSchema) {
@@ -78,6 +80,7 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
         oldPPRows = TyperUtils.extractRowsOld(PhysicalPort.class, getUpdates(), getDbSchema());
         switchUpdatedRows = TyperUtils.extractRowsUpdated(PhysicalSwitch.class, getUpdates(), getDbSchema());
         skipReconciliationPorts = new HashSet<>();
+        mdsalUtils = new ControllerMdsalUtils(key.getDataBroker());
         for (Entry<UUID, PhysicalPort> portUpdateEntry : updatedPPRows.entrySet()) {
             Optional<InstanceIdentifier<Node>> switchIid = getTerminationPointSwitch(portUpdateEntry.getKey());
             if (switchIid.isPresent()) {
@@ -140,7 +143,7 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
                 } else {
                     addToDeviceUpdate(TransactionType.UPDATE, new PortEvent(portUpdate, psNodeId));
                 }
-                reconcileToPort(transaction, portUpdate, tpPath);
+                reconcileToPort(portUpdate, tpPath);
                 getDeviceInfo().updateDeviceOperData(TerminationPoint.class, tpPath,
                         portUpdate.getUuid(), portUpdate);
                 // Update with Deleted VlanBindings
@@ -167,8 +170,7 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
         }
     }
 
-    private void reconcileToPort(final ReadWriteTransaction transaction,
-                                 final PhysicalPort portUpdate,
+    private void reconcileToPort(final PhysicalPort portUpdate,
                                  final InstanceIdentifier<TerminationPoint> tpPath) {
         if (skipReconciliationPorts.contains(portUpdate.getUuid())) {
             //case of port added along with switch add
@@ -181,7 +183,7 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
         }
         //case of individual port add , reconcile to this port
         getDeviceInfo().updateDeviceOperData(TerminationPoint.class, tpPath, portUpdate.getUuid(), portUpdate);
-        Futures.addCallback(transaction.read(LogicalDatastoreType.CONFIGURATION, tpPath),
+        Futures.addCallback(mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, tpPath),
                 new FutureCallback<Optional<TerminationPoint>>() {
                     @Override
                     public void onSuccess(final Optional<TerminationPoint> optionalConfigTp) {