All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.ovsdb.lib.OvsdbClient Maven / Gradle / Ivy

/*
 * Copyright (c) 2014, 2015 EBay Software Foundation and others. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.ovsdb.lib;

import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import org.opendaylight.ovsdb.lib.message.MonitorRequest;
import org.opendaylight.ovsdb.lib.message.TableUpdates;
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.operations.Operation;
import org.opendaylight.ovsdb.lib.operations.OperationResult;
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
import org.opendaylight.ovsdb.lib.schema.TableSchema;
import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
import org.opendaylight.ovsdb.lib.schema.typed.TypedDatabaseSchema;

/**
 * The main interface to interact with a device speaking ovsdb protocol in an asynchronous fashion and hence most
 * operations return a Future object representing the eventual response data from the remote.
 */
public interface OvsdbClient {

    /**
     * Gets the list of database names exposed by this ovsdb capable device.
     * @return list of database names
     */
    ListenableFuture> getDatabases();

    /**
     * Asynchronously returns the schema object for a specific database.
     * @param database name of the database schema
     * @return DatabaseSchema future
     */
    ListenableFuture getSchema(String database);

    /**
     * Allows for a mini DSL way of collecting the transactions to be executed against the ovsdb instance.
     * @return TransactionBuilder
     */
    TransactionBuilder transactBuilder(DatabaseSchema dbSchema);

    /**
     * Execute the list of operations in a single Transactions. Similar to the transactBuilder() method
     * @param operations List of operations that needs to be part of a transact call
     * @return Future object representing the result of the transaction. Calling
     *     cancel on the Future would cause OVSDB cancel operation to be fired against
     *     the device.
     */
    ListenableFuture> transact(DatabaseSchema dbSchema, List operations);

    /**
     * ovsdb monitor operation.
     * @param monitorRequests represents what needs to be monitored including a client specified monitor handle. This
     *                       handle is used to later cancel ({@link #cancelMonitor(MonitorHandle)}) the monitor.
     * @param callback receives the monitor response
     */
    > TableUpdates monitor(DatabaseSchema schema,
                                                    List monitorRequests,
                                                    MonitorCallBack callback);

    /**
     * ovsdb monitor operation.
     * @param monitorRequests represents what needs to be monitored including a client specified monitor handle. This
     *                       handle is used to later cancel ({@link #cancelMonitor(MonitorHandle)}) the monitor.
     * @param callback receives the monitor response
     * @param timeout time in seconds for monitor transaction timeout
     */
    > TableUpdates monitor(DatabaseSchema schema,
                                                    List monitorRequests,
                                                    MonitorCallBack callback,
                                                    int timeout);

    /**
     * ovsdb monitor operation.
     * @param monitorRequests represents what needs to be monitored
     * @param monitorHandle  A client specified monitor handle. This handle is used to later cancel
     *                       ({@link #cancelMonitor(MonitorHandle)}) the monitor.
     * @param callback receives the monitor response
     */
    > TableUpdates monitor(DatabaseSchema schema,
                                                    List monitorRequests,
                                                    MonitorHandle monitorHandle,
                                                    MonitorCallBack callback);

    /**
     * ovsdb monitor operation.
     * @param monitorRequests represents what needs to be monitored
     * @param monitorHandle  A client specified monitor handle. This handle is used to later cancel
     *                       ({@link #cancelMonitor(MonitorHandle)}) the monitor.
     * @param callback receives the monitor response
     * @param timeout time in seconds for monitor transaction timeout
     */
    > TableUpdates monitor(DatabaseSchema schema,
                                                    List monitorRequests,
                                                    MonitorHandle monitorHandle,
                                                    MonitorCallBack callback,
                                                    int timeout);

    /**
     * Cancels an existing monitor method.
     * @param handler Handle identifying a specific monitor request that is being cancelled.
     * @throws java.lang.IllegalStateException if there is no outstanding monitor request for this handle
     */
    void cancelMonitor(MonitorHandle handler);

    /**
     * Cancels an existing monitor method.
     * @param handler Handle identifying a specific monitor request that is being cancelled.
     * @param timeout time in seconds for monitor transaction timeout
     * @throws java.lang.IllegalStateException if there is no outstanding monitor request for this handle
     */
    void cancelMonitor(MonitorHandle handler, int timeout);

    /**
     * ovsdb lock operation.
     * @param lockId a client specified id for the lock; this can be used for unlocking ({@link #unLock(String)})
     * @param lockedCallBack Callback to nofify when the lock is acquired
     * @param stolenCallback Callback to notify when an acquired lock is stolen by another client
     */
    void lock(String lockId, LockAquisitionCallback lockedCallBack, LockStolenCallback stolenCallback);

    /**
     * ovsdb steal operation.
     * See {@link #lock(String, LockAquisitionCallback, LockStolenCallback)}
     */
    ListenableFuture steal(String lockId);

    /**
     * ovsdb unlock operation.
     * See {@link #unLock(String)}
     */
    ListenableFuture unLock(String lockId);

    /**
     * ovsdb echo operation.
     */
    ListenableFuture> echo();

    /**
     * Starts the echo service. The {@code callbackFilters} can be used to get notified on the absence of echo
     * notifications from the remote device and control the frequency of such notifications.
     * @param callbackFilters callbacks for notifying the client of missing echo calls from remote.
     */
    void startEchoService(EchoServiceCallbackFilters callbackFilters);

    /**
     * Stops the echo service, i.e echo requests from the remote would not be acknowledged after this call.
     */
    void stopEchoService();

    OvsdbConnectionInfo getConnectionInfo();

    boolean isActive();

    void disconnect();

    TypedDatabaseSchema getDatabaseSchema(String dbName);

    /**
     * User friendly convenient methods that make use of TyperUtils.getTypedRowWrapper to create a Typed Row Proxy
     * given the Typed Table Class.
     *
     * @param klazz Typed Interface
     * @return Proxy wrapper for the actual raw Row class.
     */
    > T createTypedRowWrapper(Class klazz);

    /**
     * User friendly convenient methods that make use of getTypedRowWrapper to create a Typed Row Proxy given
     * DatabaseSchema and Typed Table Class.
     *
     * @param dbSchema Database Schema of interest
     * @param klazz Typed Interface
     * @return Proxy wrapper for the actual raw Row class.
     */
    > T createTypedRowWrapper(DatabaseSchema dbSchema, Class klazz);

    /**
     * User friendly convenient method to get a Typed Row Proxy given a Typed Table Class and the Row to be wrapped.
     *
     * @param klazz Typed Interface
     * @param row The actual Row that the wrapper is operating on. It can be null if the caller
     *            is just interested in getting ColumnSchema.
     * @return Proxy wrapper for the actual raw Row class.
     */
    > T getTypedRowWrapper(Class klazz, Row row);

    boolean isConnectionPublished();

    void setConnectionPublished(boolean status);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy