Get rid of useless (Hwvtep)SouthboundProvider thread
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / HwvtepSouthboundProvider.java
index b8dd802751359b84fd2a57e36a7a4f3547358404..322fa4eb86ed988ba2a81ab82a2d790ed0a1e9a3 100644 (file)
@@ -149,7 +149,7 @@ public class HwvtepSouthboundProvider implements ClusteredDataTreeChangeListener
         }
     }
 
-    private void initializeHwvtepTopology(LogicalDatastoreType type) {
+    private void initializeHwvtepTopology(final LogicalDatastoreType type) {
         InstanceIdentifier<Topology> path = InstanceIdentifier
                 .create(NetworkTopology.class)
                 .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID));
@@ -169,7 +169,7 @@ public class HwvtepSouthboundProvider implements ClusteredDataTreeChangeListener
         }
     }
 
-    public void handleOwnershipChange(EntityOwnershipChange ownershipChange) {
+    public void handleOwnershipChange(final EntityOwnershipChange ownershipChange) {
         if (ownershipChange.getState().isOwner()) {
             LOG.info("*This* instance of HWVTEP southbound provider is set as a MASTER instance");
             LOG.info("Initialize HWVTEP topology {} in operational and config data store if not already present",
@@ -183,27 +183,25 @@ public class HwvtepSouthboundProvider implements ClusteredDataTreeChangeListener
 
 
     @Override
-    public void onDataTreeChanged(Collection<DataTreeModification<Topology>> collection) {
+    public void onDataTreeChanged(final Collection<DataTreeModification<Topology>> collection) {
         if (!registered.getAndSet(true)) {
             LOG.info("Starting the ovsdb port");
             ovsdbConnection.registerConnectionListener(cm);
             ovsdbConnection.startOvsdbManager();
         }
-        //mdsal registration/deregistration in mdsal update callback should be avoided
-        new Thread(() -> {
-            if (operTopologyRegistration != null) {
-                operTopologyRegistration.close();
-                operTopologyRegistration = null;
-            }
-        }).start();
+
+        if (operTopologyRegistration != null) {
+            operTopologyRegistration.close();
+            operTopologyRegistration = null;
+        }
     }
 
     private static class HwvtepsbPluginInstanceEntityOwnershipListener implements EntityOwnershipListener {
         private final HwvtepSouthboundProvider hsp;
         private final EntityOwnershipListenerRegistration listenerRegistration;
 
-        HwvtepsbPluginInstanceEntityOwnershipListener(HwvtepSouthboundProvider hsp,
-                EntityOwnershipService entityOwnershipService) {
+        HwvtepsbPluginInstanceEntityOwnershipListener(final HwvtepSouthboundProvider hsp,
+                final EntityOwnershipService entityOwnershipService) {
             this.hsp = hsp;
             listenerRegistration = entityOwnershipService.registerListener(ENTITY_TYPE, this);
         }
@@ -213,7 +211,7 @@ public class HwvtepSouthboundProvider implements ClusteredDataTreeChangeListener
         }
 
         @Override
-        public void ownershipChanged(EntityOwnershipChange ownershipChange) {
+        public void ownershipChanged(final EntityOwnershipChange ownershipChange) {
             hsp.handleOwnershipChange(ownershipChange);
         }
     }