*
* Authors : Madhu Venugopal, Brent Salisbury, Evan Zeller
*/
-package org.opendaylight.ovsdb.plugin;
+package org.opendaylight.ovsdb.plugin.impl;
import io.netty.channel.ChannelHandler;
import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
import org.opendaylight.ovsdb.lib.schema.TableSchema;
+import org.opendaylight.ovsdb.plugin.IConnectionServiceInternal;
+import org.opendaylight.ovsdb.plugin.api.Connection;
+import org.opendaylight.ovsdb.plugin.internal.IPAddressProperty;
+import org.opendaylight.ovsdb.plugin.internal.L4PortProperty;
+import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
+import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Represents the openflow plugin component in charge of programming the flows
* the flow programming and relay them to functional modules above SAL.
*/
-public class ConnectionService implements IPluginInConnectionService, IConnectionServiceInternal, OvsdbConnectionListener {
- protected static final Logger logger = LoggerFactory.getLogger(ConnectionService.class);
+public class ConnectionServiceImpl implements IPluginInConnectionService,
+ OvsdbConnectionService,
+ IConnectionServiceInternal,
+ OvsdbConnectionListener {
+ protected static final Logger logger = LoggerFactory.getLogger(ConnectionServiceImpl.class);
// Properties that can be set in config.ini
private static final Integer defaultOvsdbPort = 6640;
- private OvsdbConnection connectionLib;
+
private ConcurrentMap<String, Connection> ovsdbConnections = new ConcurrentHashMap<String, Connection>();
private List<ChannelHandler> handlers = null;
- private InventoryServiceInternal inventoryServiceInternal;
-
- public InventoryServiceInternal getInventoryServiceInternal() {
- return inventoryServiceInternal;
- }
- public void setInventoryServiceInternal(InventoryServiceInternal inventoryServiceInternal) {
- this.inventoryServiceInternal = inventoryServiceInternal;
- }
-
- public void unsetInventoryServiceInternal(InventoryServiceInternal inventoryServiceInternal) {
- if (this.inventoryServiceInternal == inventoryServiceInternal) {
- this.inventoryServiceInternal = null;
- }
- }
+ private volatile OvsdbInventoryService ovsdbInventoryService;
+ private volatile OvsdbConnection connectionLib;
- public void setOvsdbConnection(OvsdbConnection connectionService) {
- connectionLib = connectionService;
- // It is not correct to register the service here. Rather, we should depend on the
- // Service created by createServiceDependency() and hook to it via Apache DM.
- // Using this temporarily till the Service Dependency is resolved.
- connectionLib.registerForPassiveConnection(this);
+ public void setOvsdbInventoryService(OvsdbInventoryService inventoryService) {
+ this.ovsdbInventoryService = inventoryService;
}
- public void unsetOvsdbConnection(OvsdbConnection connectionService) {
- connectionLib = null;
+ public void setOvsdbConnection(OvsdbConnection ovsdbConnection) {
+ this.connectionLib = ovsdbConnection;
}
public void init() {
if (connection != null) {
ovsdbConnections.remove(identifier);
connection.disconnect();
- inventoryServiceInternal.removeNode(node);
+ ovsdbInventoryService.removeNode(node);
return new Status(StatusCode.SUCCESS);
} else {
return new Status(StatusCode.NOTFOUND);
@Override
public void run() {
try {
+ logger.info("Initialize inventory for {}", connection.toString());
initializeInventoryForNewNode(connection);
} catch (InterruptedException | ExecutionException | IOException e) {
logger.error("Failed to initialize inventory for node with identifier " + identifier, e);
public void channelClosed(Node node) throws Exception {
logger.info("Connection to Node : {} closed", node);
disconnect(node);
- inventoryServiceInternal.removeNode(node);
+ ovsdbInventoryService.removeNode(node);
}
private void initializeInventoryForNewNode (Connection connection) throws InterruptedException, ExecutionException, IOException {
Set<Property> props = new HashSet<Property>();
props.add(addressProp);
props.add(l4Port);
- inventoryServiceInternal.addNode(connection.getNode(), props);
+ logger.info("Add node to ovsdb inventory service {}", connection.getNode().toString());
+ ovsdbInventoryService.addNode(connection.getNode(), props);
List<String> databases = client.getDatabases().get();
if (databases == null) {
for (String database : databases) {
DatabaseSchema dbSchema = client.getSchema(database).get();
TableUpdates updates = this.monitorTables(connection.getNode(), dbSchema);
- inventoryServiceInternal.processTableUpdates(connection.getNode(), dbSchema.getName(), updates);
+ ovsdbInventoryService.processTableUpdates(connection.getNode(), dbSchema.getName(), updates);
}
- inventoryServiceInternal.notifyNodeAdded(connection.getNode());
+ logger.info("Notifying Inventory Listeners for Node Added: {}", connection.getNode().toString());
+ ovsdbInventoryService.notifyNodeAdded(connection.getNode());
}
public TableUpdates monitorTables(Node node, DatabaseSchema dbSchema) throws ExecutionException, InterruptedException, IOException {
@Override
public void update(TableUpdates result, DatabaseSchema dbSchema) {
- inventoryServiceInternal.processTableUpdates(node, dbSchema.getName(), result);
+ ovsdbInventoryService.processTableUpdates(node, dbSchema.getName(), result);
}
@Override