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>
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());
}
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());
/**
* 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.
}
@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>() {
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);
}
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
}
ovs = this.getTestConnection();
testGetDBs();
- dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get();
+ dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA).get();
}
@After
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);
/*
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;
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
}
ovs = getTestConnection();
testGetDBs();
- dbSchema = ovs.getSchema(HARDWARE_VTEP_SCHEMA, true).get();
+ dbSchema = ovs.getSchema(HARDWARE_VTEP_SCHEMA).get();
}
@After