Removed the option to not-cache the database schema from the library. 13/8613/1
authorMadhu Venugopal <mavenugo@gmail.com>
Mon, 30 Jun 2014 16:24:17 +0000 (09:24 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Mon, 30 Jun 2014 18:34:14 +0000 (11:34 -0700)
There is no valid reason not to cache the database schema for a ovsdb connection once it is learnt once.
The schema can never change after the connection is established & hence having this dynamic capability is
unneccessary and causes unncessary API confusion.

Change-Id: If147d90a1070beaf85a3d7f9f7f844d73d53acb0
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/library/OvsdbLibraryIT.java
library/src/main/java/org/opendaylight/ovsdb/lib/OvsdbClient.java
library/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbClientImpl.java
library/src/test/java/org/opendaylight/ovsdb/lib/OvsdbClientTestIT.java
library/src/test/java/org/opendaylight/ovsdb/lib/OvsdbClientTestITTyped.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/ConnectionService.java
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/MonitorTestCases.java
schemas/hardware_vtep/src/test/java/org/opendaylight/ovsdb/schema/hardwarevtep/TypedHardwareVTepSchemaIT.java

index acd3c2560c0a99a4e643e46bfad119f04ae57d96..82820a6fb2938b74fefabdae2433ae01b088ebbd 100644 (file)
@@ -175,7 +175,7 @@ public class OvsdbLibraryIT extends OvsdbIntegrationTestBase {
         assertNotNull("Invalid Client. Check connection params", client);
         Thread.sleep(3000); // Wait for a few seconds to get the Schema exchange done
         if (isSchemaSupported(OPEN_VSWITCH_SCHEMA)) {
-            DatabaseSchema dbSchema = client.getSchema(OPEN_VSWITCH_SCHEMA, true).get();
+            DatabaseSchema dbSchema = client.getSchema(OPEN_VSWITCH_SCHEMA).get();
             assertNotNull(dbSchema);
             System.out.println(OPEN_VSWITCH_SCHEMA + " schema in "+ client.getConnectionInfo() +
                                                      " with Tables : " + dbSchema.getTables());
@@ -185,7 +185,7 @@ public class OvsdbLibraryIT extends OvsdbIntegrationTestBase {
         }
 
         if (isSchemaSupported(HARDWARE_VTEP)) {
-            DatabaseSchema dbSchema = client.getSchema(HARDWARE_VTEP, true).get();
+            DatabaseSchema dbSchema = client.getSchema(HARDWARE_VTEP).get();
             assertNotNull(dbSchema);
             System.out.println(HARDWARE_VTEP + " schema in "+ client.getConnectionInfo() +
                                                " with Tables : " + dbSchema.getTables());
index d6a9831f0e0ca8aa1cb7b5464a32100401447629..fc0232b209878c3a20c25470e8ccb58c2f1b69ed 100644 (file)
@@ -40,10 +40,9 @@ public interface OvsdbClient {
     /**
      * Asynchronously returns the schema object for a specific database
      * @param database name of the database schema
-     * @param cacheResult if the results be cached by this instance
      * @return DatabaseSchema future
      */
-    ListenableFuture<DatabaseSchema> getSchema(String database, boolean cacheResult);
+    ListenableFuture<DatabaseSchema> getSchema(String database);
 
     /**
      * Allows for a mini DSL way of collecting the transactions to be executed against the ovsdb instance.
index 59c12192205005536ee661f34134f956551a2bf7..9efc107999627071673be1a273fa9120c5bb03f2 100644 (file)
@@ -238,11 +238,11 @@ public class OvsdbClientImpl implements OvsdbClient {
     }
 
     @Override
-    public ListenableFuture<DatabaseSchema> getSchema(final String database, final boolean cacheResult) {
+    public ListenableFuture<DatabaseSchema> getSchema(final String database) {
 
         DatabaseSchema databaseSchema = schema.get(database);
 
-        if (databaseSchema == null || cacheResult) {
+        if (databaseSchema == null) {
             return Futures.transform(
                     getSchemaFromDevice(Lists.newArrayList(database)),
                     new Function<Map<String, DatabaseSchema>, DatabaseSchema>() {
@@ -251,17 +251,13 @@ public class OvsdbClientImpl implements OvsdbClient {
                             if (result.containsKey(database)) {
                                 DatabaseSchema s = result.get(database);
                                 s.populateInternallyGeneratedColumns();
-                                if (cacheResult) {
-                                    OvsdbClientImpl.this.schema.put(database, s);
-                                }
+                                OvsdbClientImpl.this.schema.put(database, s);
                                 return s;
                             } else {
                                 return null;
                             }
                         }
                     }, executorService);
-
-
         } else {
             return Futures.immediateFuture(databaseSchema);
         }
index 9dc8f9e0529d6952d3cf4cc515375bb0bc5a20ac..daf6fb8afd6ad3d8df1ae8d79c21a82a569c78a1 100644 (file)
@@ -348,7 +348,7 @@ public class OvsdbClientTestIT extends OvsdbTestBase {
         ovs = getTestConnection();
         System.out.println("Connection Info :" + ovs.getConnectionInfo().toString());
         testGetDBs();
-        dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get();
+        dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA).get();
     }
 
     @After
index 1b84df2b5798fe92c5b1b3efc2d4da6d7877f92d..8c86d44ed280d4b97692beaa774d59763cde0afc 100644 (file)
@@ -98,7 +98,7 @@ public class OvsdbClientTestITTyped extends OvsdbTestBase {
         }
         ovs = this.getTestConnection();
         testGetDBs();
-        dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get();
+        dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA).get();
     }
 
     @After
index c94b22b03f3e3a8c4d098a0fc8a379dfe14624d1..ba94d76bc240bf8cb3bb77564f5b6a7d9d5c40e3 100644 (file)
@@ -259,7 +259,7 @@ public class ConnectionService implements IPluginInConnectionService, IConnectio
         inventoryServiceInternal.addNode(connection.getNode(), props);
 
         List<String> dbNames = Arrays.asList(Open_vSwitch.NAME.getName());
-        ListenableFuture<DatabaseSchema> dbSchemaF = client.getSchema("Open_vSwitch", true);
+        ListenableFuture<DatabaseSchema> dbSchemaF = client.getSchema("Open_vSwitch");
         DatabaseSchema databaseSchema = dbSchemaF.get();
         inventoryServiceInternal.updateDatabaseSchema(connection.getNode(), databaseSchema);
 /*
index 59d2978091cb7b60304b61632a42ebfb208f8067..90b60e1b1d12e93b6803c3e4c972b30689198922 100644 (file)
 
 package org.opendaylight.ovsdb.schema.openvswitch;
 
-import com.google.common.collect.Lists;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
 import junit.framework.Assert;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.ovsdb.lib.MonitorCallBack;
@@ -30,23 +38,18 @@ import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
+import com.google.common.collect.Lists;
 
 public class MonitorTestCases extends OpenVswitchSchemaTestBase {
 
     Logger logger = LoggerFactory.getLogger(PortAndInterfaceTestCases.class);
     DatabaseSchema dbSchema = null;
 
+    @Override
     @Before
     public void setUp() throws ExecutionException, InterruptedException, TimeoutException, IOException {
         super.setUp();
-        dbSchema = this.ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get();
+        dbSchema = this.ovs.getSchema(OPEN_VSWITCH_SCHEMA).get();
     }
 
     @Test
index 41bd724681a3f2fe13a0bc697c2ee5e33bc42ad5..00a5077bebd8a1e031070887300c3ee85217dda2 100644 (file)
@@ -56,7 +56,7 @@ public class TypedHardwareVTepSchemaIT extends OvsdbTestBase {
         }
         ovs = getTestConnection();
         testGetDBs();
-        dbSchema = ovs.getSchema(HARDWARE_VTEP_SCHEMA, true).get();
+        dbSchema = ovs.getSchema(HARDWARE_VTEP_SCHEMA).get();
     }
 
     @After