Anil noticed there was a race condition here where we might write 88/20188/6
authorEd Warnicke <hagbard@gmail.com>
Tue, 12 May 2015 22:27:11 +0000 (15:27 -0700)
committerEd Warnicke <hagbard@gmail.com>
Tue, 12 May 2015 23:35:09 +0000 (23:35 +0000)
an ovsdb-node to the operatational store before recording the
TransactInvoker we needed for people to be able to use it to write to
ovsdb.  This fixes that by imposing the order:

1)  Record the TransactInvoke for the ovsdb-node (internally)
2)  Write the ovsdb-node to OPER
3)  Register callbacks for monitors from ovsdb

Change-Id: I55202678521065b1a8c2f018a9f229b6be263a48
Signed-off-by: Ed Warnicke <hagbard@gmail.com>
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java

index 757ebd02479ff643a628e744b7bd9735a6ee7e77..bb7be5e01b8cb912c97c9d7254a0f0933b5ac90d 100644 (file)
@@ -68,8 +68,6 @@ public class OvsdbConnectionInstance implements OvsdbClient {
 
     public void init() {
         if ( this.callback == null) {
-            txInvoker.invoke(new OvsdbNodeCreateCommand(key, null,null));
-            this.callback = new OvsdbMonitorCallback(connectionInfo,txInvoker);
             try {
                 List<String> databases = getDatabases().get();
                 if (databases != null) {
@@ -77,6 +75,13 @@ public class OvsdbConnectionInstance implements OvsdbClient {
                         DatabaseSchema dbSchema = getSchema(database).get();
                         if (dbSchema != null) {
                             transactInvokers.put(dbSchema, new TransactInvokerImpl(this,dbSchema));
+                        }
+                    }
+                    txInvoker.invoke(new OvsdbNodeCreateCommand(key, null,null));
+                    this.callback = new OvsdbMonitorCallback(connectionInfo,txInvoker);
+                    for (String database : databases) {
+                        DatabaseSchema dbSchema = getSchema(database).get();
+                        if (dbSchema != null) {
                             monitorAllTables(database, dbSchema);
                         } else {
                             LOG.warn("No schema reported for database {} for key {}",database,connectionInfo);