Check the tables we want to monitor against the schema that we got from the node. 17/2317/1
authorHugo Trippaers <trippie@gmail.com>
Fri, 1 Nov 2013 15:57:18 +0000 (16:57 +0100)
committerHugo Trippaers <hugo@trippaers.nl>
Fri, 1 Nov 2013 17:06:11 +0000 (18:06 +0100)
The monitor can throw an error, so handle it.

As details is defined as being part of the error we can include it in the base response.

Change-Id: I950d36ff16eebdf1d46cf8047ec8dd620007aab6
Signed-off-by: Hugo Trippaers <trippie@gmail.com>
ovsdb/src/main/java/org/opendaylight/ovsdb/lib/message/Response.java
ovsdb/src/main/java/org/opendaylight/ovsdb/plugin/ConnectionService.java

index 1af341678b1d4e685f4a0c3b07c8f1d93af5ec02..23b5031783102d99b52c65a72eb01c513009a7f3 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.ovsdb.lib.message;
 
 public abstract class Response {
     Object error;
+    Object details;
 
     public Object getError() {
         return error;
@@ -10,4 +11,13 @@ public abstract class Response {
     public void setError(Object error) {
         this.error = error;
     }
+
+    public Object getDetails() {
+        return details;
+    }
+
+    public void setDetails(Object details) {
+        this.details = details;
+    }
+
 }
index f7753fe0c7ed30a8579d791b193bec45b2a3ed6d..59249a2b7cc50d3d224743cff7c55e3a6da758c8 100755 (executable)
@@ -215,11 +215,22 @@ public class ConnectionService implements IPluginInConnectionService, IConnectio
 
         MonitorRequestBuilder monitorReq = new MonitorRequestBuilder();
         for (Table<?> table : Tables.getTables()) {
-            monitorReq.monitor(table);
+            if (databaseSchema.getTables().keySet().contains(table.getTableName().getName())) {
+                monitorReq.monitor(table);
+            } else {
+                logger.warn("We know about table {} but it is not in the schema of {}", table.getTableName().getName(), connection.getNode().getNodeIDString());
+            }
         }
 
         ListenableFuture<TableUpdates> monResponse = connection.getRpc().monitor(monitorReq);
         TableUpdates updates = monResponse.get();
+        if (updates.getError() != null) {
+            logger.error("Error configuring monitor, error : {}, details : {}",
+                    updates.getError(),
+                    updates.getDetails());
+            /* FIXME: This should be cause for alarm */
+            throw new RuntimeException("Failed to setup a monitor in OVSDB");
+        }
         UpdateNotification monitor = new UpdateNotification();
         monitor.setUpdate(updates);
         this.update(connection.getNode(), monitor);