From 0672bb222a0d12bc8b49ea53e5d2d269b488f203 Mon Sep 17 00:00:00 2001 From: "K.V Suneelu Verma" Date: Tue, 13 Jun 2017 18:49:39 +0530 Subject: [PATCH] bug 8673 physical switch node is not removed When the node gets disconnected , its global node alone is getting removed sometimes. reuse GlobalNodeRemove command which cleans global aswell as physical switch node. Change-Id: Ic89fb1b0606bb1d42242c860ea2f7d9fa1e2b37d Signed-off-by: K.V Suneelu Verma --- .../hwvtepsouthbound/HwvtepConnectionManager.java | 9 +-------- .../transactions/md/HwvtepGlobalRemoveCommand.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java index 8312526e3..cd0c9c45b 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java @@ -496,12 +496,6 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo // might went down abruptly and didn't get a chance to clean up the operational data store. if (!ownershipChange.hasOwner()) { LOG.debug("{} has no owner, cleaning up the operational data store", ownershipChange.getEntity()); - // Below code might look weird but it's required. We want to give first opportunity to the - // previous owner of the device to clean up the operational data store if there is no owner now. - // That way we will avoid lot of nasty md-sal exceptions because of concurrent delete. - if (ownershipChange.wasOwner()) { - cleanEntityOperationalData(ownershipChange.getEntity()); - } // If first cleanEntityOperationalData() was called, this call will be no-op. cleanEntityOperationalData(ownershipChange.getEntity()); } @@ -543,8 +537,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo @SuppressWarnings("unchecked") final InstanceIdentifier nodeIid = (InstanceIdentifier) HwvtepSouthboundUtil .getInstanceIdentifierCodec().bindingDeserializer(entity.getId()); - - txInvoker.invoke(transaction -> transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid)); + txInvoker.invoke(new HwvtepGlobalRemoveCommand(nodeIid)); } private HwvtepConnectionInstance getConnectionInstanceFromEntity(Entity entity) { diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepGlobalRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepGlobalRemoveCommand.java index 8ee891746..74ef97d91 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepGlobalRemoveCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepGlobalRemoveCommand.java @@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hw import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,15 +29,22 @@ public class HwvtepGlobalRemoveCommand extends AbstractTransactionCommand { private static final Logger LOG = LoggerFactory.getLogger(HwvtepGlobalRemoveCommand.class); private static final long ONE_CONNECTED_MANAGER = 1; private static final long ONE_ACTIVE_CONNECTION_IN_PASSIVE_MODE = 1; + private final InstanceIdentifier nodeInstanceIdentifier; public HwvtepGlobalRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) { super(key, updates, dbSchema); + this.nodeInstanceIdentifier = key.getInstanceIdentifier(); + } + + public HwvtepGlobalRemoveCommand(InstanceIdentifier nodeInstanceIdentifier) { + super(null, null, null); + this.nodeInstanceIdentifier = nodeInstanceIdentifier; } @Override public void execute(ReadWriteTransaction transaction) { CheckedFuture, ReadFailedException> hwvtepGlobalFuture = transaction.read( - LogicalDatastoreType.OPERATIONAL, getOvsdbConnectionInstance().getInstanceIdentifier()); + LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier); try { Optional hwvtepGlobalOptional = hwvtepGlobalFuture.get(); if (hwvtepGlobalOptional.isPresent()) { @@ -56,8 +64,7 @@ public class HwvtepGlobalRemoveCommand extends AbstractTransactionCommand { } else { LOG.warn("{} had no HwvtepGlobalAugmentation", hwvtepNode.getNodeId().getValue()); } - transaction.delete(LogicalDatastoreType.OPERATIONAL, - getOvsdbConnectionInstance().getInstanceIdentifier()); + transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier); } else { LOG.debug("Other southbound plugin instances in cluster are connected to the device," + " not deleting OvsdbNode form data store."); -- 2.36.6