elected at the clustering level or not. Because of this it can end up in a situation
where candidates are registered but owner is not elected and all the instances
gets false when they check for the owner. This patch fixes the issue, where
it waits till owner is selected
Change-Id: I2c720aeac44e4252091952383fe3bb4ed9bed97b
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
+ public static boolean isMasterElected(){
+ if (entityOwnershipService != null) {
+ Optional<EntityOwnershipState> state = entityOwnershipService.getOwnershipState(ownerInstanceEntity);
+ return state.isPresent() && state.get().hasOwner();
+ }
+ return false;
+ }
+
@Override
public void close() throws Exception {
LOG.info("NetvirtProvider closed");
@Override
public void close() throws Exception {
LOG.info("NetvirtProvider closed");
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.ovsdb.openstack.netvirt.ClusterAwareMdsalUtils;
import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.ovsdb.openstack.netvirt.ClusterAwareMdsalUtils;
import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.NetvirtProvider;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryService;
import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryListener;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryService;
import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryListener;
public void setDependencies(Object impl) {}
private void initializeNetvirtTopology() {
public void setDependencies(Object impl) {}
private void initializeNetvirtTopology() {
+ while(!NetvirtProvider.isMasterElected()){
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ LOG.warn("Netvirt thread waiting on Netvirt Ownership Election is interrupted");
+ }
+ }
final TopologyId topologyId = new TopologyId(new Uri(Constants.NETVIRT_TOPOLOGY_ID));
InstanceIdentifier<Topology> path =
InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
final TopologyId topologyId = new TopologyId(new Uri(Constants.NETVIRT_TOPOLOGY_ID));
InstanceIdentifier<Topology> path =
InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));