import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.sal.connection.ConnectionConstants;
-import org.opendaylight.controller.sal.connection.IPluginInConnectionService;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.Property;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.ovsdb.lib.MonitorCallBack;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
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.api.ConnectionConstants;
+import org.opendaylight.ovsdb.plugin.api.Status;
+import org.opendaylight.ovsdb.plugin.api.StatusCode;
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.opendaylight.ovsdb.utils.config.ConfigProperties;
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 ConnectionServiceImpl implements IPluginInConnectionService,
- OvsdbConnectionService,
- IConnectionServiceInternal,
+public class ConnectionServiceImpl implements OvsdbConnectionService,
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 static final Integer DEFAULT_OVSDB_PORT = 6640;
+ private static final String OVSDB_LISTENPORT = "ovsdb.listenPort";
private ConcurrentMap<String, Connection> ovsdbConnections = new ConcurrentHashMap<String, Connection>();
* the services provided by the class are registered in the service registry
*/
void start() {
+ /* Start ovsdb server before getting connection clients */
+ String portString = ConfigProperties.getProperty(OvsdbConnectionService.class, OVSDB_LISTENPORT);
+ int ovsdbListenPort = DEFAULT_OVSDB_PORT;
+ if (portString != null) {
+ ovsdbListenPort = Integer.decode(portString).intValue();
+ }
+
+ if (!connectionLib.startOvsdbManager(ovsdbListenPort)) {
+ logger.warn("Start OVSDB manager call from ConnectionService was not necessary");
+ }
+
+ /* Then get connection clients */
Collection<OvsdbClient> connections = connectionLib.getConnections();
for (OvsdbClient client : connections) {
+ logger.info("CONNECT start connected clients client = {}", client);
this.connected(client);
}
}
}
}
- @Override
public Status disconnect(Node node) {
String identifier = (String) node.getID();
Connection connection = ovsdbConnections.get(identifier);
}
}
- @Override
public Node connect(String identifier, Map<ConnectionConstants, String> params) {
InetAddress address;
Integer port;
try {
port = Integer.parseInt(params.get(ConnectionConstants.PORT));
- if (port == 0) port = defaultOvsdbPort;
+ if (port == 0) port = DEFAULT_OVSDB_PORT;
} catch (Exception e) {
- port = defaultOvsdbPort;
+ port = DEFAULT_OVSDB_PORT;
}
try {
return ovsdbConnections.get(identifier);
}
+ @Override
+ public Node getNode (String identifier) {
+ String id = identifier;
+
+ String[] pair = identifier.split("[|,:]+");
+ if (pair[0].equals("OVS")) {
+ id = pair[1];
+ }
+
+ Connection connection = ovsdbConnections.get(id);
+ if (connection != null) {
+ return connection.getNode();
+ } else {
+ return null;
+ }
+ }
+
@Override
public List<Node> getNodes() {
List<Node> nodes = new ArrayList<Node>();
return nodes;
}
- @Override
- public void notifyClusterViewChanged() {
- }
-
- @Override
- public void notifyNodeDisconnectFromMaster(Node arg0) {
- }
-
private Node handleNewConnection(String identifier, OvsdbClient client) throws InterruptedException, ExecutionException {
Connection connection = new Connection(identifier, client);
Node node = connection.getNode();