+ LOG.error("Error initializing ovsdb topology", e);
+ }
+ }
+
+ 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);
+ }
+
+ private class SouthboundPluginInstanceEntityOwnershipListener implements EntityOwnershipListener {
+ private SouthboundProvider sp;
+ private EntityOwnershipListenerRegistration listenerRegistration;
+
+ SouthboundPluginInstanceEntityOwnershipListener(SouthboundProvider sp,
+ EntityOwnershipService entityOwnershipService) {
+ this.sp = sp;
+ listenerRegistration = entityOwnershipService.registerListener(ENTITY_TYPE, this);
+ }
+
+ public void close() {
+ this.listenerRegistration.close();
+ }
+ @Override
+ public void ownershipChanged(EntityOwnershipChange ownershipChange) {
+ sp.handleOwnershipChange(ownershipChange);