2 * Copyright (c) 2014, 2015 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.ovsdb.lib;
11 import java.net.InetAddress;
12 import java.util.Collection;
13 import javax.net.ssl.SSLContext;
16 * OvsDBConnection Interface provides OVSDB connection management APIs which includes
17 * both Active and Passive connections.
18 * From the Library perspective, Active OVSDB connections are those that are initiated from
19 * the Controller towards the ovsdb-manager.
20 * While Passive OVSDB connections are those that are initiated from the ovs towards
23 * Applications that use OvsDBConnectionService can use the connect APIs to initiate Active
24 * connections and can listen to the asynchronous Passive connections via registerConnectionListener
28 public interface OvsdbConnection {
30 * connect API can be used by the applications to initiate Active connection from
31 * the controller towards ovsdb-server
32 * @param address IP Address of the remote server that hosts the ovsdb server.
33 * @param port Layer 4 port on which the remote ovsdb server is listening on.
34 * @return OvsDBClient The primary Client interface for the ovsdb connection.
36 OvsdbClient connect(final InetAddress address, final int port);
39 * connect API can be used by the applications to initiate Active ssl
40 * connection from the controller towards ovsdb-server
41 * @param address IP Address of the remote server that hosts the ovsdb server.
42 * @param port Layer 4 port on which the remote ovsdb server is listening on.
43 * @param sslContext Netty sslContext for channel configuration
44 * @return OvsDBClient The primary Client interface for the ovsdb connection.
46 OvsdbClient connectWithSsl(final InetAddress address, final int port,
47 final SSLContext sslContext);
50 * Method to disconnect an existing connection.
51 * @param client that represents the ovsdb connection.
53 void disconnect(OvsdbClient client);
56 * Method to start ovsdb server for passive connection
58 boolean startOvsdbManager(final int ovsdbListenPort);
61 * Method to start ovsdb server for passive connection with SSL
63 boolean startOvsdbManagerWithSsl(final int ovsdbListenPort,
64 final SSLContext sslContext);
67 * Method to register a Passive Connection Listener with the ConnectionService.
68 * @param listener Passive Connection listener interested in Passive OVSDB connection requests.
70 void registerConnectionListener(OvsdbConnectionListener listener);
73 * Method to unregister a Passive Connection Listener with the ConnectionService.
76 void unregisterConnectionListener(OvsdbConnectionListener listener);
79 * Returns a Collection of all the active OVSDB Connections.
81 * @return Collection of all the active OVSDB Connections
83 Collection<OvsdbClient> getConnections();