net.floodlightcontroller.storage
Interface IStorageSourceService

All Superinterfaces:
IFloodlightService
All Known Implementing Classes:
AbstractStorageSource, MemoryStorageSource, NoSqlStorageSource

public interface IStorageSourceService
extends IFloodlightService


Method Summary
 void addListener(java.lang.String tableName, IStorageSourceListener listener)
          Add a listener to the specified table.
 IQuery createQuery(java.lang.String tableName, java.lang.String[] columnNames, IPredicate predicate, RowOrdering ordering)
          Create a query object representing the given query parameters.
 void createTable(java.lang.String tableName, java.util.Set<java.lang.String> indexedColumns)
          Create a new table if one does not already exist with the given name.
 void deleteMatchingRows(java.lang.String tableName, IPredicate predicate)
          Delete the rows that match the predicate
 java.util.concurrent.Future<?> deleteMatchingRowsAsync(java.lang.String tableName, IPredicate predicate)
          Asynchronous version of deleteRows
 void deleteRow(java.lang.String tableName, java.lang.Object rowKey)
          Delete the row with the given primary key.
 java.util.concurrent.Future<?> deleteRowAsync(java.lang.String tableName, java.lang.Object rowKey)
          Asynchronous version of deleteRow
 void deleteRows(java.lang.String tableName, java.util.Set<java.lang.Object> rowKeys)
          Delete the rows with the given keys.
 java.util.concurrent.Future<?> deleteRowsAsync(java.lang.String tableName, java.util.Set<java.lang.Object> rowKeys)
          Asynchronous version of deleteRows
 IResultSet executeQuery(IQuery query)
          Execute a query created with createQuery.
 IResultSet executeQuery(java.lang.String tableName, java.lang.String[] columnNames, IPredicate predicate, RowOrdering ordering)
          Execute a query created with the given query parameters.
 java.lang.Object[] executeQuery(java.lang.String tableName, java.lang.String[] columnNames, IPredicate predicate, RowOrdering ordering, IRowMapper rowMapper)
          Execute a query and call the row mapper to map the results to Java objects.
 java.util.concurrent.Future<IResultSet> executeQueryAsync(IQuery query)
          Asynchronous variant of executeQuery.
 java.util.concurrent.Future<IResultSet> executeQueryAsync(java.lang.String tableName, java.lang.String[] columnNames, IPredicate predicate, RowOrdering ordering)
          Asynchronous variant of executeQuery.
 java.util.concurrent.Future<java.lang.Object[]> executeQueryAsync(java.lang.String tableName, java.lang.String[] columnNames, IPredicate predicate, RowOrdering ordering, IRowMapper rowMapper)
          Asynchronous variant of executeQuery
 java.util.Set<java.lang.String> getAllTableNames()
           
 IResultSet getRow(java.lang.String tableName, java.lang.Object rowKey)
          Query for a row with the given ID (primary key).
 java.util.concurrent.Future<?> getRowAsync(java.lang.String tableName, java.lang.Object rowKey)
          Asynchronous version of getRow
 void insertRow(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> values)
          Insert a new row in the table with the given column data.
 java.util.concurrent.Future<?> insertRowAsync(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> values)
          Asynchronous variant of insertRow.
 void notifyListeners(java.util.List<StorageSourceNotification> notifications)
          This is logically a private method and should not be called by clients of this interface.
 void removeListener(java.lang.String tableName, IStorageSourceListener listener)
          Remove a listener from the specified table.
 java.util.concurrent.Future<?> saveAsync(IResultSet resultSet)
          Asynchronous version of save
 void setExceptionHandler(IStorageExceptionHandler exceptionHandler)
          Set exception handler to use for asynchronous operations.
 void setTablePrimaryKeyName(java.lang.String tableName, java.lang.String primaryKeyName)
          Set the column to be used as the primary key for a table.
 void updateMatchingRows(java.lang.String tableName, IPredicate predicate, java.util.Map<java.lang.String,java.lang.Object> values)
          Update the rows in the given table.
 java.util.concurrent.Future<?> updateMatchingRowsAsync(java.lang.String tableName, IPredicate predicate, java.util.Map<java.lang.String,java.lang.Object> values)
          Asynchronous variant of updateMatchingRows
 void updateRow(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> values)
          Update or insert a row in the table with the given column data.
 void updateRow(java.lang.String tableName, java.lang.Object rowKey, java.util.Map<java.lang.String,java.lang.Object> values)
          Update or insert a row in the table with the given row key (primary key) and column names/values.
 java.util.concurrent.Future<?> updateRowAsync(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> values)
          Asynchronous version of updateRow
 java.util.concurrent.Future<?> updateRowAsync(java.lang.String tableName, java.lang.Object rowKey, java.util.Map<java.lang.String,java.lang.Object> values)
          Asynchronous variant of updateRow
 void updateRows(java.lang.String tableName, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> rows)
          Update or insert a list of rows in the table.
 java.util.concurrent.Future<?> updateRowsAsync(java.lang.String tableName, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> rows)
          Asynchronous variant of updateRows
 

Method Detail

setTablePrimaryKeyName

void setTablePrimaryKeyName(java.lang.String tableName,
                            java.lang.String primaryKeyName)
Set the column to be used as the primary key for a table. This should be guaranteed to be unique for all of the rows in the table, although the storage API does not necessarily enforce this requirement. If no primary key name is specified for a table then the storage API assumes there is a column named "id" that is used as the primary key. In this case when a new row is inserted using the storage API and no id is specified explictly in the row data, the storage API automatically generates a unique ID (typically a UUID) for the id column. To work across all possible implementations of the storage API it is safest, though, to specify the primary key column explicitly. FIXME: It's sort of a kludge to have to specify the primary key column here. Ideally there would be some sort of metadata -- perhaps stored directly in the table, at least in the NoSQL case -- that the storage API could query to obtain the primary key info.

Parameters:
tableName - The name of the table for which we're setting the key
primaryKeyName - The name of column to be used as the primary key

createTable

void createTable(java.lang.String tableName,
                 java.util.Set<java.lang.String> indexedColumns)
Create a new table if one does not already exist with the given name.

Parameters:
tableName - The name of the table to create.
indexedColumns - Which columns should be indexed

getAllTableNames

java.util.Set<java.lang.String> getAllTableNames()
Returns:
the set of all tables that have been created via createTable

createQuery

IQuery createQuery(java.lang.String tableName,
                   java.lang.String[] columnNames,
                   IPredicate predicate,
                   RowOrdering ordering)
Create a query object representing the given query parameters. The query object can be passed to executeQuery to actually perform the query and obtain a result set.

Parameters:
tableName - The name of the table to query.
columnNames - The list of columns to return in the result set.
predicate - The predicate that specifies which rows to return in the result set.
ordering - Specification of order that rows are returned from the result set returned from executing the query. If the ordering is null, then rows are returned in an implementation-specific order.
Returns:
Query object to be passed to executeQuery.

executeQuery

IResultSet executeQuery(IQuery query)
Execute a query created with createQuery.

Parameters:
query - The query to execute
Returns:
The result set containing the rows/columns specified in the query.

executeQuery

IResultSet executeQuery(java.lang.String tableName,
                        java.lang.String[] columnNames,
                        IPredicate predicate,
                        RowOrdering ordering)
Execute a query created with the given query parameters.

Parameters:
tableName - The name of the table to query.
columnNames - The list of columns to return in the result set.
predicate - The predicate that specifies which rows to return in the result set.
ordering - Specification of order that rows are returned from the result set returned from executing the query. If the ordering is null, then rows are returned in an implementation-specific order.
Returns:
The result set containing the rows/columns specified in the query.

executeQuery

java.lang.Object[] executeQuery(java.lang.String tableName,
                                java.lang.String[] columnNames,
                                IPredicate predicate,
                                RowOrdering ordering,
                                IRowMapper rowMapper)
Execute a query and call the row mapper to map the results to Java objects.

Parameters:
tableName - The name of the table to query.
columnNames - The list of columns to return in the result set.
predicate - The predicate that specifies which rows to return in the result set.
ordering - Specification of order that rows are returned from the result set returned from executing the query. If the ordering is null, then rows are returned in an implementation-specific order.
rowMapper - The client-supplied object that maps the data in a row in the result set to a client object.
Returns:
The result set containing the rows/columns specified in the query.

insertRow

void insertRow(java.lang.String tableName,
               java.util.Map<java.lang.String,java.lang.Object> values)
Insert a new row in the table with the given column data. If the primary key is the default value of "id" and is not specified in the then a unique id will be automatically assigned to the row.

Parameters:
tableName - The name of the table to which to add the row
values - The map of column names/values to add to the table.

updateRows

void updateRows(java.lang.String tableName,
                java.util.List<java.util.Map<java.lang.String,java.lang.Object>> rows)
Update or insert a list of rows in the table. The primary key must be included in the map of values for each row.

Parameters:
tableName - The table to update or insert into
values - The map of column names/values to update the rows

updateMatchingRows

void updateMatchingRows(java.lang.String tableName,
                        IPredicate predicate,
                        java.util.Map<java.lang.String,java.lang.Object> values)
Update the rows in the given table. Any rows matching the predicate are updated with the column names/values specified in the values map. (The values map should not contain the special column "id".)

Parameters:
tableName - The table to update
predicate - The predicate to use to select which rows to update
values - The map of column names/values to update the rows.

updateRow

void updateRow(java.lang.String tableName,
               java.lang.Object rowKey,
               java.util.Map<java.lang.String,java.lang.Object> values)
Update or insert a row in the table with the given row key (primary key) and column names/values. (If the values map contains the special column "id", its value must match rowId.)

Parameters:
tableName - The table to update or insert into
rowKey - The ID (primary key) of the row to update
values - The map of column names/values to update the rows

updateRow

void updateRow(java.lang.String tableName,
               java.util.Map<java.lang.String,java.lang.Object> values)
Update or insert a row in the table with the given column data. The primary key must be included in the map of values.

Parameters:
tableName - The table to update or insert into
values - The map of column names/values to update the rows

deleteRow

void deleteRow(java.lang.String tableName,
               java.lang.Object rowKey)
Delete the row with the given primary key.

Parameters:
tableName - The table from which to delete the row
rowKey - The primary key of the row to delete.

deleteRows

void deleteRows(java.lang.String tableName,
                java.util.Set<java.lang.Object> rowKeys)
Delete the rows with the given keys.

Parameters:
tableName - The table from which to delete the rows
rowKeys - The set of primary keys of the rows to delete.

deleteMatchingRows

void deleteMatchingRows(java.lang.String tableName,
                        IPredicate predicate)
Delete the rows that match the predicate

Parameters:
tableName -
predicate -

getRow

IResultSet getRow(java.lang.String tableName,
                  java.lang.Object rowKey)
Query for a row with the given ID (primary key).

Parameters:
tableName - The name of the table to query
rowKey - The primary key of the row
Returns:
The result set containing the row with the given ID

setExceptionHandler

void setExceptionHandler(IStorageExceptionHandler exceptionHandler)
Set exception handler to use for asynchronous operations.

Parameters:
exceptionHandler -

executeQueryAsync

java.util.concurrent.Future<IResultSet> executeQueryAsync(IQuery query)
Asynchronous variant of executeQuery.

Parameters:
query -
Returns:

executeQueryAsync

java.util.concurrent.Future<IResultSet> executeQueryAsync(java.lang.String tableName,
                                                          java.lang.String[] columnNames,
                                                          IPredicate predicate,
                                                          RowOrdering ordering)
Asynchronous variant of executeQuery.

Parameters:
tableName -
columnNames -
predicate -
ordering -
Returns:

executeQueryAsync

java.util.concurrent.Future<java.lang.Object[]> executeQueryAsync(java.lang.String tableName,
                                                                  java.lang.String[] columnNames,
                                                                  IPredicate predicate,
                                                                  RowOrdering ordering,
                                                                  IRowMapper rowMapper)
Asynchronous variant of executeQuery

Parameters:
tableName -
columnNames -
predicate -
ordering -
rowMapper -
Returns:

insertRowAsync

java.util.concurrent.Future<?> insertRowAsync(java.lang.String tableName,
                                              java.util.Map<java.lang.String,java.lang.Object> values)
Asynchronous variant of insertRow.

Parameters:
tableName -
values -
Returns:

updateRowsAsync

java.util.concurrent.Future<?> updateRowsAsync(java.lang.String tableName,
                                               java.util.List<java.util.Map<java.lang.String,java.lang.Object>> rows)
Asynchronous variant of updateRows

Parameters:
tableName -
rows -

updateMatchingRowsAsync

java.util.concurrent.Future<?> updateMatchingRowsAsync(java.lang.String tableName,
                                                       IPredicate predicate,
                                                       java.util.Map<java.lang.String,java.lang.Object> values)
Asynchronous variant of updateMatchingRows

Parameters:
tableName -
predicate -
values -
Returns:

updateRowAsync

java.util.concurrent.Future<?> updateRowAsync(java.lang.String tableName,
                                              java.lang.Object rowKey,
                                              java.util.Map<java.lang.String,java.lang.Object> values)
Asynchronous variant of updateRow

Parameters:
tableName -
rowKey -
values -
Returns:

updateRowAsync

java.util.concurrent.Future<?> updateRowAsync(java.lang.String tableName,
                                              java.util.Map<java.lang.String,java.lang.Object> values)
Asynchronous version of updateRow

Parameters:
tableName -
values -
Returns:

deleteRowAsync

java.util.concurrent.Future<?> deleteRowAsync(java.lang.String tableName,
                                              java.lang.Object rowKey)
Asynchronous version of deleteRow

Parameters:
tableName -
rowKey -
Returns:

deleteRowsAsync

java.util.concurrent.Future<?> deleteRowsAsync(java.lang.String tableName,
                                               java.util.Set<java.lang.Object> rowKeys)
Asynchronous version of deleteRows

Parameters:
tableName -
rowKeys -
Returns:

deleteMatchingRowsAsync

java.util.concurrent.Future<?> deleteMatchingRowsAsync(java.lang.String tableName,
                                                       IPredicate predicate)
Asynchronous version of deleteRows

Parameters:
tableName -
predicate -
Returns:

getRowAsync

java.util.concurrent.Future<?> getRowAsync(java.lang.String tableName,
                                           java.lang.Object rowKey)
Asynchronous version of getRow

Parameters:
tableName -
rowKey -
Returns:

saveAsync

java.util.concurrent.Future<?> saveAsync(IResultSet resultSet)
Asynchronous version of save

Parameters:
resultSet -
Returns:

addListener

void addListener(java.lang.String tableName,
                 IStorageSourceListener listener)
Add a listener to the specified table. The listener is called when any modifications are made to the table. You can add the same listener instance to multiple tables, since the table name is included as a parameter in the listener methods.

Parameters:
tableName - The name of the table to listen for modifications
listener - The listener instance to call

removeListener

void removeListener(java.lang.String tableName,
                    IStorageSourceListener listener)
Remove a listener from the specified table. The listener should have been previously added to the table with addListener.

Parameters:
tableName - The name of the table with the listener
listener - The previously installed listener instance

notifyListeners

void notifyListeners(java.util.List<StorageSourceNotification> notifications)
This is logically a private method and should not be called by clients of this interface.

Parameters:
notifications - the notifications to dispatch