Changing the monitor operation in the library layer to return TableUpdates as per...
[ovsdb.git] / library / src / main / java / org / opendaylight / ovsdb / lib / OvsdbClient.java
1 /*
2  *
3  *  * Copyright (C) 2014 EBay Software Foundation
4  *  *
5  *  * This program and the accompanying materials are made available under the
6  *  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  *  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  *  *
9  *  * Authors : Ashwin Raveendran
10  *
11  */
12
13 package org.opendaylight.ovsdb.lib;
14
15 import java.util.List;
16
17 import org.opendaylight.ovsdb.lib.message.MonitorRequest;
18 import org.opendaylight.ovsdb.lib.message.TableUpdates;
19 import org.opendaylight.ovsdb.lib.notation.Row;
20 import org.opendaylight.ovsdb.lib.operations.Operation;
21 import org.opendaylight.ovsdb.lib.operations.OperationResult;
22 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
23 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
24 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
25 import org.opendaylight.ovsdb.lib.schema.TableSchema;
26
27 import com.google.common.util.concurrent.ListenableFuture;
28
29 /**
30  * The main interface to interact with a device speaking ovsdb protocol in an asynchronous fashion and hence most
31  * operations return a Future object representing the eventual response data from the remote.
32  */
33 public interface OvsdbClient {
34
35     /**
36      * Gets the list of database names exposed by this ovsdb capable device
37      * @return list of database names
38      */
39     ListenableFuture<List<String>> getDatabases();
40
41     /**
42      * Asynchronously returns the schema object for a specific database
43      * @param database name of the database schema
44      * @return DatabaseSchema future
45      */
46     ListenableFuture<DatabaseSchema> getSchema(String database);
47
48     /**
49      * Allows for a mini DSL way of collecting the transactions to be executed against the ovsdb instance.
50      * @return TransactionBuilder
51      */
52     TransactionBuilder transactBuilder();
53
54     /**
55      * Execute the list of operations in a single Transactions. Similar to the transactBuilder() method
56      * @param operations List of operations that needs to be part of a transact call
57      * @return Future object representing the result of the transaction. Calling
58      * cancel on the Future would cause OVSDB cancel operation to be fired against
59      * the device.
60      */
61     ListenableFuture<List<OperationResult>> transact(List<Operation> operations);
62
63
64     /**
65      * ovsdb <a href="http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-04#section-4.1.5">monitor</a> operation.
66      * @param monitorRequests represents what needs to be monitored including a client specified monitor handle. This
67      *                       handle is used to later cancel ({@link #cancelMonitor(MonitorHandle)}) the monitor.
68      * @param callback receives the monitor response
69      */
70     public <E extends TableSchema<E>> TableUpdates monitor(DatabaseSchema schema, List<MonitorRequest<E>> monitorRequests,
71                                  MonitorCallBack callback);
72
73     /**
74      * Cancels an existing monitor method.
75      * @param handler Handle identifying a specific monitor request that is being cancelled.
76      * @throws java.lang.IllegalStateException if there is no outstanding monitor request for this handle
77      */
78     public void cancelMonitor(MonitorHandle handler);
79
80     /**
81      * ovsdb <a href="http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-04#section-4.1.8">lock</a> operation.
82      * @param lockId a client specified id for the lock; this can be used for unlocking ({@link #unLock(String)})
83      * @param lockedCallBack Callback to nofify when the lock is acquired
84      * @param stolenCallback Callback to notify when an acquired lock is stolen by another client
85      */
86     public void lock(String lockId, LockAquisitionCallback lockedCallBack, LockStolenCallback stolenCallback);
87
88     /**
89      * ovsdb steal operation, see {@link #lock(String, LockAquisitionCallback, LockStolenCallback)}
90      * @param lockId
91      * @return
92      */
93     public ListenableFuture<Boolean> steal(String lockId);
94
95     /**
96      * ovsdb unlock operaiton, see {@link #unLock(String)}
97      * @param lockId
98      * @return
99      */
100     public ListenableFuture<Boolean> unLock(String lockId);
101
102     /**
103      * Starts the echo service. The {@code callbackFilters} can be used to get notified on the absence of echo
104      * notifications from the remote device and control the frequency of such notifications.
105      * @param callbackFilters callbacks for notifying the client of missing echo calls from remote.
106      */
107     public void startEchoService(EchoServiceCallbackFilters callbackFilters);
108
109     /**
110      * Stops the echo service, i.e echo requests from the remote would not be acknowledged after this call.
111      */
112     public void stopEchoService();
113
114     public OvsdbConnectionInfo getConnectionInfo();
115
116     public boolean isActive();
117
118     public void disconnect();
119
120     public DatabaseSchema getDatabaseSchema (String dbName);
121
122     /**
123      * User friendly convenient methods that make use of TyperUtils.getTypedRowWrapper to create a Typed Row Proxy
124      * given the Typed Table Class
125      *
126      * @param klazz Typed Interface
127      * @return Proxy wrapper for the actual raw Row class.
128      */
129     public <T> T createTypedRowWrapper(Class<T> klazz);
130     /**
131      * User friendly convenient methods that make use of getTypedRowWrapper to create a Typed Row Proxy given
132      * DatabaseSchema and Typed Table Class.
133      *
134      * @param dbSchema Database Schema of interest
135      * @param klazz Typed Interface
136      * @return Proxy wrapper for the actual raw Row class.
137      */
138     public <T> T createTypedRowWrapper(DatabaseSchema dbSchema, Class<T> klazz);
139
140     /**
141      * User friendly convenient method to get a Typed Row Proxy given a Typed Table Class and the Row to be wrapped.
142      *
143      * @param klazz Typed Interface
144      * @param row The actual Row that the wrapper is operating on. It can be null if the caller is just interested in getting ColumnSchema.
145      * @return Proxy wrapper for the actual raw Row class.
146      */
147     public <T> T getTypedRowWrapper(final Class<T> klazz, final Row<GenericTableSchema> row);
148
149 }