Deprecating the Schma-dependent Plugin CRUD APIs and Introducing Schema-independent... 19/9619/4
authorMadhu Venugopal <mavenugo@gmail.com>
Mon, 4 Aug 2014 20:47:29 +0000 (13:47 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Mon, 4 Aug 2014 22:11:47 +0000 (15:11 -0700)
1. Deprecated all the existing insert/get/update/Delete methods that are Open_vSwitch Schema-dependent
2. Introduced equivalent methods with DatabaseName as an additional argument.
3. Introduced a new inssertTree method that has the capability to insert a Tree of rows with parent-child relationship
4. Changed the return types to make more sense (instead of the status types returned today)
5. Added a more generic Exception class which will be inherited by more specific exceptions as the need araises.

The implementation for these methods are not done yet.

Change-Id: Ia363574a4d71e301f7c4b1a2e3bac08de53c62f9
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
plugin/pom.xml
plugin/src/main/java/org/opendaylight/ovsdb/plugin/api/OvsdbConfigurationService.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/error/OvsdbPluginException.java [new file with mode: 0644]
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/ConfigurationServiceImpl.java

index a8dfc945ad3b5c9f2a0f2f7fa745d0d8ea36d22c..52a65a9a8db4f57a9c08bf3e9ff126cd8a641765 100755 (executable)
             <Export-Package>
               <!-- ToDo: Remove this line after the deprecated APIs have been removed -->
               org.opendaylight.ovsdb.plugin,
-              org.opendaylight.ovsdb.plugin.api
+              org.opendaylight.ovsdb.plugin.api,
+              org.opendaylight.ovsdb.plugin.error
             </Export-Package>
           </instructions>
           <manifestLocation>${project.basedir}/META-INF</manifestLocation>
index 7b81cc0689fc79c1d1ae8e527af1e3a8dd4ea8d3..9a59f75df6f8eb1c0cc2a68c7d1c9a8911fd8a64 100644 (file)
@@ -16,78 +16,202 @@ import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
+import org.opendaylight.ovsdb.plugin.error.OvsdbPluginException;
 
 public interface OvsdbConfigurationService {
 
     /**
-     * This version of insertRow is a short-term replacement for the older & now deprecated method of the same name.
+     * @deprecated This version of insertRow is a short-term replacement for the older & now deprecated method of the same name.
      * This API assumes an Open_vSwitch database Schema.
      *
+     * This API is replaced by
+     * {@link #insertRow(Node, String, String, String, Row<GenericTableSchema>) insertRow} and
+     * {@link #insertTree(Node, String, String, String, Row<GenericTableSchema>) insertTree}
+     *
      * @param node OVSDB Node
      * @param tableName Table on which the row is inserted
      * @param parentUuid UUID of the parent table to which this operation will result in attaching/mutating.
      * @param row Row of table Content to be inserted
      * @return UUID of the inserted Row
      */
+    @Deprecated
     public StatusWithUuid insertRow(Node node, String tableName, String parentUuid, Row<GenericTableSchema> row);
 
     /**
-     * This version of updateRow is a short-term replacement for the older & now deprecated method of the same name.
+     * insert a Row in a Table of a specified Database Schema.
+     *
+     * This method can insert just a single Row specified in the row parameter.
+     * But {@link #insertTree(Node, String, String, UUID, Row<GenericTableSchema>) insertTree}
+     * can insert a hierarchy of rows with parent-child relationship.
+     *
+     * @param node OVSDB Node
+     * @param databaseName Database Name that represents the Schema supported by the node.
+     * @param tableName Table on which the row is inserted
+     * @param parentUuid UUID of the parent table to which this operation will result in attaching/mutating.
+     * @param row Row of table Content to be inserted
+     * @throws OvsdbPluginException Any failure during the insert transaction will result in a specific exception.
+     * @return UUID of the inserted Row
+     */
+    public UUID insertRow(Node node, String databaseName, String tableName, UUID parentUuid, Row<GenericTableSchema> row) throws OvsdbPluginException;
+
+    /**
+     * inserts a Tree of Rows in multiple Tables that has parent-child relationships referenced through the OVSDB schema's refTable construct
+     *
+     * @param node OVSDB Node
+     * @param databaseName Database Name that represents the Schema supported by the node.
+     * @param tableName Table on which the row is inserted
+     * @param parentUuid UUID of the parent table to which this operation will result in attaching/mutating.
+     * @param row Row Tree with parent-child relationships via column of type refTable.
+     * @throws OvsdbPluginException Any failure during the insert transaction will result in a specific exception.
+     * @return Returns the row tree with the UUID of every inserted Row populated in the _uuid column of every row in the tree
+     */
+    public Row<GenericTableSchema> insertTree(Node node, String databaseName, String tableName, UUID parentUuid, Row<GenericTableSchema> row) throws OvsdbPluginException;
+
+    /**
+     * @deprecated This version of updateRow is a short-term replacement for the older & now deprecated method of the same name.
      * This API assumes an Open_vSwitch database Schema.
      *
+     * This API is replaced by
+     * {@link #updateRow(Node, String, String, UUID, Row<GenericTableSchema>, boolean) updateRow}
+     *
      * @param node OVSDB Node
      * @param tableName Table on which the row is Updated
      * @param parentUuid UUID of the parent row on which this operation might result in mutating.
      * @param rowUuid UUID of the row that is being updated
      * @param row Row of table Content to be Updated. Include just those columns that needs to be updated.
      */
+    @Deprecated
     public Status updateRow (Node node, String tableName, String parentUuid, String rowUuid, Row row);
 
     /**
-     * This version of deleteRow is a short-term replacement for the older & now deprecated method of the same name.
+     * update or mutate a Row in a Table of a specified Database Schema.
+     *
+     * @param node OVSDB Node
+     * @param databaseName Database Name that represents the Schema supported by the node.
+     * @param tableName Table on which the row is updated
+     * @param rowUuid UUID of the row being updated
+     * @param row Row of table Content to be updated
+     * @param overwrite true will overwrite/replace the existing row (matching the rowUuid) with the passed row object.
+     *                  false will update the existing row (matching the rowUuid) using only the columns in the passed row object.
+     * @throws OvsdbPluginException Any failure during the update operation will result in a specific exception.
+     * @return Returns the entire Row after the update operation.
+     */
+    public Row<GenericTableSchema> updateRow(Node node, String databaseName, String tableName, UUID rowUuid,
+                            Row<GenericTableSchema> row, boolean overwrite) throws OvsdbPluginException;
+
+    /**
+     * @deprecated This version of deleteRow is a short-term replacement for the older & now deprecated method of the same name.
      * This API assumes an Open_vSwitch database Schema.
      *
+     * This API is replaced by {@link #deleteRow(Node, String, String, UUID) deleteRow}
+     *
+     * @param node OVSDB Node
+     * @param tableName Table on which the row is Updated
+     * @param rowUuid UUID of the row that is being deleted
+     */
+    @Deprecated
+    public Status deleteRow (Node node, String tableName, String rowUuid);
+
+    /**
+     * update or mutate a Row in a Table of a specified Database Schema.
+     *
      * @param node OVSDB Node
+     * @param databaseName Database Name that represents the Schema supported by the node.
      * @param tableName Table on which the row is Updated
      * @param rowUuid UUID of the row that is being deleted
+     * @throws OvsdbPluginException Any failure during the delete operation will result in a specific exception.
      */
 
-    public Status deleteRow (Node node, String tableName, String rowUUID);
+    public void deleteRow (Node node, String databaseName, String tableName, UUID rowUuid) throws OvsdbPluginException;
 
     /**
-     * This version of getRow is a short-term replacement for the older & now deprecated method of the same name.
+     * @deprecated This version of getRow is a short-term replacement for the older & now deprecated method of the same name.
      * This API assumes an Open_vSwitch database Schema.
      *
+     * This API is replaced by {@link #getRow(Node, String, String, UUID) getRow}
+     *
      * @param node OVSDB Node
      * @param tableName Table Name
      * @param rowUuid UUID of the row being queried
      * @return a row with a list of Column data that corresponds to an unique Row-identifier called uuid in a given table.
      */
-
+    @Deprecated
     public Row getRow(Node node, String tableName, String uuid);
 
     /**
-     * This version of getRows is a short-term replacement for the older & now deprecated method of the same name.
+     * Returns a Row from a table for the specified uuid.
+     *
+     * @param node OVSDB Node
+     * @param databaseName Database Name that represents the Schema supported by the node.
+     * @param tableName Table Name
+     * @param uuid UUID of the row being queried
+     * @throws OvsdbPluginException Any failure during the get operation will result in a specific exception.
+     * @return a row with a list of Column data that corresponds to an unique Row-identifier called uuid in a given table.
+     */
+    public Row<GenericTableSchema> getRow(Node node, String databaseName, String tableName, UUID uuid) throws OvsdbPluginException;
+
+    /**
+     * @Deprecated This version of getRows is a short-term replacement for the older & now deprecated method of the same name.
      * This API assumes an Open_vSwitch database Schema.
      *
+     * This API is replaced by
+     * {@link #getRows(Node, String, String) getRows} and {@link #getRows(Node, String, String, String) getRows}
+     *
      * @param node OVSDB Node
      * @param tableName Table Name
      * @return List of rows that makes the entire Table.
      */
-
+    @Deprecated
     public ConcurrentMap<String, Row> getRows(Node node, String tableName);
 
     /**
-     * Returns all the Tables in a given Ndoe.
+     * Returns all rows of a table.
+     *
+     * @param node OVSDB Node
+     * @param databaseName Database Name that represents the Schema supported by the node.
+     * @param tableName Table Name
+     * @throws OvsdbPluginException Any failure during the get operation will result in a specific exception.
+     * @return Map of rows to its UUID that makes the entire Table.
+     */
+    public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node, String databaseName, String tableName) throws OvsdbPluginException;
+
+    /**
+     * Returns all rows of a table filtered by query string.
+     *
+     * @param node OVSDB Node
+     * @param databaseName Database Name that represents the Schema supported by the node.
+     * @param tableName Table Name
+     * @param fiqlQuery FIQL style String Query {@link http://tools.ietf.org/html/draft-nottingham-atompub-fiql-00} to filter rows
+     * @throws OvsdbPluginException Any failure during the get operation will result in a specific exception.
+     * @return Map of rows to its UUID that makes the entire Table.
+     */
+    public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node, String databaseName, String tableName, String fiqlQuery) throws OvsdbPluginException;
+
+    /**
+     * @Deprecated Returns all the Tables in a given Ndoe.
      * This API assumes an Open_vSwitch database Schema.
      *
+     * This API is replaced by
+     * {@link #getTables(Node, String) getTables}
      * @param node OVSDB node
      * @return List of Table Names that make up Open_vSwitch schema.
      */
+    @Deprecated
     public List<String> getTables(Node node);
 
+    /**
+     * Returns all the Tables in a given Node.
+     *
+     * @param node OVSDB node
+     * @param databaseName Database Name that represents the Schema supported by the node.
+     * @throws OvsdbPluginException Any failure during the get operation will result in a specific exception.
+     * @return List of Table Names that make up the schema represented by the databaseName
+     */
+    public List<String> getTables(Node node, String databaseName) throws OvsdbPluginException;
+
     /**
      * setOFController is a convenience method used by existing applications to setup Openflow Controller on
      * a Open_vSwitch Bridge.
diff --git a/plugin/src/main/java/org/opendaylight/ovsdb/plugin/error/OvsdbPluginException.java b/plugin/src/main/java/org/opendaylight/ovsdb/plugin/error/OvsdbPluginException.java
new file mode 100644 (file)
index 0000000..199047e
--- /dev/null
@@ -0,0 +1,11 @@
+package org.opendaylight.ovsdb.plugin.error;
+
+public class OvsdbPluginException extends RuntimeException {
+    public OvsdbPluginException(String message){
+        super(message);
+    }
+
+    public OvsdbPluginException(String message, Throwable cause){
+        super(message, cause);
+    }
+}
index 57be21b91f92f8e7a80ed66d069541bae383e4b5..63c57e2fbaab81f45daf145a85022a6132ebc8fd 100644 (file)
@@ -51,10 +51,11 @@ import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
 import org.opendaylight.ovsdb.plugin.OvsdbConfigService;
 import org.opendaylight.ovsdb.plugin.api.Connection;
 import org.opendaylight.ovsdb.plugin.api.OvsVswitchdSchemaConstants;
-import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
+import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
+import org.opendaylight.ovsdb.plugin.error.OvsdbPluginException;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.Controller;
 import org.opendaylight.ovsdb.schema.openvswitch.Interface;
@@ -1173,5 +1174,57 @@ public class ConfigurationServiceImpl implements IPluginInBridgeDomainConfigServ
         // TODO Auto-generated method stub
         return null;
     }
+
+    @Override
+    public UUID insertRow(Node node, String databaseName, String tableName,
+            UUID parentUuid, Row<GenericTableSchema> row)
+            throws OvsdbPluginException {
+        throw new OvsdbPluginException("Not implemented Yet");
+    }
+
+    @Override
+    public Row<GenericTableSchema> insertTree(Node node, String databaseName,
+            String tableName, UUID parentUuid, Row<GenericTableSchema> row)
+            throws OvsdbPluginException {
+        throw new OvsdbPluginException("Not implemented Yet");
+    }
+
+    @Override
+    public Row<GenericTableSchema> updateRow(Node node, String databaseName,
+            String tableName, UUID rowUuid, Row<GenericTableSchema> row,
+            boolean overwrite) throws OvsdbPluginException {
+        throw new OvsdbPluginException("Not implemented Yet");
+    }
+
+    @Override
+    public void deleteRow(Node node, String databaseName, String tableName,
+            UUID rowUuid) throws OvsdbPluginException {
+        throw new OvsdbPluginException("Not implemented Yet");
+
+    }
+
+    @Override
+    public Row<GenericTableSchema> getRow(Node node, String databaseName,
+            String tableName, UUID uuid) throws OvsdbPluginException {
+        throw new OvsdbPluginException("Not implemented Yet");
+    }
+
+    @Override
+    public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node,
+            String databaseName, String tableName) throws OvsdbPluginException {
+        throw new OvsdbPluginException("Not implemented Yet");
+    }
+
+    @Override
+    public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node,
+            String databaseName, String tableName, String fiqlQuery)
+            throws OvsdbPluginException {
+        throw new OvsdbPluginException("Not implemented Yet");
+    }
+
+    @Override
+    public List<String> getTables(Node node, String databaseName) throws OvsdbPluginException {
+        throw new OvsdbPluginException("Not implemented Yet");
+    }
 }