import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
-import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvokerImpl;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
public SouthboundProvider(
- EntityOwnershipService entityOwnershipServiceDependency) {
+ EntityOwnershipService entityOwnershipServiceDependency,
+ OvsdbConnection ovsdbConnection) {
this.entityOwnershipService = entityOwnershipServiceDependency;
registration = null;
+ this.ovsdbConnection = ovsdbConnection;
+ LOG.info("SouthboundProvider ovsdbConnectionService: {}", ovsdbConnection);
}
@Override
LOG.info("SouthboundProvider Session Initiated");
db = session.getSALService(DataBroker.class);
this.txInvoker = new TransactionInvokerImpl(db);
- cm = new OvsdbConnectionManager(db,txInvoker,entityOwnershipService);
+ cm = new OvsdbConnectionManager(db,txInvoker,entityOwnershipService, ovsdbConnection);
ovsdbDataChangeListener = new OvsdbDataChangeListener(db,cm);
//Register listener for entityOnwership changes
if (ownershipStateOpt.isPresent()) {
EntityOwnershipState ownershipState = ownershipStateOpt.get();
if (ownershipState.hasOwner() && !ownershipState.isOwner()) {
- if (ovsdbConnection == null) {
- ovsdbConnection = new OvsdbConnectionService();
- ovsdbConnection.registerConnectionListener(cm);
- ovsdbConnection.startOvsdbManager(SouthboundConstants.DEFAULT_OVSDB_PORT);
- }
+ 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);
+ + "registered for ownership", instanceEntity, e);
}
}
@Override
- public void close() throws Exception {
+ public void close() {
LOG.info("SouthboundProvider Closed");
cm.close();
ovsdbDataChangeListener.close();
transaction.cancel();
}
} catch (Exception e) {
- LOG.error("Error initializing ovsdb topology {}",e);
+ LOG.error("Error initializing ovsdb topology", e);
}
}
} else {
LOG.info("*This* instance of OVSDB southbound provider is set as a SLAVE instance");
}
- if (ovsdbConnection == null) {
- ovsdbConnection = new OvsdbConnectionService();
- ovsdbConnection.registerConnectionListener(cm);
- ovsdbConnection.startOvsdbManager(SouthboundConstants.DEFAULT_OVSDB_PORT);
- }
+ ovsdbConnection.registerConnectionListener(cm);
+ ovsdbConnection.startOvsdbManager(SouthboundConstants.DEFAULT_OVSDB_PORT);
}
private class SouthboundPluginInstanceEntityOwnershipListener implements EntityOwnershipListener {