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); }
/** * Function called by dependency manager after "init ()" is called and after * the services provided by the class are registered in the service registry */ void start() { /* Start ovsdb server before getting connection clients */ String portString = ConfigProperties.getProperty(OvsdbConnectionService.class, OVSDB_LISTENPORT); int ovsdbListenPort = DEFAULT_OVSDB_PORT; if (portString != null) { ovsdbListenPort = Integer.decode(portString).intValue(); } if (!connectionLib.startOvsdbManager(ovsdbListenPort)) { logger.warn("Start OVSDB manager call from ConnectionService was not necessary"); } /* Then get connection clients */ Collection<OvsdbClient> connections = connectionLib.getConnections(); for (OvsdbClient client : connections) { logger.info("CONNECT start connected clients client = {}", client); this.connected(client); } }
/** * 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); } }