// 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());
}
@SuppressWarnings("unchecked") final InstanceIdentifier<Node> nodeIid =
(InstanceIdentifier<Node>) HwvtepSouthboundUtil
.getInstanceIdentifierCodec().bindingDeserializer(entity.getId());
-
- txInvoker.invoke(transaction -> transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid));
+ txInvoker.invoke(new HwvtepGlobalRemoveCommand(nodeIid));
}
private HwvtepConnectionInstance getConnectionInstanceFromEntity(Entity entity) {
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;
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<Node> nodeInstanceIdentifier;
public HwvtepGlobalRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
super(key, updates, dbSchema);
+ this.nodeInstanceIdentifier = key.getInstanceIdentifier();
+ }
+
+ public HwvtepGlobalRemoveCommand(InstanceIdentifier<Node> nodeInstanceIdentifier) {
+ super(null, null, null);
+ this.nodeInstanceIdentifier = nodeInstanceIdentifier;
}
@Override
public void execute(ReadWriteTransaction transaction) {
CheckedFuture<Optional<Node>, ReadFailedException> hwvtepGlobalFuture = transaction.read(
- LogicalDatastoreType.OPERATIONAL, getOvsdbConnectionInstance().getInstanceIdentifier());
+ LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier);
try {
Optional<Node> hwvtepGlobalOptional = hwvtepGlobalFuture.get();
if (hwvtepGlobalOptional.isPresent()) {
} 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.");