Fixed issue with connection-info->{local-ip,local-port} not being stored 44/19444/1
authorEd Warnicke <hagbard@gmail.com>
Fri, 1 May 2015 17:58:52 +0000 (10:58 -0700)
committerEd Warnicke <hagbard@gmail.com>
Fri, 1 May 2015 17:58:52 +0000 (10:58 -0700)
Use of ConnectionInfo as a key in OvsdbConnectionManager
should only have remote{Ip,port} info... so:

1)  Introduced a method suppressLocalIpPort() to SouthboundMapper
    to strip localIp/Port info out of a ConnectionInfo if needed
2)  Insured that *all* gets to the clients map in OvsdbConnectionManager
    use that method before doing a lookup
3)  Insured that *all* puts to the clients map in OvsdbConnectionManager
    use that method before writing.

Also in passing fixed disconnect to just get the connectionInfo from
the ovsdbNode it has, instead of doing a convoluted dance and
removed the then no longer used createConnectionInfo(ovsdbNode) from
SouthboundMapper.

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

index c4ac089939616d8c89ebdb5678ecd4c632d98cef..cf108de0c860b0d4845481b7b1ba7286ca4bf8a4 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfoBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -54,7 +53,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
                 externalClient.getConnectionInfo().getRemotePort());
         ConnectionInfo key = SouthboundMapper.createConnectionInfo(externalClient);
         OvsdbConnectionInstance client = new OvsdbConnectionInstance(key,externalClient,txInvoker);
-        clients.put(key, client);
+        putConnectionInstance(key, client);
     }
 
     @Override
@@ -80,7 +79,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
     }
 
     public void disconnect(OvsdbNodeAugmentation ovsdbNode) throws UnknownHostException {
-        OvsdbClient client = clients.get(SouthboundMapper.createConnectionInfo(ovsdbNode));
+        OvsdbClient client = getConnectionInstance(ovsdbNode.getConnectionInfo());
         if (client != null) {
             client.disconnect();
         }
@@ -93,9 +92,14 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
         }
     }
 
+    private void putConnectionInstance(ConnectionInfo key,OvsdbConnectionInstance instance) {
+        ConnectionInfo connectionInfo = SouthboundMapper.suppressLocalIpPort(key);
+        clients.put(connectionInfo, instance);
+    }
+
     public OvsdbConnectionInstance getConnectionInstance(ConnectionInfo key) {
-        ConnectionInfoBuilder connectionInfoBuilder = new ConnectionInfoBuilder(key);
-        return clients.get(connectionInfoBuilder.build());
+        ConnectionInfo connectionInfo = SouthboundMapper.suppressLocalIpPort(key);
+        return clients.get(connectionInfo);
     }
 
     public OvsdbConnectionInstance getConnectionInstance(OvsdbBridgeAttributes mn) {
index a8ee454dca0cef3eded111fd9c3c12737c7995b9..4922e3c5085ad7aa4e9ef6feeeec426943b060e8 100644 (file)
@@ -349,13 +349,15 @@ public class SouthboundMapper {
         ConnectionInfoBuilder connectionInfoBuilder = new ConnectionInfoBuilder();
         connectionInfoBuilder.setRemoteIp(createIpAddress(client.getConnectionInfo().getRemoteAddress()));
         connectionInfoBuilder.setRemotePort(new PortNumber(client.getConnectionInfo().getRemotePort()));
+        connectionInfoBuilder.setLocalIp(createIpAddress(client.getConnectionInfo().getLocalAddress()));
+        connectionInfoBuilder.setLocalPort(new PortNumber(client.getConnectionInfo().getLocalPort()));
         return connectionInfoBuilder.build();
     }
 
-    public static ConnectionInfo createConnectionInfo(OvsdbNodeAugmentation ovsdbNodeAugmentation) {
+    public static ConnectionInfo suppressLocalIpPort(ConnectionInfo connectionInfo) {
         ConnectionInfoBuilder connectionInfoBuilder = new ConnectionInfoBuilder();
-        connectionInfoBuilder.setRemoteIp(ovsdbNodeAugmentation.getConnectionInfo().getRemoteIp());
-        connectionInfoBuilder.setRemotePort(ovsdbNodeAugmentation.getConnectionInfo().getRemotePort());
+        connectionInfoBuilder.setRemoteIp(connectionInfo.getRemoteIp());
+        connectionInfoBuilder.setRemotePort(connectionInfo.getRemotePort());
         return connectionInfoBuilder.build();
     }
 }