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
8 package org.opendaylight.ovsdb.lib;
10 import io.netty.channel.Channel;
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 * <p>Applications that use OvsDBConnectionService can use the connect APIs to initiate Active
24 * connections and can listen to the asynchronous Passive connections via registerConnectionListener
27 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(InetAddress address, 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(InetAddress address, int port, SSLContext sslContext);
49 * Method to disconnect an existing connection.
50 * @param client that represents the ovsdb connection.
52 void disconnect(OvsdbClient client);
55 * Method to start ovsdb server for passive connection.
57 boolean startOvsdbManager(int ovsdbListenPort);
60 * Method to start ovsdb server for passive connection with SSL.
62 boolean startOvsdbManagerWithSsl(int ovsdbListenPort, SSLContext sslContext);
65 * Method to register a Passive Connection Listener with the ConnectionService.
66 * @param listener Passive Connection listener interested in Passive OVSDB connection requests.
68 void registerConnectionListener(OvsdbConnectionListener listener);
71 * Method to unregister a Passive Connection Listener with the ConnectionService.
73 void unregisterConnectionListener(OvsdbConnectionListener listener);
76 * Returns a Collection of all the active OVSDB Connections.
78 * @return Collection of all the active OVSDB Connections
80 Collection<OvsdbClient> getConnections();
82 OvsdbClient getClient(Channel channel);