2 * Copyright (c) 2014, 2015 EBay Software Foundation 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.util.List;
13 import org.opendaylight.ovsdb.lib.message.MonitorRequest;
14 import org.opendaylight.ovsdb.lib.message.TableUpdates;
15 import org.opendaylight.ovsdb.lib.notation.Row;
16 import org.opendaylight.ovsdb.lib.operations.Operation;
17 import org.opendaylight.ovsdb.lib.operations.OperationResult;
18 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
19 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
20 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
21 import org.opendaylight.ovsdb.lib.schema.TableSchema;
22 import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
24 import com.google.common.util.concurrent.ListenableFuture;
27 * The main interface to interact with a device speaking ovsdb protocol in an asynchronous fashion and hence most
28 * operations return a Future object representing the eventual response data from the remote.
30 public interface OvsdbClient {
33 * Gets the list of database names exposed by this ovsdb capable device
34 * @return list of database names
36 ListenableFuture<List<String>> getDatabases();
39 * Asynchronously returns the schema object for a specific database
40 * @param database name of the database schema
41 * @return DatabaseSchema future
43 ListenableFuture<DatabaseSchema> getSchema(String database);
46 * Allows for a mini DSL way of collecting the transactions to be executed against the ovsdb instance.
47 * @return TransactionBuilder
49 TransactionBuilder transactBuilder(DatabaseSchema dbSchema);
52 * Execute the list of operations in a single Transactions. Similar to the transactBuilder() method
53 * @param operations List of operations that needs to be part of a transact call
54 * @return Future object representing the result of the transaction. Calling
55 * cancel on the Future would cause OVSDB cancel operation to be fired against
58 ListenableFuture<List<OperationResult>> transact(DatabaseSchema dbSchema, List<Operation> operations);
62 * ovsdb <a href="http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-04#section-4.1.5">monitor</a> operation.
63 * @param monitorRequests represents what needs to be monitored including a client specified monitor handle. This
64 * handle is used to later cancel ({@link #cancelMonitor(MonitorHandle)}) the monitor.
65 * @param callback receives the monitor response
67 <E extends TableSchema<E>> TableUpdates monitor(DatabaseSchema schema,
68 List<MonitorRequest<E>> monitorRequests,
69 MonitorCallBack callback);
72 * ovsdb <a href="http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-04#section-4.1.5">monitor</a> operation.
73 * @param monitorRequests represents what needs to be monitored
74 * @param monitorHandle A client specified monitor handle. This handle is used to later cancel
75 * ({@link #cancelMonitor(MonitorHandle)}) the monitor.
76 * @param callback receives the monitor response
78 <E extends TableSchema<E>> TableUpdates monitor(DatabaseSchema schema,
79 List<MonitorRequest<E>> monitorRequests,
80 MonitorHandle monitorHandle,
81 MonitorCallBack callback);
84 * Cancels an existing monitor method.
85 * @param handler Handle identifying a specific monitor request that is being cancelled.
86 * @throws java.lang.IllegalStateException if there is no outstanding monitor request for this handle
88 void cancelMonitor(MonitorHandle handler);
91 * ovsdb <a href="http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-04#section-4.1.8">lock</a> operation.
92 * @param lockId a client specified id for the lock; this can be used for unlocking ({@link #unLock(String)})
93 * @param lockedCallBack Callback to nofify when the lock is acquired
94 * @param stolenCallback Callback to notify when an acquired lock is stolen by another client
96 void lock(String lockId, LockAquisitionCallback lockedCallBack, LockStolenCallback stolenCallback);
99 * ovsdb steal operation, see {@link #lock(String, LockAquisitionCallback, LockStolenCallback)}
103 ListenableFuture<Boolean> steal(String lockId);
106 * ovsdb unlock operaiton, see {@link #unLock(String)}
110 ListenableFuture<Boolean> unLock(String lockId);
113 * Starts the echo service. The {@code callbackFilters} can be used to get notified on the absence of echo
114 * notifications from the remote device and control the frequency of such notifications.
115 * @param callbackFilters callbacks for notifying the client of missing echo calls from remote.
117 void startEchoService(EchoServiceCallbackFilters callbackFilters);
120 * Stops the echo service, i.e echo requests from the remote would not be acknowledged after this call.
122 void stopEchoService();
124 OvsdbConnectionInfo getConnectionInfo();
130 DatabaseSchema getDatabaseSchema(String dbName);
133 * User friendly convenient methods that make use of TyperUtils.getTypedRowWrapper to create a Typed Row Proxy
134 * given the Typed Table Class
136 * @param klazz Typed Interface
137 * @return Proxy wrapper for the actual raw Row class.
139 <T extends TypedBaseTable<?>> T createTypedRowWrapper(Class<T> klazz);
141 * User friendly convenient methods that make use of getTypedRowWrapper to create a Typed Row Proxy given
142 * DatabaseSchema and Typed Table Class.
144 * @param dbSchema Database Schema of interest
145 * @param klazz Typed Interface
146 * @return Proxy wrapper for the actual raw Row class.
148 <T extends TypedBaseTable<?>> T createTypedRowWrapper(DatabaseSchema dbSchema, Class<T> klazz);
151 * User friendly convenient method to get a Typed Row Proxy given a Typed Table Class and the Row to be wrapped.
153 * @param klazz Typed Interface
154 * @param row The actual Row that the wrapper is operating on. It can be null if the caller
155 * is just interested in getting ColumnSchema.
156 * @return Proxy wrapper for the actual raw Row class.
158 <T extends TypedBaseTable<?>> T getTypedRowWrapper(final Class<T> klazz,
159 final Row<GenericTableSchema> row);