Upgrade support for hwvtep reconciliation 33/88533/2
authorChandra Shekar S <chandra.shekar.s@ericsson.com>
Wed, 18 Mar 2020 10:00:54 +0000 (15:30 +0530)
committerChandra Shekar S <chandra.shekar.s@ericsson.com>
Mon, 23 Mar 2020 09:23:07 +0000 (14:53 +0530)
Signed-off-by: Chandra Shekar S <chandra.shekar.s@ericsson.com>
Change-Id: I5ed959004ced1c4a4b22aea67ab11d3aab291daf

hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/reconciliation/configuration/HwvtepReconciliationManager.java

index 17eb2a5fa944e83fcc8873e8affd8650517d2eb3..8edeeab8e9a5ef67c1d435f7a1722e7fe0087e16 100644 (file)
@@ -83,6 +83,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>javax.annotation-api</artifactId>
       <optional>true</optional>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.serviceutils</groupId>
+      <artifactId>upgrade</artifactId>
+      <version>0.5.0-SNAPSHOT</version>
+    </dependency>
     <!-- Testing Dependencies -->
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 34b44c1f08b4c7e7d93ca425d381bde4a6d6f7de..3330c8e997949c6bb27e73958a5bedfe626a1eb8 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Collection;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -38,7 +39,9 @@ import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.configuration.Hwvt
 import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvoker;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvokerImpl;
 import org.opendaylight.ovsdb.lib.OvsdbConnection;
+import org.opendaylight.ovsdb.utils.mdsal.utils.Scheduler;
 import org.opendaylight.ovsdb.utils.mdsal.utils.ShardStatusMonitor;
+import org.opendaylight.serviceutils.upgrade.UpgradeState;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder;
@@ -68,17 +71,20 @@ public class HwvtepSouthboundProvider implements ClusteredDataTreeChangeListener
     private final AtomicBoolean registered = new AtomicBoolean(false);
     private ListenerRegistration<HwvtepSouthboundProvider> operTopologyRegistration;
     private int shardStatusCheckRetryCount = 1000;
+    private UpgradeState upgradeState;
 
     @Inject
     public HwvtepSouthboundProvider(@Reference final DataBroker dataBroker,
             @Reference final EntityOwnershipService entityOwnershipServiceDependency,
             @Reference final OvsdbConnection ovsdbConnection,
             @Reference final DOMSchemaService schemaService,
-            @Reference final BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer) {
+            @Reference final BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer,
+            @Reference final UpgradeState upgradeState) {
         this.dataBroker = dataBroker;
         this.entityOwnershipService = entityOwnershipServiceDependency;
         registration = null;
         this.ovsdbConnection = ovsdbConnection;
+        this.upgradeState = upgradeState;
         HwvtepSouthboundUtil.setInstanceIdentifierCodec(new InstanceIdentifierCodec(schemaService,
                 bindingNormalizedNodeSerializer));
         LOG.info("HwvtepSouthboundProvider ovsdbConnectionService: {}", ovsdbConnection);
@@ -113,8 +119,7 @@ public class HwvtepSouthboundProvider implements ClusteredDataTreeChangeListener
         LOG.info("HwvtepSouthboundProvider Session Initiated");
         txInvoker = new TransactionInvokerImpl(dataBroker);
         cm = new HwvtepConnectionManager(dataBroker, txInvoker, entityOwnershipService, ovsdbConnection);
-        hwvtepDTListener = new HwvtepDataChangeListener(dataBroker, cm);
-        hwvtepReconciliationManager = new HwvtepReconciliationManager(dataBroker, cm);
+        registerConfigListenerPostUpgrade();
         //Register listener for entityOnwership changes
         providerOwnershipChangeListener =
                 new HwvtepsbPluginInstanceEntityOwnershipListener(this,this.entityOwnershipService);
@@ -137,6 +142,17 @@ public class HwvtepSouthboundProvider implements ClusteredDataTreeChangeListener
         operTopologyRegistration = dataBroker.registerDataTreeChangeListener(treeId, this);
     }
 
+    private void registerConfigListenerPostUpgrade() {
+        if (upgradeState.isUpgradeInProgress()) {
+            LOG.error("Upgrade is in progress delay config data change listener registration");
+            Scheduler.getScheduledExecutorService().schedule(() -> registerConfigListenerPostUpgrade(),
+                    60, TimeUnit.SECONDS);
+            return;
+        }
+        hwvtepDTListener = new HwvtepDataChangeListener(dataBroker, cm);
+        hwvtepReconciliationManager = new HwvtepReconciliationManager(dataBroker, cm);
+    }
+
     @Override
     @PreDestroy
     @SuppressWarnings("checkstyle:IllegalCatch")
index ed95d7ae8aa7bb8d8e5bbd7b1ddfdd342a3cdb49..7bc2ccd2a19d16c8e9e5115001d028844ca6d085 100644 (file)
@@ -78,7 +78,7 @@ public class HwvtepReconciliationManager implements ClusteredDataTreeChangeListe
                     HwvtepConnectionInstance connection =
                             hcm.getConnectionInstance(physicalSwitch);
                     if (connection != null) {
-                        LOG.trace("Reconcile config for node {}, IP : {}", node.key(),
+                        LOG.info("HwvtepReconciliationManager Reconcile config for node {}, IP : {}", node.key(),
                                 connection.getConnectionInfo().getRemoteAddress());
                         hcm.reconcileConfigurations(connection, node);
                     }