public void handleOwnershipChange(EntityOwnershipChange ownershipChange) { if (ownershipChange.isOwner()) { LOG.info("*This* instance of OVSDB southbound provider is set as a MASTER instance"); LOG.info("Initialize OVSDB topology {} in operational and config data store if not already present", SouthboundConstants.OVSDB_TOPOLOGY_ID); initializeOvsdbTopology(LogicalDatastoreType.OPERATIONAL); initializeOvsdbTopology(LogicalDatastoreType.CONFIGURATION); } else { LOG.info("*This* instance of OVSDB southbound provider is set as a SLAVE instance"); } ovsdbConnection.registerConnectionListener(cm); ovsdbConnection.startOvsdbManager(SouthboundConstants.DEFAULT_OVSDB_PORT); }
/** * Used by blueprint when starting the container. */ public void init() { LOG.info("SouthboundProvider Session Initiated"); this.txInvoker = new TransactionInvokerImpl(db); cm = new OvsdbConnectionManager(db,txInvoker,entityOwnershipService, ovsdbConnection); ovsdbDataTreeChangeListener = new OvsdbDataTreeChangeListener(db, cm); //Register listener for entityOnwership changes providerOwnershipChangeListener = new SouthboundPluginInstanceEntityOwnershipListener(this,this.entityOwnershipService); //register instance entity to get the ownership of the provider Entity instanceEntity = new Entity(ENTITY_TYPE, ENTITY_TYPE); try { Optional<EntityOwnershipState> ownershipStateOpt = entityOwnershipService.getOwnershipState(instanceEntity); registration = entityOwnershipService.registerCandidate(instanceEntity); if (ownershipStateOpt.isPresent()) { EntityOwnershipState ownershipState = ownershipStateOpt.get(); if (ownershipState.hasOwner() && !ownershipState.isOwner()) { ovsdbConnection.registerConnectionListener(cm); ovsdbConnection.startOvsdbManager(SouthboundConstants.DEFAULT_OVSDB_PORT); LOG.info("*This* instance of OVSDB southbound provider is set as a SLAVE instance"); } } } catch (CandidateAlreadyRegisteredException e) { LOG.warn("OVSDB Southbound Provider instance entity {} was already " + "registered for ownership", instanceEntity, e); } }