Adding generic GETDATA and GETCOLUMN proxy methods for _uuid and _version in TypedBas... 01/8201/1
authorMadhu Venugopal <mavenugo@gmail.com>
Fri, 20 Jun 2014 23:07:48 +0000 (16:07 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Fri, 20 Jun 2014 23:07:48 +0000 (16:07 -0700)
Please note that as per RFC 7047, the _uuid column will not be included for filter-less monitors and hence getUuid will not work if we are monitoring with no Filters.
But the TableUpdate contains the UUID for each of the update and a monitoring solution should manage that.
Please refer to TypedVSwitchdSchemaIT.java 's getOpenVSwitchTableUuid() for more info on how this is used.

Change-Id: Ia758ed726bbcfdb9fa0b6a7873f50831aed217e4
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
library/src/main/java/org/opendaylight/ovsdb/lib/schema/typed/TypedBaseTable.java
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TypedVSwitchdSchemaIT.java

index 19e1dc17be795e69d243a7f27c86377fc9028948..8a2b5ec001806942b8f06975c7480c8446588dc3 100644 (file)
@@ -9,9 +9,23 @@
  */
 package org.opendaylight.ovsdb.lib.schema.typed;
 
+import org.opendaylight.ovsdb.lib.notation.Column;
+import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 
 public interface TypedBaseTable {
     @TypedColumn(name="", method=MethodType.GETTABLESCHEMA)
     GenericTableSchema getSchema();
+
+    @TypedColumn(name="_uuid", method=MethodType.GETDATA)
+    public UUID getUuid();
+
+    @TypedColumn(name="_uuid", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, UUID> getUuidColumn();
+
+    @TypedColumn(name="_version", method=MethodType.GETDATA)
+    public UUID getVersion();
+
+    @TypedColumn(name="_version", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, UUID> getVersionColumn();
 }
index 39c7788b0564f5c07a6993f2a049ef8773e97492..01a8f0e8ef05dac64e53dfcbdd9902fb5ca79a7a 100644 (file)
@@ -60,7 +60,7 @@ public class TypedVSwitchdSchemaIT extends OvsdbTestBase {
 
     @Test
     public void testTypedBridgeOperations() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-        this.monitorBridge();
+        this.monitorTables();
         this.createTypedBridge();
         this.createTypedController();
     }
@@ -103,6 +103,8 @@ public class TypedVSwitchdSchemaIT extends OvsdbTestBase {
         Row bridgeRow = tableCache.get(bridge.getSchema().getName()).get(testBridgeUuid);
         Bridge monitoredBridge = ovs.getTypedRowWrapper(Bridge.class, bridgeRow);
         Assert.assertEquals(monitoredBridge.getNameColumn().getData(), bridge.getNameColumn().getData());
+        Assert.assertNotNull(monitoredBridge.getVersion());
+        Assert.assertNotNull(this.getOpenVSwitchTableUuid());
     }
 
     private void createTypedController() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
@@ -179,14 +181,27 @@ public class TypedVSwitchdSchemaIT extends OvsdbTestBase {
         Assert.assertTrue(OPEN_VSWITCH_SCHEMA+" schema is not supported by the switch", hasOpenVswitchSchema);
     }
 
-    public void monitorBridge() throws ExecutionException, InterruptedException, IOException {
+    private UUID getOpenVSwitchTableUuid() {
+        OpenVSwitch openVSwitch = ovs.getTypedRowWrapper(OpenVSwitch.class, null);
+        Map<UUID, Row> ovsTable = tableCache.get(openVSwitch.getSchema().getName());
+        if (ovsTable != null) {
+            if (ovsTable.keySet().size() >= 1) {
+                return (UUID)ovsTable.keySet().toArray()[0];
+            }
+        }
+        return null;
+    }
+
+    public void monitorTables() throws ExecutionException, InterruptedException, IOException {
         Assert.assertNotNull(dbSchema);
-        GenericTableSchema bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+        Bridge bridge = ovs.createTypedRowWrapper(Bridge.class);
+        OpenVSwitch openVSwitch = ovs.createTypedRowWrapper(OpenVSwitch.class);
 
         List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
-        MonitorRequestBuilder<GenericTableSchema> builder = MonitorRequestBuilder.builder(bridge);
-        monitorRequests.add(builder.with(new MonitorSelect(true, true, true, true))
-                                   .build());
+        MonitorRequestBuilder<GenericTableSchema> bridgeBuilder = MonitorRequestBuilder.builder(bridge.getSchema());
+        MonitorRequestBuilder<GenericTableSchema> ovsTableBuilder = MonitorRequestBuilder.builder(openVSwitch.getSchema());
+        monitorRequests.add(bridgeBuilder.with(new MonitorSelect(true, true, true, true)).build());
+        monitorRequests.add(ovsTableBuilder.with(new MonitorSelect(true, true, true, true)).build());
 
         MonitorHandle monitor = ovs.monitor(dbSchema, monitorRequests, new UpdateMonitor());
         Assert.assertNotNull(monitor);