import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactCommand;
import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactInvoker;
import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactInvokerImpl;
+import org.opendaylight.ovsdb.southbound.transactions.md.OvsdbNodeCreateCommand;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
import org.slf4j.Logger;
private TransactionInvoker txInvoker;
private Map<DatabaseSchema,TransactInvoker> transactInvokers = new HashMap<DatabaseSchema,TransactInvoker>();
private MonitorCallBack callback;
+ private ConnectionInfo key;
OvsdbConnectionInstance(ConnectionInfo key,OvsdbClient client,TransactionInvoker txInvoker) {
this.connectionInfo = key;
this.client = client;
this.txInvoker = txInvoker;
- registerCallBack();
+ this.key = key;
}
public void transact(TransactCommand command) {
}
}
- private void registerCallBack() {
- this.callback = new OvsdbMonitorCallback(connectionInfo,txInvoker);
- try {
- List<String> databases = getDatabases().get();
- if (databases != null) {
- for (String database : databases) {
- DatabaseSchema dbSchema = getSchema(database).get();
- if (dbSchema != null) {
- transactInvokers.put(dbSchema, new TransactInvokerImpl(this,dbSchema));
- monitorAllTables(database, dbSchema);
- } else {
- LOG.warn("No schema reported for database {} for key {}",database,connectionInfo);
+ public void init() {
+ if ( this.callback == null) {
+ txInvoker.invoke(new OvsdbNodeCreateCommand(key, null,null));
+ this.callback = new OvsdbMonitorCallback(connectionInfo,txInvoker);
+ try {
+ List<String> databases = getDatabases().get();
+ if (databases != null) {
+ for (String database : databases) {
+ DatabaseSchema dbSchema = getSchema(database).get();
+ if (dbSchema != null) {
+ transactInvokers.put(dbSchema, new TransactInvokerImpl(this,dbSchema));
+ monitorAllTables(database, dbSchema);
+ } else {
+ LOG.warn("No schema reported for database {} for key {}",database,connectionInfo);
+ }
}
+ } else {
+ LOG.warn("No databases reported from {}",connectionInfo);
}
- } else {
- LOG.warn("No databases reported from {}",connectionInfo);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.warn("Exception attempting to initialize {}: {}",connectionInfo,e);
}
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("Exception attempting to initialize {}: {}",connectionInfo,e);
}
}
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
-import org.opendaylight.ovsdb.southbound.transactions.md.OvsdbNodeCreateCommand;
import org.opendaylight.ovsdb.southbound.transactions.md.OvsdbNodeRemoveCommand;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAttributes;
ConnectionInfo key = SouthboundMapper.createConnectionInfo(externalClient);
OvsdbConnectionInstance client = new OvsdbConnectionInstance(key,externalClient,txInvoker);
putConnectionInstance(key, client);
- txInvoker.invoke(new OvsdbNodeCreateCommand(key, null,null));
+ client.init();
}
@Override