Merge "Upgrade ietf-{inet,yang}-types to 2013-07-15"
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / OvsdbConnectionInstance.java
index 69907f2b5b06b8caee9e9eec423cfb27bac05268..d29fabe972dec308e42381dd3d750f48e4281f76 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.ovsdb.southbound;
 
 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
 
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -16,9 +18,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
-
 import javax.annotation.Nonnull;
-
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
@@ -65,9 +65,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.ListenableFuture;
-
 public class OvsdbConnectionInstance implements OvsdbClient {
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbConnectionInstance.class);
     private OvsdbClient client;
@@ -118,8 +115,13 @@ public class OvsdbConnectionInstance implements OvsdbClient {
         }
     }
 
+    public ListenableFuture<List<OperationResult>> transact(
+            DatabaseSchema dbSchema, List<Operation> operations) {
+        return client.transact(dbSchema, operations);
+    }
+
     public void registerCallbacks() {
-        if ( this.callback == null) {
+        if (this.callback == null) {
             if (this.initialCreateData != null ) {
                 this.updateConnectionAttributes();
             }
@@ -144,12 +146,9 @@ public class OvsdbConnectionInstance implements OvsdbClient {
         if (transactInvokers == null) {
             try {
                 transactInvokers = new HashMap<>();
-                List<String> databases = getDatabases().get();
-                for (String database : databases) {
-                    DatabaseSchema dbSchema = getSchema(database).get();
-                    if (dbSchema != null) {
-                        transactInvokers.put(dbSchema, new TransactInvokerImpl(this,dbSchema));
-                    }
+                DatabaseSchema dbSchema = getSchema(SouthboundConstants.OPEN_V_SWITCH).get();
+                if (dbSchema != null) {
+                    transactInvokers.put(dbSchema, new TransactInvokerImpl(this,dbSchema));
                 }
             } catch (InterruptedException | ExecutionException e) {
                 LOG.warn("Exception attempting to createTransactionInvokers {}", connectionInfo, e);
@@ -171,7 +170,7 @@ public class OvsdbConnectionInstance implements OvsdbClient {
                 }
                 monitorRequests.add(monitorBuilder.with(new MonitorSelect(true, true, true, true)).build());
             }
-            this.callback.update(monitor(dbSchema, monitorRequests, callback),dbSchema);
+            this.callback.update(monitor(dbSchema, monitorRequests, callback), dbSchema);
         } else {
             LOG.warn("No tables for schema {} for database {} for key {}",dbSchema,database,connectionInfo);
         }
@@ -241,7 +240,7 @@ public class OvsdbConnectionInstance implements OvsdbClient {
             try {
                 List<OperationResult> got = result.get();
                 LOG.debug("OVSDB transaction result: {}", got);
-            } catch (Exception e) {
+            } catch (InterruptedException | ExecutionException e) {
                 LOG.warn("Transact execution exception: ", e);
             }
             LOG.trace("invoke exit tb: {}", txBuilder);
@@ -261,15 +260,17 @@ public class OvsdbConnectionInstance implements OvsdbClient {
         return client.transactBuilder(dbSchema);
     }
 
-    public ListenableFuture<List<OperationResult>> transact(
-            DatabaseSchema dbSchema, List<Operation> operations) {
-        return client.transact(dbSchema, operations);
+    @Override
+    public <E extends TableSchema<E>> TableUpdates monitor(
+            DatabaseSchema schema, List<MonitorRequest> monitorRequests,
+            MonitorHandle monitorHandle, MonitorCallBack callbackArgument) {
+        return null;
     }
 
     public <E extends TableSchema<E>> TableUpdates monitor(
             DatabaseSchema schema, List<MonitorRequest> monitorRequests,
-            MonitorCallBack callback) {
-        return client.monitor(schema, monitorRequests, callback);
+            MonitorCallBack callbackArgument) {
+        return client.monitor(schema, monitorRequests, callbackArgument);
     }
 
     public void cancelMonitor(MonitorHandle handler) {
@@ -351,13 +352,6 @@ public class OvsdbConnectionInstance implements OvsdbClient {
         this.instanceIdentifier = iid;
     }
 
-    @Override
-    public <E extends TableSchema<E>> TableUpdates monitor(
-            DatabaseSchema schema, List<MonitorRequest> monitorRequests,
-            MonitorHandle monitorHandle, MonitorCallBack callback) {
-        return null;
-    }
-
     public Entity getConnectedEntity() {
         return this.connectedEntity;
     }
@@ -394,12 +388,13 @@ public class OvsdbConnectionInstance implements OvsdbClient {
     public OvsdbNodeAugmentation getOvsdbNodeAugmentation() {
         return this.initialCreateData;
     }
+
     public void setOvsdbNodeAugmentation(OvsdbNodeAugmentation ovsdbNodeCreateData) {
         this.initialCreateData = ovsdbNodeCreateData;
     }
 
     @Override
-    public void echo() {
-        client.echo();
+    public ListenableFuture<List<String>> echo() {
+        return client.echo();
     }
 }