From 59228a542e8f0b9140b2bead1ae8fab08061d23e Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Mon, 13 Apr 2015 18:31:33 -0700 Subject: [PATCH] Deprecated OvsdbClientKey and replaced with ConnectionInfo Since ConnectionInfo is basically the same info only better. Change-Id: Icbf8a8946f26ffd971b006595a6933e9ddf020ab Signed-off-by: Ed Warnicke --- .../ovsdb/southbound/OvsdbClientKey.java | 90 ------------------- .../southbound/OvsdbConnectionInstance.java | 33 +++---- .../southbound/OvsdbConnectionManager.java | 27 ++---- .../southbound/OvsdbDataChangeListener.java | 2 +- .../southbound/OvsdbMonitorCallback.java | 5 +- .../ovsdb/southbound/SouthboundMapper.java | 34 ++++--- .../md/AbstractTransactionCommand.java | 8 +- .../md/OpenVSwitchUpdateCommand.java | 8 +- .../md/OvsdbBridgeRemovedCommand.java | 8 +- .../md/OvsdbBridgeUpdateCommand.java | 19 ++-- .../md/OvsdbControllerRemovedCommand.java | 6 +- .../md/OvsdbControllerUpdateCommand.java | 7 +- .../md/OvsdbNodeCreateCommand.java | 9 +- .../md/OvsdbNodeRemoveCommand.java | 10 ++- .../md/OvsdbOperationalCommandAggregator.java | 4 +- .../md/OvsdbPortRemoveCommand.java | 6 +- .../md/OvsdbPortTransactionCommand.java | 4 +- .../md/OvsdbPortUpdateCommand.java | 6 +- .../ovsdb/southbound/OvsdbClientKeyTest.java | 22 ++--- 19 files changed, 110 insertions(+), 198 deletions(-) delete mode 100644 southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbClientKey.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 index ffff1be45..000000000 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbClientKey.java +++ /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 toInstanceIndentifier() { - return SouthboundMapper.createInstanceIdentifier(ipaddress,port); - } -} diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java index 896c5f69d..22abd55e7 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java @@ -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 transactInvokers = new HashMap(); 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 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; } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java index 7c92a7890..6c39dd435 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java @@ -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 clients - = new ConcurrentHashMap(); + Map clients + = new ConcurrentHashMap(); 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); } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataChangeListener.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataChangeListener.java index 983c97750..977625cdc 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataChangeListener.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataChangeListener.java @@ -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))); } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbMonitorCallback.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbMonitorCallback.java index 9871467ff..12be9e9eb 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbMonitorCallback.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbMonitorCallback.java @@ -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; } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java index 782dc1260..5d296e701 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java @@ -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 createInstanceIdentifier(OvsdbClientKey key,OvsdbBridgeName bridgeName) { + public static InstanceIdentifier createInstanceIdentifier(ConnectionInfo key,OvsdbBridgeName bridgeName) { return createInstanceIdentifier(createManagedNodeId(key, bridgeName)); } - public static InstanceIdentifier createInstanceIdentifier(OvsdbClientKey key,Bridge bridge) { + public static InstanceIdentifier createInstanceIdentifier(ConnectionInfo key,Bridge bridge) { String managedNodePathString = bridge .getExternalIdsColumn() .getData() @@ -147,8 +145,8 @@ public class SouthboundMapper { return nodeKey.getNodeId(); } - public static InstanceIdentifier createInstanceIdentifier(OvsdbClientKey key) { - return createInstanceIdentifier(key.getIp(), key.getPort()); + public static InstanceIdentifier createInstanceIdentifier(ConnectionInfo key) { + return createInstanceIdentifier(key.getRemoteIp(), key.getRemotePort()); } public static InstanceIdentifier 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(); + } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/AbstractTransactionCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/AbstractTransactionCommand.java index 7ab28cde9..06d2f1fa8 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/AbstractTransactionCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/AbstractTransactionCommand.java @@ -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; diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java index 90f07bc03..ee73984b8 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java @@ -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 entry : updatedOpenVSwitchRows.entrySet()) { OpenVSwitch openVSwitch = entry.getValue(); - final InstanceIdentifier nodePath = getKey() - .toInstanceIndentifier(); + final InstanceIdentifier nodePath = SouthboundMapper.createInstanceIdentifier(getConnectionInfo()); Optional 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()); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeRemovedCommand.java index 61c984d88..ea707ae9c 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeRemovedCommand.java @@ -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 removedRows = TyperUtils.extractRowsRemoved(Bridge.class, getUpdates(), getDbSchema()).values(); for (Bridge bridge : removedRows) { - InstanceIdentifier bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(), + InstanceIdentifier bridgeIid = SouthboundMapper.createInstanceIdentifier(getConnectionInfo(), bridge); - InstanceIdentifier mnIid = SouthboundMapper.createInstanceIdentifier(getKey()) + InstanceIdentifier 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 diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java index 41079fc7f..417cb0ba8 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java @@ -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 updatedBridgeRows; private Map 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 connectionIId = getKey().toInstanceIndentifier(); - Optional connection = readNode(transaction, getKey().toInstanceIndentifier()); + final InstanceIdentifier connectionIId = SouthboundMapper.createInstanceIdentifier(getConnectionInfo()); + Optional 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 bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(),bridge); + InstanceIdentifier 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 managedBridges = new ArrayList(); - InstanceIdentifier bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(),bridge); + InstanceIdentifier 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 bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(),bridge); + InstanceIdentifier 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 connectionNodePath = getKey().toInstanceIndentifier(); + InstanceIdentifier connectionNodePath = SouthboundMapper.createInstanceIdentifier(getConnectionInfo()); ovsdbBridgeAugmentationBuilder.setManagedBy(new OvsdbNodeRef(connectionNodePath)); } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerRemovedCommand.java index 484375d0e..64f489ede 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerRemovedCommand.java @@ -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 removedControllerRows; private Map 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 bridgeIid = SouthboundMapper.createInstanceIdentifier(getKey(), bridge); + InstanceIdentifier bridgeIid = SouthboundMapper.createInstanceIdentifier(getConnectionInfo(), bridge); deleteControllers(transaction, controllerEntriesToRemove(bridgeIid,bridge)); } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerUpdateCommand.java index 7173d6a9d..3eb52a91a 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbControllerUpdateCommand.java @@ -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 updatedControllerRows; private Map 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 iid = SouthboundMapper.createInstanceIdentifier(getKey(), bridge) + InstanceIdentifier iid = + SouthboundMapper.createInstanceIdentifier(getConnectionInfo(), bridge) .augmentation(OvsdbBridgeAugmentation.class) .child(ControllerEntry.class,controllerEntry.getKey()); transaction.put(LogicalDatastoreType.OPERATIONAL, iid, controllerEntry); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeCreateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeCreateCommand.java index 5d8cc3218..13a087090 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeCreateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeCreateCommand.java @@ -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())); } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeRemoveCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeRemoveCommand.java index 57e048d81..918d1caf0 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeRemoveCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbNodeRemoveCommand.java @@ -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, ReadFailedException> ovsdbNodeFuture = transaction.read( - LogicalDatastoreType.OPERATIONAL, getKey().toInstanceIndentifier()); + LogicalDatastoreType.OPERATIONAL, SouthboundMapper.createInstanceIdentifier(getConnectionInfo())); Optional 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); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbOperationalCommandAggregator.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbOperationalCommandAggregator.java index 6d198e370..c04c5cf84 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbOperationalCommandAggregator.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbOperationalCommandAggregator.java @@ -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 commands = new ArrayList(); - 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)); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortRemoveCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortRemoveCommand.java index 0efa359cf..763ae27f9 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortRemoveCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortRemoveCommand.java @@ -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 nodePath = SouthboundMapper - .createInstanceIdentifier(getKey(), + .createInstanceIdentifier(getConnectionInfo(), new OvsdbBridgeName(bridgeName)).child( TerminationPoint.class, new TerminationPointKey(new TpId(portName))); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortTransactionCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortTransactionCommand.java index c71039fac..10d4dbfaa 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortTransactionCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortTransactionCommand.java @@ -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 diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java index 8a65497f9..293d1cb69 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java @@ -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 nodePath = SouthboundMapper .createInstanceIdentifier(bridgeId); Optional node = readNode(transaction, nodePath); diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbClientKeyTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbClientKeyTest.java index 21204902c..9a656e636 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbClientKeyTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbClientKeyTest.java @@ -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 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 -- 2.36.6