Deprecated OvsdbClientKey and replaced with ConnectionInfo 32/18232/2
authorEd Warnicke <eaw@cisco.com>
Tue, 14 Apr 2015 01:31:33 +0000 (18:31 -0700)
committerEd Warnicke <eaw@cisco.com>
Tue, 14 Apr 2015 02:57:24 +0000 (19:57 -0700)
Since ConnectionInfo is basically the same info only better.

Change-Id: Icbf8a8946f26ffd971b006595a6933e9ddf020ab
Signed-off-by: Ed Warnicke <eaw@cisco.com>
19 files changed:
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbClientKey.java [deleted file]
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataChangeListener.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbMonitorCallback.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/AbstractTransactionCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeCreateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeRemoveCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbOperationalCommandAggregator.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortRemoveCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortTransactionCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbClientKeyTest.java

diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbClientKey.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbClientKey.java
deleted file mode 100644 (file)
index ffff1be..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.ovsdb.southbound;
-
-import org.opendaylight.ovsdb.lib.OvsdbClient;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class OvsdbClientKey {
-    /*
-     * This class is immutable.  If you are in anyway changing its fields after
-     * creation, your are doing it wrong :)
-     */
-    private IpAddress ipaddress;
-    private PortNumber port;
-
-    OvsdbClientKey(ConnectionInfo connectionInfo) {
-        ipaddress = connectionInfo.getRemoteIp();
-        port = connectionInfo.getRemotePort();
-    }
-
-    public OvsdbClientKey(IpAddress ip, PortNumber port) {
-        this.ipaddress = ip;
-        this.port = port;
-    }
-
-    OvsdbClientKey(OvsdbClient client) {
-        ipaddress = SouthboundMapper.createIpAddress(client.getConnectionInfo().getRemoteAddress());
-        port = new PortNumber(client.getConnectionInfo().getRemotePort());
-    }
-
-    public IpAddress getIp() {
-        return ipaddress;
-    }
-
-    public PortNumber getPort() {
-        return port;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result
-                + ((ipaddress == null) ? 0 : ipaddress.hashCode());
-        result = prime * result + ((port == null) ? 0 : port.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        OvsdbClientKey other = (OvsdbClientKey) obj;
-        if (ipaddress == null) {
-            if (other.ipaddress != null) {
-                return false;
-            }
-        } else if (!ipaddress.equals(other.ipaddress)) {
-            return false;
-        }
-        if (port == null) {
-            if (other.port != null) {
-                return false;
-            }
-        } else if (!port.equals(other.port)) {
-            return false;
-        }
-        return true;
-    }
-
-    public InstanceIdentifier<Node> toInstanceIndentifier() {
-        return SouthboundMapper.createInstanceIdentifier(ipaddress,port);
-    }
-}
index 896c5f69d018cd6d47bbbadfea9a56513f8ebfdb..22abd55e798eed6ae769596a51e77b224d31869b 100644 (file)
@@ -37,6 +37,7 @@ import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactInvoker;
 import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactInvokerImpl;
 import org.opendaylight.ovsdb.southbound.transactions.md.OvsdbNodeCreateCommand;
 import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,13 +47,13 @@ import com.google.common.util.concurrent.ListenableFuture;
 public class OvsdbConnectionInstance implements OvsdbClient {
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbConnectionInstance.class);
     private OvsdbClient client;
-    private OvsdbClientKey key;
+    private ConnectionInfo connectionInfo;
     private TransactionInvoker txInvoker;
     private Map<DatabaseSchema,TransactInvoker> transactInvokers = new HashMap<DatabaseSchema,TransactInvoker>();
     private MonitorCallBack callback;
 
-    OvsdbConnectionInstance(OvsdbClientKey key,OvsdbClient client,TransactionInvoker txInvoker) {
-        this.key = key;
+    OvsdbConnectionInstance(ConnectionInfo key,OvsdbClient client,TransactionInvoker txInvoker) {
+        this.connectionInfo = key;
         this.client = client;
         this.txInvoker = txInvoker;
         txInvoker.invoke(new OvsdbNodeCreateCommand(key, null,null));
@@ -66,7 +67,7 @@ public class OvsdbConnectionInstance implements OvsdbClient {
     }
 
     private void registerCallBack() {
-        this.callback = new OvsdbMonitorCallback(key,txInvoker);
+        this.callback = new OvsdbMonitorCallback(connectionInfo,txInvoker);
         try {
             List<String> databases = getDatabases().get();
             if (databases != null) {
@@ -76,14 +77,14 @@ public class OvsdbConnectionInstance implements OvsdbClient {
                         transactInvokers.put(dbSchema, new TransactInvokerImpl(this,dbSchema));
                         monitorAllTables(database, dbSchema);
                     } else {
-                        LOG.warn("No schema reported for database {} for key {}",database,key);
+                        LOG.warn("No schema reported for database {} for key {}",database,connectionInfo);
                     }
                 }
             } else {
-                LOG.warn("No databases reported from {}",key);
+                LOG.warn("No databases reported from {}",connectionInfo);
             }
         } catch (InterruptedException | ExecutionException e) {
-            LOG.warn("Exception attempting to initialize {}: {}",key,e);
+            LOG.warn("Exception attempting to initialize {}: {}",connectionInfo,e);
         }
     }
 
@@ -102,7 +103,7 @@ public class OvsdbConnectionInstance implements OvsdbClient {
             }
             this.callback.update(monitor(dbSchema, monitorRequests, callback),dbSchema);
         } else {
-            LOG.warn("No tables for schema {} for database {} for key {}",dbSchema,database,key);
+            LOG.warn("No tables for schema {} for database {} for key {}",dbSchema,database,connectionInfo);
         }
     }
 
@@ -154,10 +155,6 @@ public class OvsdbConnectionInstance implements OvsdbClient {
         client.stopEchoService();
     }
 
-    public OvsdbConnectionInfo getConnectionInfo() {
-        return client.getConnectionInfo();
-    }
-
     public boolean isActive() {
         return client.isActive();
     }
@@ -184,11 +181,15 @@ public class OvsdbConnectionInstance implements OvsdbClient {
         return client.getTypedRowWrapper(klazz, row);
     }
 
-    public OvsdbClientKey getKey() {
-        return key;
+    public OvsdbConnectionInfo getConnectionInfo() {
+        return client.getConnectionInfo();
+    }
+
+    public ConnectionInfo getMDConnectionInfo() {
+        return connectionInfo;
     }
 
-    public void setKey(OvsdbClientKey key) {
-        this.key = key;
+    public void setMDConnectionInfo(ConnectionInfo key) {
+        this.connectionInfo = key;
     }
 }
index 7c92a78904b764ad3029d278fedfebefa39caffb..6c39dd435594109671fa5a11916e9746ddea7fde 100644 (file)
@@ -25,6 +25,7 @@ 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;
@@ -35,8 +36,8 @@ import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 
 public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoCloseable {
-    Map<OvsdbClientKey,OvsdbConnectionInstance> clients
-        = new ConcurrentHashMap<OvsdbClientKey,OvsdbConnectionInstance>();
+    Map<ConnectionInfo,OvsdbConnectionInstance> clients
+        = new ConcurrentHashMap<ConnectionInfo,OvsdbConnectionInstance>();
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbConnectionManager.class);
 
     private DataBroker db;
@@ -51,7 +52,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
     public void connected(final OvsdbClient externalClient) {
         LOG.info("OVSDB Connection from {}:{}",externalClient.getConnectionInfo().getRemoteAddress(),
                 externalClient.getConnectionInfo().getRemotePort());
-        OvsdbClientKey key = new OvsdbClientKey(externalClient);
+        ConnectionInfo key = SouthboundMapper.createConnectionInfo(externalClient);
         OvsdbConnectionInstance client = new OvsdbConnectionInstance(key,externalClient,txInvoker);
         clients.put(key, client);
     }
@@ -60,7 +61,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
     public void disconnected(OvsdbClient client) {
         LOG.info("OVSDB Disconnect from {}:{}",client.getConnectionInfo().getRemoteAddress(),
                 client.getConnectionInfo().getRemotePort());
-        OvsdbClientKey key = new OvsdbClientKey(client);
+        ConnectionInfo key = SouthboundMapper.createConnectionInfo(client);
         txInvoker.invoke(new OvsdbNodeRemoveCommand(key,null,null));
         clients.remove(key);
     }
@@ -79,9 +80,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
     }
 
     public void disconnect(OvsdbNodeAugmentation ovsdbNode) throws UnknownHostException {
-        OvsdbClientKey key = new OvsdbClientKey(ovsdbNode.getConnectionInfo().getRemoteIp(),
-                ovsdbNode.getConnectionInfo().getRemotePort());
-        OvsdbClient client = clients.get(key);
+        OvsdbClient client = clients.get(ovsdbNode.getConnectionInfo());
         if (client != null) {
             client.disconnect();
         }
@@ -94,13 +93,9 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
         }
     }
 
-    public OvsdbConnectionInstance getConnectionInstance(OvsdbClientKey key) {
-        return clients.get(key);
-    }
-
-    public OvsdbConnectionInstance getConnectionInstance(ConnectionInfo connectionInfo) {
-        Preconditions.checkNotNull(connectionInfo);
-        return getConnectionInstance(new OvsdbClientKey(connectionInfo));
+    public OvsdbConnectionInstance getConnectionInstance(ConnectionInfo key) {
+        ConnectionInfoBuilder connectionInfoBuilder = new ConnectionInfoBuilder(key);
+        return clients.get(connectionInfoBuilder.build());
     }
 
     public OvsdbConnectionInstance getConnectionInstance(OvsdbBridgeAttributes mn) {
@@ -145,10 +140,6 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
         }
     }
 
-    public OvsdbClient getClient(OvsdbClientKey key) {
-        return getConnectionInstance(key);
-    }
-
     public OvsdbClient getClient(ConnectionInfo connectionInfo) {
         return getConnectionInstance(connectionInfo);
     }
index 983c977509b2a17dd67b742a6cd62d250e47fe53..977625cdcaf14a14329e286013479328a05c9c8a 100644 (file)
@@ -79,7 +79,7 @@ public class OvsdbDataChangeListener implements DataChangeListener, AutoCloseabl
             connectionInstance.transact(new TransactCommandAggregator(
                     new BridgeOperationalState(db, changes),
                     new DataChangesManagedByOvsdbNodeEvent(
-                            SouthboundMapper.createInstanceIdentifier(connectionInstance.getKey()),
+                            SouthboundMapper.createInstanceIdentifier(connectionInstance.getMDConnectionInfo()),
                             changes)));
         }
     }
index 9871467fffefd3acbc6c7d37cc4b2a7201a6d5f9..12be9e9eb984b71775f7e81b71b41ab634f3cafc 100644 (file)
@@ -12,6 +12,7 @@ import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.southbound.transactions.md.OvsdbOperationalCommandAggregator;
 import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -19,9 +20,9 @@ public class OvsdbMonitorCallback implements MonitorCallBack {
 
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbMonitorCallback.class);
     private TransactionInvoker txInvoker;
-    private OvsdbClientKey key;
+    private ConnectionInfo key;
 
-    OvsdbMonitorCallback(OvsdbClientKey key,TransactionInvoker txInvoker) {
+    OvsdbMonitorCallback(ConnectionInfo key,TransactionInvoker txInvoker) {
         this.txInvoker = txInvoker;
         this.key = key;
     }
index 782dc1260525ab11cc54c4ff9d68e8e6c9a28a74..5d296e7019e3db82d3f443070e14394dbeef77f1 100644 (file)
@@ -43,6 +43,7 @@ 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.ovsdb.bridge.attributes.ControllerEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntryBuilder;
+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.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
@@ -69,23 +70,20 @@ public class SouthboundMapper {
         nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, createOvsdbAugmentation(client));
         return nodeBuilder.build();
     }
-    public static Node createNode(OvsdbClientKey key) {
+    public static Node createNode(ConnectionInfo key) {
         NodeBuilder nodeBuilder = new NodeBuilder();
-        nodeBuilder.setNodeId(createNodeId(key.getIp(),key.getPort()));
+        nodeBuilder.setNodeId(createNodeId(key.getRemoteIp(),key.getRemotePort()));
         nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, createOvsdbAugmentation(key));
         return nodeBuilder.build();
     }
 
     public static OvsdbNodeAugmentation createOvsdbAugmentation(OvsdbClient client) {
-        return createOvsdbAugmentation(new OvsdbClientKey(client));
+        return createOvsdbAugmentation(createConnectionInfo(client));
     }
 
-    public static OvsdbNodeAugmentation createOvsdbAugmentation(OvsdbClientKey key) {
+    public static OvsdbNodeAugmentation createOvsdbAugmentation(ConnectionInfo key) {
         OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = new OvsdbNodeAugmentationBuilder();
-        ConnectionInfoBuilder ciBuilder = new ConnectionInfoBuilder();
-        ciBuilder.setRemoteIp(key.getIp());
-        ciBuilder.setRemotePort(key.getPort());
-        ovsdbNodeBuilder.setConnectionInfo(ciBuilder.build());
+        ovsdbNodeBuilder.setConnectionInfo(key);
         return ovsdbNodeBuilder.build();
     }
 
@@ -122,11 +120,11 @@ public class SouthboundMapper {
         return nodePath;
     }
 
-    public static InstanceIdentifier<Node> createInstanceIdentifier(OvsdbClientKey key,OvsdbBridgeName bridgeName) {
+    public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key,OvsdbBridgeName bridgeName) {
         return createInstanceIdentifier(createManagedNodeId(key, bridgeName));
     }
 
-    public static InstanceIdentifier<Node> createInstanceIdentifier(OvsdbClientKey key,Bridge bridge) {
+    public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key,Bridge bridge) {
         String managedNodePathString = bridge
                 .getExternalIdsColumn()
                 .getData()
@@ -147,8 +145,8 @@ public class SouthboundMapper {
         return nodeKey.getNodeId();
     }
 
-    public static InstanceIdentifier<Node> createInstanceIdentifier(OvsdbClientKey key) {
-        return createInstanceIdentifier(key.getIp(), key.getPort());
+    public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key) {
+        return createInstanceIdentifier(key.getRemoteIp(), key.getRemotePort());
     }
 
     public static InstanceIdentifier<Node> createInstanceIdentifier(IpAddress ip, PortNumber port) {
@@ -175,8 +173,8 @@ public class SouthboundMapper {
                 bridgeName);
     }
 
-    public static NodeId createManagedNodeId(OvsdbClientKey key, OvsdbBridgeName bridgeName) {
-        return createManagedNodeId(key.getIp(),key.getPort(),bridgeName);
+    public static NodeId createManagedNodeId(ConnectionInfo key, OvsdbBridgeName bridgeName) {
+        return createManagedNodeId(key.getRemoteIp(),key.getRemotePort(),bridgeName);
     }
 
     public static NodeId createManagedNodeId(IpAddress ip, PortNumber port, OvsdbBridgeName bridgeName) {
@@ -341,4 +339,12 @@ public class SouthboundMapper {
     public static String getRandomUUID() {
         return "Random_" + java.util.UUID.randomUUID().toString().replace("-", "");
     }
+    public static ConnectionInfo createConnectionInfo(OvsdbClient client) {
+        ConnectionInfoBuilder connectionInfoBuilder = new ConnectionInfoBuilder();
+        connectionInfoBuilder.setRemoteIp(createIpAddress(client.getConnectionInfo().getRemoteAddress()));
+        connectionInfoBuilder.setLocalIp(createIpAddress(client.getConnectionInfo().getLocalAddress()));
+        connectionInfoBuilder.setRemotePort(new PortNumber(client.getConnectionInfo().getRemotePort()));
+        connectionInfoBuilder.setLocalPort(new PortNumber(client.getConnectionInfo().getLocalPort()));
+        return connectionInfoBuilder.build();
+    }
 }
index 7ab28cde90851f10b437cbd9a60af0dda6c79f4d..06d2f1fa8da86c0ab37e8d47831a95e2af021c63 100644 (file)
@@ -2,13 +2,13 @@ package org.opendaylight.ovsdb.southbound.transactions.md;
 
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
 
 public abstract class AbstractTransactionCommand implements TransactionCommand {
 
     private TableUpdates updates;
     private DatabaseSchema dbSchema;
-    private OvsdbClientKey key;
+    private ConnectionInfo key;
 
     public TableUpdates getUpdates() {
         return updates;
@@ -18,7 +18,7 @@ public abstract class AbstractTransactionCommand implements TransactionCommand {
         return dbSchema;
     }
 
-    public OvsdbClientKey getKey() {
+    public ConnectionInfo getConnectionInfo() {
         return key;
     }
 
@@ -26,7 +26,7 @@ public abstract class AbstractTransactionCommand implements TransactionCommand {
         // NO OP
     }
 
-    public AbstractTransactionCommand(OvsdbClientKey key,TableUpdates updates, DatabaseSchema dbSchema) {
+    public AbstractTransactionCommand(ConnectionInfo key,TableUpdates updates, DatabaseSchema dbSchema) {
         this.updates = updates;
         this.dbSchema = dbSchema;
         this.key = key;
index 90f07bc03ea97d869e245e4b554bba21b1d830a7..ee73984b80eacd0255bcd3fade42b4a09ae6351e 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 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.OvsdbNodeAugmentationBuilder;
@@ -48,7 +47,7 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand {
     private static final Logger LOG = LoggerFactory
             .getLogger(OpenVSwitchUpdateCommand.class);
 
-    public OpenVSwitchUpdateCommand(OvsdbClientKey key, TableUpdates updates,
+    public OpenVSwitchUpdateCommand(ConnectionInfo key, TableUpdates updates,
             DatabaseSchema dbSchema) {
         super(key, updates, dbSchema);
     }
@@ -61,8 +60,7 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand {
 
         for (Entry<UUID, OpenVSwitch> entry : updatedOpenVSwitchRows.entrySet()) {
             OpenVSwitch openVSwitch = entry.getValue();
-            final InstanceIdentifier<Node> nodePath = getKey()
-                    .toInstanceIndentifier();
+            final InstanceIdentifier<Node> nodePath = SouthboundMapper.createInstanceIdentifier(getConnectionInfo());
             Optional<Node> node = Optional.absent();
             try {
                 node = transaction.read(LogicalDatastoreType.OPERATIONAL,
@@ -73,7 +71,7 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand {
             if (node.isPresent()) {
                 LOG.debug("Node {} is present", node);
                 OvsdbNodeAugmentation ovsdbNode = SouthboundMapper
-                        .createOvsdbAugmentation(getKey());
+                        .createOvsdbAugmentation(getConnectionInfo());
                 OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = new OvsdbNodeAugmentationBuilder();
                 ovsdbNodeBuilder.setOvsVersion(openVSwitch.getVersion()
                         .toString());
index 61c984d88cb5c9ec3a941cbb66d76a5f473efdd0..ea707ae9c25681e2d2f36d3311498c59cf8fab18 100644 (file)
@@ -8,10 +8,10 @@ import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef;
 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.ManagedNodeEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntryKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
 public class OvsdbBridgeRemovedCommand extends AbstractTransactionCommand {
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbBridgeRemovedCommand.class);
 
-    public OvsdbBridgeRemovedCommand(OvsdbClientKey key, TableUpdates updates,
+    public OvsdbBridgeRemovedCommand(ConnectionInfo key, TableUpdates updates,
             DatabaseSchema dbSchema) {
         super(key,updates,dbSchema);
     }
@@ -32,9 +32,9 @@ public class OvsdbBridgeRemovedCommand extends AbstractTransactionCommand {
         Collection<Bridge> removedRows = TyperUtils.extractRowsRemoved(Bridge.class,
                 getUpdates(), getDbSchema()).values();
         for (Bridge bridge : removedRows) {
-            InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(),
+            InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getConnectionInfo(),
                     bridge);
-            InstanceIdentifier<ManagedNodeEntry> mnIid = SouthboundMapper.createInstanceIdentifier(getKey())
+            InstanceIdentifier<ManagedNodeEntry> mnIid = SouthboundMapper.createInstanceIdentifier(getConnectionInfo())
                     .augmentation(OvsdbNodeAugmentation.class)
                     .child(ManagedNodeEntry.class, new ManagedNodeEntryKey(new OvsdbBridgeRef(bridgeIid)));
             // TODO handle removal of reference to managed node from model
index 41079fc7f3d784059d51a97e499cf87d5bcb7ba1..417cb0ba8f88313a4dcc634b723ef8b807316d79 100644 (file)
@@ -14,7 +14,6 @@ import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
@@ -35,6 +34,7 @@ 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.ovsdb.bridge.attributes.BridgeOtherConfigsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntryKey;
+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.ManagedNodeEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
@@ -53,7 +53,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
     private Map<UUID,Bridge> updatedBridgeRows;
     private Map<UUID, Bridge> oldBridgeRows;
 
-    public OvsdbBridgeUpdateCommand(OvsdbClientKey key, TableUpdates updates,
+    public OvsdbBridgeUpdateCommand(ConnectionInfo key, TableUpdates updates,
             DatabaseSchema dbSchema) {
         super(key,updates,dbSchema);
         updatedBridgeRows = TyperUtils.extractRowsUpdated(Bridge.class, getUpdates(), getDbSchema());
@@ -69,8 +69,8 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
 
     private void updateBridge(ReadWriteTransaction transaction,
             Bridge bridge) {
-        final InstanceIdentifier<Node> connectionIId = getKey().toInstanceIndentifier();
-        Optional<Node> connection = readNode(transaction, getKey().toInstanceIndentifier());
+        final InstanceIdentifier<Node> connectionIId = SouthboundMapper.createInstanceIdentifier(getConnectionInfo());
+        Optional<Node> connection = readNode(transaction, connectionIId);
         if (connection.isPresent()) {
             LOG.debug("Connection {} is present",connection);
 
@@ -79,7 +79,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
             transaction.merge(LogicalDatastoreType.OPERATIONAL, connectionIId, connectionNode);
 
             // Update the bridge node with whatever data we are getting
-            InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(),bridge);
+            InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getConnectionInfo(),bridge);
             Node bridgeNode = buildBridgeNode(bridge);
             transaction.merge(LogicalDatastoreType.OPERATIONAL, bridgeIid, bridgeNode);
             deleteEntries(transaction, protocolEntriesToRemove(bridgeIid,bridge));
@@ -185,11 +185,12 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
             Bridge bridge) {
         //Update node with managed node reference
         NodeBuilder connectionNode = new NodeBuilder();
-        connectionNode.setNodeId(SouthboundMapper.createNodeId(getKey().getIp(),getKey().getPort()));
+        connectionNode.setNodeId(SouthboundMapper.createNodeId(getConnectionInfo().getRemoteIp(),
+                getConnectionInfo().getRemotePort()));
 
         OvsdbNodeAugmentationBuilder ovsdbConnectionAugmentationBuilder = new OvsdbNodeAugmentationBuilder();
         List<ManagedNodeEntry> managedBridges = new ArrayList<ManagedNodeEntry>();
-        InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(),bridge);
+        InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getConnectionInfo(),bridge);
         ManagedNodeEntry managedBridge = new ManagedNodeEntryBuilder().setBridgeRef(
                 new OvsdbBridgeRef(bridgeIid)).build();
         managedBridges.add(managedBridge);
@@ -203,7 +204,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
 
     private Node buildBridgeNode(Bridge bridge) {
         NodeBuilder bridgeNodeBuilder = new NodeBuilder();
-        InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(),bridge);
+        InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getConnectionInfo(),bridge);
         NodeId bridgeNodeId = SouthboundMapper.createManagedNodeId(bridgeIid);
         bridgeNodeBuilder.setNodeId(bridgeNodeId);
         OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
@@ -224,7 +225,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
     }
 
     private void setManagedBy(OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder) {
-        InstanceIdentifier<Node> connectionNodePath = getKey().toInstanceIndentifier();
+        InstanceIdentifier<Node> connectionNodePath = SouthboundMapper.createInstanceIdentifier(getConnectionInfo());
         ovsdbBridgeAugmentationBuilder.setManagedBy(new OvsdbNodeRef(connectionNodePath));
     }
 
index 484375d0e8f92e183088d747c565766f71057f42..64f489ede3e8bc469722a91d3447aa1294666a28 100644 (file)
@@ -19,12 +19,12 @@ import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.Controller;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 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.ovsdb.bridge.attributes.ControllerEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntryKey;
+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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -38,7 +38,7 @@ public class OvsdbControllerRemovedCommand extends AbstractTransactionCommand {
     private Map<UUID, Controller> removedControllerRows;
     private Map<UUID, Bridge> updatedBridgeRows;
 
-    public OvsdbControllerRemovedCommand(OvsdbClientKey key,
+    public OvsdbControllerRemovedCommand(ConnectionInfo key,
             TableUpdates updates, DatabaseSchema dbSchema) {
         super(key, updates, dbSchema);
         updatedBridgeRows = TyperUtils.extractRowsUpdated(Bridge.class, getUpdates(), getDbSchema());
@@ -50,7 +50,7 @@ public class OvsdbControllerRemovedCommand extends AbstractTransactionCommand {
     @Override
     public void execute(ReadWriteTransaction transaction) {
         for (Bridge bridge : updatedBridgeRows.values()) {
-            InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(), bridge);
+            InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getConnectionInfo(), bridge);
             deleteControllers(transaction, controllerEntriesToRemove(bridgeIid,bridge));
         }
     }
index 7173d6a9d03b18b3a0b6efc1913adfc285875319..3eb52a91a3003c5443dfa3ccefd63e2a0d23f22a 100644 (file)
@@ -17,10 +17,10 @@ import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.Controller;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 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.ovsdb.bridge.attributes.ControllerEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class OvsdbControllerUpdateCommand extends AbstractTransactionCommand {
@@ -30,7 +30,7 @@ public class OvsdbControllerUpdateCommand extends AbstractTransactionCommand {
     private Map<UUID, Controller> updatedControllerRows;
     private Map<UUID, Bridge> updatedBridgeRows;
 
-    public OvsdbControllerUpdateCommand(OvsdbClientKey key,
+    public OvsdbControllerUpdateCommand(ConnectionInfo key,
             TableUpdates updates, DatabaseSchema dbSchema) {
         super(key, updates, dbSchema);
         updatedBridgeRows = TyperUtils.extractRowsUpdated(Bridge.class, getUpdates(), getDbSchema());
@@ -48,7 +48,8 @@ public class OvsdbControllerUpdateCommand extends AbstractTransactionCommand {
 
     private void setController(ReadWriteTransaction transaction, Bridge bridge) {
         for (ControllerEntry controllerEntry: SouthboundMapper.createControllerEntries(bridge, updatedControllerRows)) {
-            InstanceIdentifier<ControllerEntry> iid = SouthboundMapper.createInstanceIdentifier(getKey(), bridge)
+            InstanceIdentifier<ControllerEntry> iid =
+                    SouthboundMapper.createInstanceIdentifier(getConnectionInfo(), bridge)
                     .augmentation(OvsdbBridgeAugmentation.class)
                     .child(ControllerEntry.class,controllerEntry.getKey());
             transaction.put(LogicalDatastoreType.OPERATIONAL, iid, controllerEntry);
index 5d8cc32180e6f9fc2c3c593c84572b6ab29a7f2b..13a0870900cecd96757dbc51e0643ab845900e65 100644 (file)
@@ -4,19 +4,20 @@ import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
 
 public class OvsdbNodeCreateCommand extends AbstractTransactionCommand {
 
-    public OvsdbNodeCreateCommand(OvsdbClientKey key,TableUpdates updates,DatabaseSchema dbSchema) {
+    public OvsdbNodeCreateCommand(ConnectionInfo key,TableUpdates updates,DatabaseSchema dbSchema) {
         super(key,updates,dbSchema);
     }
 
     @Override
     public void execute(ReadWriteTransaction transaction) {
-        transaction.put(LogicalDatastoreType.OPERATIONAL, getKey().toInstanceIndentifier(),
-                SouthboundMapper.createNode(getKey()));
+        transaction.put(LogicalDatastoreType.OPERATIONAL,
+                SouthboundMapper.createInstanceIdentifier(getConnectionInfo()),
+                SouthboundMapper.createNode(getConnectionInfo()));
     }
 
 }
index 57e048d816ac9dca9ba66747987b797b0ebd89bb..918d1caf0106fada87ba4afc4cc3b11a57c862bc 100644 (file)
@@ -5,8 +5,9 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
+import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 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.ManagedNodeEntry;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.slf4j.Logger;
@@ -18,14 +19,14 @@ import com.google.common.util.concurrent.CheckedFuture;
 public class OvsdbNodeRemoveCommand extends AbstractTransactionCommand {
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbNodeRemoveCommand.class);
 
-    public OvsdbNodeRemoveCommand(OvsdbClientKey key,TableUpdates updates,DatabaseSchema dbSchema) {
+    public OvsdbNodeRemoveCommand(ConnectionInfo key,TableUpdates updates,DatabaseSchema dbSchema) {
         super(key,updates,dbSchema);
     }
 
     @Override
     public void execute(ReadWriteTransaction transaction) {
         CheckedFuture<Optional<Node>, ReadFailedException> ovsdbNodeFuture = transaction.read(
-                LogicalDatastoreType.OPERATIONAL, getKey().toInstanceIndentifier());
+                LogicalDatastoreType.OPERATIONAL, SouthboundMapper.createInstanceIdentifier(getConnectionInfo()));
         Optional<Node> ovsdbNodeOptional;
         try {
             ovsdbNodeOptional = ovsdbNodeFuture.get();
@@ -37,7 +38,8 @@ public class OvsdbNodeRemoveCommand extends AbstractTransactionCommand {
                         transaction.delete(LogicalDatastoreType.OPERATIONAL, managedNode.getBridgeRef().getValue());
                     }
                 }
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, getKey().toInstanceIndentifier());
+                transaction.delete(LogicalDatastoreType.OPERATIONAL,
+                        SouthboundMapper.createInstanceIdentifier(getConnectionInfo()));
             }
         } catch (Exception e) {
             LOG.warn("Failure to delete ovsdbNode {}",e);
index 6d198e3706638d1b3c9feed5441567c303d7838e..c04c5cf84f08ccde6ce174d945df1b9fbcbaac5d 100644 (file)
@@ -6,14 +6,14 @@ import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
 
 public class OvsdbOperationalCommandAggregator implements TransactionCommand {
 
 
     private List<TransactionCommand> commands = new ArrayList<TransactionCommand>();
 
-    public OvsdbOperationalCommandAggregator(OvsdbClientKey key,TableUpdates updates, DatabaseSchema dbSchema) {
+    public OvsdbOperationalCommandAggregator(ConnectionInfo key,TableUpdates updates, DatabaseSchema dbSchema) {
         commands.add(new OvsdbBridgeUpdateCommand(key, updates,  dbSchema));
         commands.add(new OvsdbBridgeRemovedCommand(key, updates,  dbSchema));
         commands.add(new OvsdbControllerUpdateCommand(key, updates,  dbSchema));
index 0efa359cf2d8edf2a9f0d18446b9d5a3f5739763..763ae27f91227f465e39df9c50b146154d9ba4c2 100644 (file)
@@ -16,16 +16,16 @@ import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Port;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeName;
+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.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class OvsdbPortRemoveCommand extends AbstractTransactionCommand {
-    public OvsdbPortRemoveCommand(OvsdbClientKey key, TableUpdates updates,
+    public OvsdbPortRemoveCommand(ConnectionInfo key, TableUpdates updates,
             DatabaseSchema dbSchema) {
         super(key, updates, dbSchema);
     }
@@ -43,7 +43,7 @@ public class OvsdbPortRemoveCommand extends AbstractTransactionCommand {
             for (Port port : portRemovedRows) {
                 portName = port.getName();
                 final InstanceIdentifier<TerminationPoint> nodePath = SouthboundMapper
-                        .createInstanceIdentifier(getKey(),
+                        .createInstanceIdentifier(getConnectionInfo(),
                                 new OvsdbBridgeName(bridgeName)).child(
                                 TerminationPoint.class,
                                 new TerminationPointKey(new TpId(portName)));
index c71039fac664288728a014ab262546eb6f01c0a7..10d4dbfaa0bc30aa3464173f9c29aa016f17d78e 100644 (file)
@@ -3,11 +3,11 @@ package org.opendaylight.ovsdb.southbound.transactions.md;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
 
 public class OvsdbPortTransactionCommand extends AbstractTransactionCommand {
 
-    public OvsdbPortTransactionCommand(OvsdbClientKey key,
+    public OvsdbPortTransactionCommand(ConnectionInfo key,
             TableUpdates updates, DatabaseSchema dbSchema) {
         super(key, updates, dbSchema);
         // TODO Auto-generated constructor stub
index 8a65497f934ff90948691711ee966d905510740c..293d1cb69e3524d68e290fca31e5a9fb4309b77d 100644 (file)
@@ -27,7 +27,6 @@ import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.Interface;
 import org.opendaylight.ovsdb.schema.openvswitch.Port;
-import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
@@ -37,6 +36,7 @@ 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.OvsdbPortInterfaceAttributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
+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.port._interface.attributes.InterfaceExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIdsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigs;
@@ -65,7 +65,7 @@ import com.google.common.base.Optional;
 public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbPortUpdateCommand.class);
 
-    public OvsdbPortUpdateCommand(OvsdbClientKey key, TableUpdates updates,
+    public OvsdbPortUpdateCommand(ConnectionInfo key, TableUpdates updates,
             DatabaseSchema dbSchema) {
         super(key, updates, dbSchema);
     }
@@ -86,7 +86,7 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
                     if (portUUID.equals(port.getUuid())) {
                         bridgeName = bridge.getName();
                         NodeId bridgeId = SouthboundMapper.createManagedNodeId(
-                                getKey(), new OvsdbBridgeName(bridgeName));
+                                getConnectionInfo(), new OvsdbBridgeName(bridgeName));
                         final InstanceIdentifier<Node> nodePath = SouthboundMapper
                                 .createInstanceIdentifier(bridgeId);
                         Optional<Node> node = readNode(transaction, nodePath);
index 21204902c3ae50e32fc426cbd9d5139f8591314d..9a656e636227c00afa1f107ff7306f0094c50197 100644 (file)
@@ -13,7 +13,12 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+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.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
@@ -25,10 +30,6 @@ import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-
 /**
 * Unit test for {@link OvsdbClientKey}
 *
@@ -39,14 +40,17 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 public class OvsdbClientKeyTest {
     private static final String ADDRESS_STR = "192.168.120.1";
     private static final String PORT_STR = "6640";
-    private OvsdbClientKey ovsdbClientKeyTest;
+    private ConnectionInfo ovsdbClientKeyTest;
     private InstanceIdentifier<Node> nodePath;
 
     @Before
     public void setUp() {
         Ipv4Address ipv4 = new Ipv4Address(ADDRESS_STR);
         PortNumber port = new PortNumber(Integer.parseInt(PORT_STR));
-        ovsdbClientKeyTest = new OvsdbClientKey(new IpAddress(ipv4), port);
+        ConnectionInfoBuilder connectionInfoBuilder = new ConnectionInfoBuilder();
+        connectionInfoBuilder.setRemoteIp(new IpAddress(ipv4));
+        connectionInfoBuilder.setRemotePort(port);
+        ovsdbClientKeyTest = connectionInfoBuilder.build();
 
         String uriString = SouthboundConstants.OVSDB_URI_PREFIX + "://" + ADDRESS_STR + ":" + PORT_STR;
         Uri uri = new Uri(uriString);
@@ -61,10 +65,6 @@ public class OvsdbClientKeyTest {
     public void testToInstanceIndentifier() {
         Assert.assertNotNull("OvsdbClientKey should not be null", ovsdbClientKeyTest);
 
-        PowerMockito.mockStatic(SouthboundMapper.class);
-        PowerMockito.when(SouthboundMapper.createInstanceIdentifier(any(IpAddress.class), any(PortNumber.class)))
-                .thenReturn(nodePath);
-
-        Assert.assertEquals("Failed to return " + nodePath, nodePath, ovsdbClientKeyTest.toInstanceIndentifier());
+        Assert.assertEquals("Failed to return " + nodePath, nodePath, SouthboundMapper.createInstanceIdentifier(ovsdbClientKeyTest));
     }
 }
\ No newline at end of file