import java.util.Set;
import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.ovsdb.lib.EchoServiceCallbackFilters;
import org.opendaylight.ovsdb.lib.LockAquisitionCallback;
import org.opendaylight.ovsdb.lib.LockStolenCallback;
import org.opendaylight.ovsdb.lib.schema.TableSchema;
import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactCommand;
-import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactCommandAggregator;
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.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OvsdbConnectionInstance implements OvsdbClient {
private static final Logger LOG = LoggerFactory.getLogger(OvsdbConnectionInstance.class);
private OvsdbClient client;
- private OvsdbClientKey key;
+ private ConnectionInfo connectionInfo;
private TransactionInvoker txInvoker;
private Map<DatabaseSchema,TransactInvoker> transactInvokers = new HashMap<DatabaseSchema,TransactInvoker>();
private MonitorCallBack callback;
- OvsdbConnectionInstance(OvsdbClientKey key,OvsdbClient client,TransactionInvoker txInvoker) {
- this.key = key;
+ OvsdbConnectionInstance(ConnectionInfo key,OvsdbClient client,TransactionInvoker txInvoker) {
+ this.connectionInfo = key;
this.client = client;
this.txInvoker = txInvoker;
txInvoker.invoke(new OvsdbNodeCreateCommand(key, null,null));
}
public void transact(TransactCommand command) {
- for(TransactInvoker transactInvoker: transactInvokers.values()) {
+ for (TransactInvoker transactInvoker: transactInvokers.values()) {
transactInvoker.invoke(command);
}
}
private void registerCallBack() {
- this.callback = new OvsdbMonitorCallback(key,txInvoker);
+ this.callback = new OvsdbMonitorCallback(connectionInfo,txInvoker);
try {
List<String> databases = getDatabases().get();
- if(databases != null) {
+ if (databases != null) {
for (String database : databases) {
DatabaseSchema dbSchema = getSchema(database).get();
- if(dbSchema != null) {
+ if (dbSchema != null) {
transactInvokers.put(dbSchema, new TransactInvokerImpl(this,dbSchema));
monitorAllTables(database, dbSchema);
} else {
- LOG.warn("No schema reported for database {} for key {}",database,key);
+ LOG.warn("No schema reported for database {} for key {}",database,connectionInfo);
}
}
} else {
- LOG.warn("No databases reported from {}",key);
+ LOG.warn("No databases reported from {}",connectionInfo);
}
} catch (InterruptedException | ExecutionException e) {
- LOG.warn("Exception attempting to initialize {}: {}",key,e);
+ LOG.warn("Exception attempting to initialize {}: {}",connectionInfo,e);
}
}
private void monitorAllTables(String database, DatabaseSchema dbSchema) {
Set<String> tables = dbSchema.getTables();
- if(tables != null) {
+ if (tables != null) {
List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
for (String tableName : tables) {
GenericTableSchema tableSchema = dbSchema.table(tableName, GenericTableSchema.class);
}
this.callback.update(monitor(dbSchema, monitorRequests, callback),dbSchema);
} else {
- LOG.warn("No tables for schema {} for database {} for key {}",dbSchema,database,key);
+ LOG.warn("No tables for schema {} for database {} for key {}",dbSchema,database,connectionInfo);
}
}
client.stopEchoService();
}
- public OvsdbConnectionInfo getConnectionInfo() {
- return client.getConnectionInfo();
- }
-
public boolean isActive() {
return client.isActive();
}
return client.getTypedRowWrapper(klazz, row);
}
- public OvsdbClientKey getKey() {
- return key;
+ public OvsdbConnectionInfo getConnectionInfo() {
+ return client.getConnectionInfo();
+ }
+
+ public ConnectionInfo getMDConnectionInfo() {
+ return connectionInfo;
}
- public void setKey(OvsdbClientKey key) {
- this.key = key;
+ public void setMDConnectionInfo(ConnectionInfo key) {
+ this.connectionInfo = key;
}
}