6d5a35269f2105f9f837b3a7aade15cdad1cbdba
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / OvsdbConnection.java
1 /*
2  * Copyright (c) 2014, 2015 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.ovsdb.lib;
9
10 import io.netty.channel.Channel;
11 import java.net.InetAddress;
12 import java.util.Collection;
13 import javax.net.ssl.SSLContext;
14
15 /**
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
21  * the controller.
22  *
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
25  * listener API.
26  */
27 public interface OvsdbConnection {
28
29     /**
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.
35      */
36     OvsdbClient connect(InetAddress address, int port);
37
38     /**
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.
45      */
46     OvsdbClient connectWithSsl(InetAddress address, int port, SSLContext sslContext);
47
48     /**
49      * Method to disconnect an existing connection.
50      * @param client that represents the ovsdb connection.
51      */
52     void disconnect(OvsdbClient client);
53
54     /**
55      * Method to start ovsdb server for passive connection.
56      */
57     boolean startOvsdbManager(int ovsdbListenPort);
58
59     /**
60      * Method to start ovsdb server for passive connection with SSL.
61      */
62     boolean startOvsdbManagerWithSsl(int ovsdbListenPort, SSLContext sslContext);
63
64     /**
65      * Method to register a Passive Connection Listener with the ConnectionService.
66      * @param listener Passive Connection listener interested in Passive OVSDB connection requests.
67      */
68     void registerConnectionListener(OvsdbConnectionListener listener);
69
70     /**
71      * Method to unregister a Passive Connection Listener with the ConnectionService.
72      */
73     void unregisterConnectionListener(OvsdbConnectionListener listener);
74
75     /**
76      * Returns a Collection of all the active OVSDB Connections.
77      *
78      * @return Collection of all the active OVSDB Connections
79      */
80     Collection<OvsdbClient> getConnections();
81
82     OvsdbClient getClient(Channel channel);
83 }