Merge "Add getTerminationPointOfBridge method to SouthboundUtils"
authorAnil Vishnoi <vishnoianil@gmail.com>
Fri, 29 Jul 2016 19:27:34 +0000 (19:27 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 29 Jul 2016 19:27:34 +0000 (19:27 +0000)
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListener.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/reconciliation/connection/ConnectionReconciliationTask.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcEndpoint.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataTreeChangeListener.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactInvokerImpl.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/connection/ConnectionReconciliationTask.java

index 98a6661381781531e7ba7a3f0d4890ffdb8ab5e3..471a67f9d00da6875f173f34a5d613ff7daf5ac0 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.ovsdb.hwvtepsouthbound;
 
 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
 
+import java.net.ConnectException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
@@ -158,7 +159,8 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
         LOG.trace("HwvtepConnectionManager exit disconnected client: {}", client);
     }
 
-    public OvsdbClient connect(InstanceIdentifier<Node> iid, HwvtepGlobalAugmentation hwvtepGlobal) throws UnknownHostException {
+    public OvsdbClient connect(InstanceIdentifier<Node> iid,
+                               HwvtepGlobalAugmentation hwvtepGlobal) throws UnknownHostException, ConnectException {
         LOG.info("Connecting to {}", HwvtepSouthboundUtil.connectionInfoToString(hwvtepGlobal.getConnectionInfo()));
         InetAddress ip = HwvtepSouthboundMapper.createInetAddress(hwvtepGlobal.getConnectionInfo().getRemoteIp());
         OvsdbClient client = OvsdbConnectionService.getService()
index ce6d6150697fd24dc13bbfb7186d9c8ad24aa43e..5cca754d4b009ab573164316b20c812ae5e8c2a5 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.ovsdb.hwvtepsouthbound;
 
+import java.net.ConnectException;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -134,7 +135,7 @@ public class HwvtepDataChangeListener implements ClusteredDataTreeChangeListener
                     } else {
                         try {
                             OvsdbClient client = hcm.connect(key, hwvtepGlobal);
-                        } catch (UnknownHostException e) {
+                        } catch (UnknownHostException | ConnectException e) {
                             LOG.warn("Failed to connect to HWVTEP node", e);
                         }
                     }
@@ -164,7 +165,7 @@ public class HwvtepDataChangeListener implements ClusteredDataTreeChangeListener
                             if (newClient == null) {
                                 hcm.reconcileConnection(key, hgUpdated);
                             }
-                        } catch (UnknownHostException e) {
+                        } catch (UnknownHostException | ConnectException e) {
                             LOG.warn("Failed to update connection on HWVTEP Node", e);
                         }
                     }
index ce02e8e48abb797a8ed45997ff04cdfeecdf8a94..476765ffe4e4cca191f2450054c74967ee0d3f2c 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.net.ConnectException;
 import java.net.UnknownHostException;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -59,7 +60,7 @@ public class ConnectionReconciliationTask extends ReconciliationTask {
                 LOG.warn("Connection retry({}) failed for {}.",
                         connectionAttempt.get(), hwvtepNode.getConnectionInfo());
             }
-        } catch (UnknownHostException e) {
+        } catch (UnknownHostException | ConnectException e) {
             LOG.warn("Connection retry({}) failed with exception. ",connectionAttempt.get(), e);
         }
         return result;
index fc7aacf296949aed72ce6578c91ea94c9d0cf53b..0b032e5df61286d949cb8e455064e2e67240bbb8 100644 (file)
@@ -195,6 +195,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
 
         OvsdbRPC rpc = factory.getClient(channel, OvsdbRPC.class);
         OvsdbClientImpl client = new OvsdbClientImpl(rpc, channel, type, socketConnType);
+        client.setConnectionPublished(true);
         connections.put(client, channel);
         ChannelFuture closeFuture = channel.closeFuture();
         closeFuture.addListener(new ChannelConnectionHandler(client));
index f4787d31b99d52ee51b433169b71bcef69a4987b..d9f6dfdb40c87e469999865b1c9c8619dc08c68e 100644 (file)
@@ -123,10 +123,13 @@ public class JsonRpcEndpoint {
                 FUTURE_REAPER_SERVICE.schedule(new Runnable() {
                     @Override
                     public void run() {
-                        if (sf.isDone() || sf.isCancelled()) {
-                            return;
+                        CallContext cc = methodContext.remove(request.getId());
+                        if ( cc != null) {
+                            if ( cc.getFuture().isDone() || cc.getFuture().isCancelled()) {
+                                return;
+                            }
+                            cc.getFuture().cancel(false);
                         }
-                        methodContext.remove(request.getId()).getFuture().cancel(false);
                     }
                 },REAPER_INTERVAL, TimeUnit.MILLISECONDS);
 
index 73f0004939c223fde1c867a081da21ee427f8a86..3a5067c7237ded66f2fd813b8c8bb77e3ee06133 100644 (file)
@@ -14,6 +14,8 @@ import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+
+import java.net.ConnectException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
@@ -186,7 +188,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
     }
 
     public OvsdbClient connect(InstanceIdentifier<Node> iid,
-            OvsdbNodeAugmentation ovsdbNode) throws UnknownHostException {
+            OvsdbNodeAugmentation ovsdbNode) throws UnknownHostException, ConnectException {
         LOG.info("Connecting to {}", SouthboundUtil.connectionInfoToString(ovsdbNode.getConnectionInfo()));
 
         // TODO handle case where we already have a connection
index 1acd7bed8166579a3e2f9a48f03e74be05d04f01..df93e4aac948d0c45306be42b69bef5a67eb0592 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.ovsdb.southbound;
 
+import java.net.ConnectException;
 import java.net.UnknownHostException;
 import java.util.Collection;
 import java.util.HashMap;
@@ -118,7 +119,7 @@ public class OvsdbDataTreeChangeListener implements ClusteredDataTreeChangeListe
                             InstanceIdentifier<Node> instanceIdentifier = change.getRootPath().getRootIdentifier();
                             cm.connect(instanceIdentifier, ovsdbNode);
                             LOG.info("OVSDB node has been connected: {}",ovsdbNode);
-                        } catch (UnknownHostException e) {
+                        } catch (UnknownHostException | ConnectException e) {
                             LOG.warn("Failed to connect to ovsdbNode", e);
                         }
                     }
@@ -164,7 +165,7 @@ public class OvsdbDataTreeChangeListener implements ClusteredDataTreeChangeListe
                                 cm.disconnect(ovsdbNodeModification.getDataBefore());
                                 cm.connect(change.getRootPath().getRootIdentifier(), ovsdbNodeModification
                                         .getDataAfter());
-                            } catch (UnknownHostException e) {
+                            } catch (UnknownHostException | ConnectException e) {
                                 LOG.warn("Error disconnecting from or connecting to ovsdbNode", e);
                             }
                         }
index 95ef4028de444dc844e1f84e3498ebdca05049ab..92ba86b2aff44d71cacdb2e30a74a512ca0bb34d 100644 (file)
@@ -55,13 +55,16 @@ public class TransactInvokerImpl implements TransactInvoker {
         LOG.debug("invoke: command: {}, tb: {}", command, tb);
         if (tb.getOperations().size() > 0) {
             try {
-                List<OperationResult> got = result.get();
-                LOG.debug("OVSDB transaction result: {}", got);
+                if (!result.isCancelled()) {
+                    List<OperationResult> got = result.get();
+                    LOG.debug("OVSDB transaction result: {}", got);
+                } else {
+                    LOG.debug("Operation task cancelled for transaction : {}", tb);
+                }
             } catch (InterruptedException | ExecutionException e) {
                 LOG.warn("Transact execution exception: ", e);
             }
             LOG.trace("invoke exit command: {}, tb: {}", command, tb);
         }
     }
-
 }
index 7e844f79b81b10a95e1bf4791d60ee8c6fb1b009..942e2e0cbefbdd9d81c631d51c114b65c4d458a2 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.ovsdb.southbound.reconciliation.connection;
 
+import java.net.ConnectException;
 import java.net.UnknownHostException;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
@@ -53,7 +54,7 @@ public class ConnectionReconciliationTask extends ReconciliationTask {
                 LOG.warn("Connection retry({}) failed for {}.",
                         connectionAttempt.get(), ovsdbNode.getConnectionInfo());
             }
-        } catch (UnknownHostException e) {
+        } catch (UnknownHostException | ConnectException e) {
             LOG.warn("Connection retry({}) failed with exception. ",connectionAttempt.get(), e);
         }
         return result;