Eliminate Duplicate Controller MD-SAL code 77/89577/7
authorChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Mon, 4 May 2020 07:27:33 +0000 (12:57 +0530)
committerChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Wed, 24 Jun 2020 08:33:24 +0000 (08:33 +0000)
With the MD-SAL migration done, there are now two almost identical
classes. Remove duplicate classes.

JIRA: OVSDB-495

Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Change-Id: Idc6dd7198fb99d5f97f056c84f20659734dd8094
Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
17 files changed:
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundUtil.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/HwvtepOperationalState.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/TransactUtils.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/HwvtepPhysicalPortUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-it/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/it/HwvtepSouthboundIT.java
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java
utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtils.java [deleted file]
utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtilsAsync.java [deleted file]
utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerNotifyingDataChangeListener.java [deleted file]
utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/NotifyingDataChangeListener.java
utils/mdsal-utils/src/test/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtilsAsyncTest.java [deleted file]
utils/mdsal-utils/src/test/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtilsTest.java [deleted file]
utils/ovsdb-it-utils/src/main/java/org/opendaylight/ovsdb/utils/ovsdb/it/utils/NodeInfo.java
utils/ovsdb-it-utils/src/main/java/org/opendaylight/ovsdb/utils/ovsdb/it/utils/OvsdbItUtils.java
utils/southbound-utils/src/main/java/org/opendaylight/ovsdb/utils/southbound/utils/SouthboundUtils.java

index aa01bf6b46d00c745e4532e7094ac246ee3580d5..e5ff0cddd8abc54b1716e7b15662de7d49fb53b4 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.mdsal.binding.api.ReadTransaction;
 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalSwitchAttributes;
@@ -162,7 +162,7 @@ public final class HwvtepSouthboundUtil {
             // below
             InstanceIdentifier<Node> path = (InstanceIdentifier<Node>) ref.getValue();
 
-            Optional<Node> optional = new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, path);
+            Optional<Node> optional = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, path);
             if (optional != null && optional.isPresent()) {
                 HwvtepGlobalAugmentation hwvtepNode = null;
                 Node node = optional.get();
index 1c320e53e59cecc133d097c2e4c7dc4f2b69fd22..75b9f1e2a878174a1c5777c01892446229a6af61 100644 (file)
@@ -27,7 +27,7 @@ import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepDeviceInfo;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil;
 import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.EncapsulationTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
@@ -102,7 +102,7 @@ public class HwvtepOperationalState {
         this.db = connectionInstance.getDataBroker();
         this.changes = null;
         transaction = connectionInstance.getDataBroker().newReadWriteTransaction();
-        Optional<Node> readNode = new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL,
+        Optional<Node> readNode = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL,
                 connectionInstance.getInstanceIdentifier());
         if (readNode.isPresent()) {
             operationalNodes.put(connectionInstance.getInstanceIdentifier(), readNode.get());
@@ -139,7 +139,7 @@ public class HwvtepOperationalState {
         if (nodeCreateOrUpdate != null) {
             transaction = db.newReadWriteTransaction();
             for (Entry<InstanceIdentifier<Node>, Node> entry: nodeCreateOrUpdate.entrySet()) {
-                Optional<Node> readNode = new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL,
+                Optional<Node> readNode = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL,
                         entry.getKey());
                 //add related globalNode or physicalSwitchNode to operationalNodes map
                 //for example, when creating physical port, logical switch is needed
@@ -156,7 +156,7 @@ public class HwvtepOperationalState {
                             InstanceIdentifier<Node> psNodeIid =
                                     (InstanceIdentifier<Node>) pswitch.getSwitchRef().getValue();
                             Optional<Node> psNode =
-                                new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, psNodeIid);
+                                new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, psNodeIid);
                             if (psNode.isPresent()) {
                                 operationalNodes.put(psNodeIid, psNode.get());
                             }
@@ -166,7 +166,7 @@ public class HwvtepOperationalState {
                         @SuppressWarnings("unchecked")
                         InstanceIdentifier<Node> hgNodeIid =
                                 (InstanceIdentifier<Node>) psAugmentation.getManagedBy().getValue();
-                        Optional<Node> hgNode = new ControllerMdsalUtils(db).readOptional(
+                        Optional<Node> hgNode = new MdsalUtils(db).readOptional(
                                 LogicalDatastoreType.OPERATIONAL, hgNodeIid);
                         if (hgNode.isPresent()) {
                             operationalNodes.put(hgNodeIid, hgNode.get());
@@ -224,7 +224,7 @@ public class HwvtepOperationalState {
     }
 
     public Optional<LogicalSwitches> getLogicalSwitches(final InstanceIdentifier<LogicalSwitches> iid) {
-        return new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
+        return new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
     }
 
     public Optional<Tunnels> getTunnels(final InstanceIdentifier<?> iid, final TunnelsKey tunnelsKey) {
@@ -240,7 +240,7 @@ public class HwvtepOperationalState {
     }
 
     public Optional<Tunnels> getTunnels(final InstanceIdentifier<Tunnels> iid) {
-        Optional<Tunnels> tunnels = new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
+        Optional<Tunnels> tunnels = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
         return tunnels;
     }
 
@@ -280,7 +280,7 @@ public class HwvtepOperationalState {
     public Optional<HwvtepPhysicalLocatorAugmentation>
             getPhysicalLocatorAugmentation(final InstanceIdentifier<TerminationPoint> iid) {
         Optional<TerminationPoint> tp =
-            new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
+            new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
         if (tp.isPresent()) {
             return Optional.ofNullable(tp.get().augmentation(HwvtepPhysicalLocatorAugmentation.class));
         }
@@ -349,7 +349,7 @@ public class HwvtepOperationalState {
     }
 
     public Optional<Acls> getAcls(final InstanceIdentifier<Acls> iid) {
-        Optional<Acls> acl = new ControllerMdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
+        Optional<Acls> acl = new MdsalUtils(db).readOptional(LogicalDatastoreType.OPERATIONAL, iid);
         return acl;
     }
 
index aa5baa5f2ea584346093e5b99006aa3c5eabc4ce..3c1331c795a57258548869100523b04220de84be 100644 (file)
@@ -31,7 +31,7 @@ import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 import org.opendaylight.ovsdb.schema.hardwarevtep.Global;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
 import org.opendaylight.ovsdb.schema.hardwarevtep.Tunnel;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.ManagementIps;
@@ -286,7 +286,7 @@ public class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
         } else {
             // TODO/FIXME: Not in operational, do we create a new one?
             LOG.warn("Trying to create tunnel without creating physical locators first");
-            Optional<TerminationPoint> confLocOptional = new ControllerMdsalUtils(getOperationalState().getDataBroker())
+            Optional<TerminationPoint> confLocOptional = new MdsalUtils(getOperationalState().getDataBroker())
                     .readOptional(LogicalDatastoreType.CONFIGURATION, iid);
             if (confLocOptional.isPresent()) {
                 locatorUUID = TransactUtils.createPhysicalLocator(transaction, getOperationalState(), iid);
index 854af78a7ad312a5f1dda1fcb0430ca2771b7162..9ba36305df17407f8676fdd405674be7fba6fe4d 100644 (file)
@@ -28,7 +28,7 @@ import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocatorSet;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.EncapsulationTypeVxlanOverIpv4;
@@ -238,7 +238,7 @@ public final class TransactUtils {
             return null;
         }
         LogicalSwitchUpdateCommand cmd = new LogicalSwitchUpdateCommand(operationalState, Collections.emptyList());
-        ControllerMdsalUtils mdsalUtils = new ControllerMdsalUtils(operationalState.getDataBroker());
+        MdsalUtils mdsalUtils = new MdsalUtils(operationalState.getDataBroker());
         LogicalSwitches ls = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, lswitchIid);
         if (ls != null) {
             cmd.updateLogicalSwitch(transaction, lswitchIid.firstIdentifierOf(Node.class), Lists.newArrayList(ls));
index b9d07c63d07d6a170b1d254ec37c2005c7eb659a..abf421214badbbce636827004610c6986d29178c 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsLocal;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
@@ -120,7 +120,7 @@ public class UcastMacsLocalUpdateCommand
                 locatorUuid = new UUID(locatorAugmentation.getPhysicalLocatorUuid().getValue());
             } else {
                 //if no, get it from config DS and create id
-                Optional<TerminationPoint> configLocatorOptional = new ControllerMdsalUtils(
+                Optional<TerminationPoint> configLocatorOptional = new MdsalUtils(
                         getOperationalState().getDataBroker()).readOptional(LogicalDatastoreType.CONFIGURATION, iid);
                 if (configLocatorOptional.isPresent()) {
                     HwvtepPhysicalLocatorAugmentation locatorAugmentation =
index 702ff75ddf0cdfee9e6b45d65a00edf6b6fc4ac2..70123b194454cb9e2031ff953baa80936fe23ffc 100644 (file)
@@ -34,7 +34,7 @@ import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalPort;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
@@ -70,7 +70,7 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
     private final Map<UUID, PhysicalPort> oldPPRows;
     private final Map<UUID, PhysicalSwitch> switchUpdatedRows;
     private final Set<UUID> skipReconciliationPorts;
-    private final ControllerMdsalUtils mdsalUtils;
+    private final MdsalUtils mdsalUtils;
 
     public HwvtepPhysicalPortUpdateCommand(final HwvtepConnectionInstance key, final TableUpdates updates,
             final DatabaseSchema dbSchema) {
@@ -79,7 +79,7 @@ public class HwvtepPhysicalPortUpdateCommand extends AbstractTransactionCommand
         oldPPRows = TyperUtils.extractRowsOld(PhysicalPort.class, getUpdates(), getDbSchema());
         switchUpdatedRows = TyperUtils.extractRowsUpdated(PhysicalSwitch.class, getUpdates(), getDbSchema());
         skipReconciliationPorts = new HashSet<>();
-        mdsalUtils = new ControllerMdsalUtils(key.getDataBroker());
+        mdsalUtils = new MdsalUtils(key.getDataBroker());
         for (Entry<UUID, PhysicalPort> portUpdateEntry : updatedPPRows.entrySet()) {
             Optional<InstanceIdentifier<Node>> switchIid = getTerminationPointSwitch(portUpdateEntry.getKey());
             if (switchIid.isPresent()) {
index 7ed4c6dd466a12cced906ff5bc58722877134d17..ebd43c08f68c5814a7f3881875d4de385e36fce6 100644 (file)
@@ -42,7 +42,7 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
 import org.opendaylight.ovsdb.utils.hwvtepsouthbound.utils.HwvtepSouthboundUtils;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalRef;
@@ -96,7 +96,7 @@ public class HwvtepSouthboundIT extends AbstractMdsalTestBase {
     private static final int OVSDB_UPDATE_TIMEOUT = 1000;
     private static final int OVSDB_ROUNDTRIP_TIMEOUT = 10000;
 
-    private static ControllerMdsalUtils mdsalUtils = null;
+    private static MdsalUtils mdsalUtils = null;
     private static boolean setup = false;
     private static int testMethodsRemaining;
     private static String addressStr;
@@ -268,7 +268,7 @@ public class HwvtepSouthboundIT extends AbstractMdsalTestBase {
             }
         }
 
-        mdsalUtils = new ControllerMdsalUtils(dataBroker);
+        mdsalUtils = new MdsalUtils(dataBroker);
         assertTrue("Did not find " + HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID.getValue(), getHwvtepTopology());
         final ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
         final InstanceIdentifier<Node> iid = HwvtepSouthboundUtils.createInstanceIdentifier(connectionInfo);
index 57e5996fcd6568d4d060f261a90973cc6d3b7011..270ec495280f7498a13b8563ba8b4693761231d3 100644 (file)
@@ -56,7 +56,7 @@ import org.opendaylight.ovsdb.lib.notation.Version;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.ovsdb.southbound.SouthboundUtil;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
@@ -196,7 +196,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     private static int portNumber;
     private static String connectionType;
     private static boolean setup = false;
-    private static ControllerMdsalUtils mdsalUtils = null;
+    private static MdsalUtils mdsalUtils = null;
     private static Node ovsdbNode;
     private static int testMethodsRemaining;
     private static Version schemaVersion;
@@ -444,7 +444,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             }
         }
 
-        mdsalUtils = new ControllerMdsalUtils(dataBroker);
+        mdsalUtils = new MdsalUtils(dataBroker);
         assertTrue("Did not find " + SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue(), getOvsdbTopology());
         final ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
         final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
diff --git a/utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtils.java b/utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtils.java
deleted file mode 100644 (file)
index b57b45c..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2015 Red Hat, 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.utils.mdsal.utils;
-
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class ControllerMdsalUtils {
-    private static final Logger LOG = LoggerFactory.getLogger(ControllerMdsalUtils.class);
-    private static int MDSAL_MAX_READ_TRIALS = Integer.getInteger("mdsalutil.max.tries", 30);
-    private static int MDSAL_READ_SLEEP_INTERVAL_MS = Integer.getInteger("mdsalutil.sleep.between.mdsal.reads", 1000);
-
-    private final DataBroker databroker;
-
-    /**
-     * Class constructor setting the data broker.
-     *
-     * @param dataBroker the {@link org.opendaylight.mdsal.binding.api.DataBroker}
-     */
-    public ControllerMdsalUtils(DataBroker dataBroker) {
-        this.databroker = dataBroker;
-    }
-
-    /**
-     * Executes delete as a blocking transaction.
-     *
-     * @param store {@link LogicalDatastoreType} which should be modified
-     * @param path {@link InstanceIdentifier} to read from
-     * @param <D> the data object type
-     * @return the result of the request
-     */
-    public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean delete(
-            final LogicalDatastoreType store, final InstanceIdentifier<D> path)  {
-        boolean result = false;
-        final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
-        transaction.delete(store, path);
-        FluentFuture<? extends @NonNull CommitInfo> future = transaction.commit();
-        try {
-            future.get();
-            result = true;
-        } catch (InterruptedException | ExecutionException e) {
-            LOG.warn("Failed to delete {} ", path, e);
-        }
-        return result;
-    }
-
-    /**
-     * Executes merge as a blocking transaction.
-     *
-     * @param logicalDatastoreType {@link LogicalDatastoreType} which should be modified
-     * @param path {@link InstanceIdentifier} for path to read
-     * @param <D> the data object type
-     * @return the result of the request
-     */
-    public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean merge(
-            final LogicalDatastoreType logicalDatastoreType, final InstanceIdentifier<D> path, D data)  {
-        boolean result = false;
-        final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
-        transaction.mergeParentStructureMerge(logicalDatastoreType, path, data);
-        FluentFuture<? extends @NonNull CommitInfo> future = transaction.commit();
-        try {
-            future.get();
-            result = true;
-        } catch (InterruptedException | ExecutionException e) {
-            LOG.warn("Failed to merge {} ", path, e);
-        }
-        return result;
-    }
-
-    /**
-     * Executes put as a blocking transaction.
-     *
-     * @param logicalDatastoreType {@link LogicalDatastoreType} which should be modified
-     * @param path {@link InstanceIdentifier} for path to read
-     * @param <D> the data object type
-     * @return the result of the request
-     */
-    public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean put(
-            final LogicalDatastoreType logicalDatastoreType, final InstanceIdentifier<D> path, D data)  {
-        boolean result = false;
-        final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
-        transaction.mergeParentStructurePut(logicalDatastoreType, path, data);
-        FluentFuture<? extends @NonNull CommitInfo> future = transaction.commit();
-        try {
-            future.get();
-            result = true;
-        } catch (InterruptedException | ExecutionException e) {
-            LOG.warn("Failed to put {} ", path, e);
-        }
-        return result;
-    }
-
-    /**
-     * Executes read as a blocking transaction.
-     *
-     * @param store {@link LogicalDatastoreType} to read
-     * @param path {@link InstanceIdentifier} for path to read
-     * @param <D> the data object type
-     * @return the result as the data object requested
-     */
-    public <D extends DataObject> D read(
-            final LogicalDatastoreType store, final InstanceIdentifier<? extends DataObject> path) {
-        Optional<D> optionalDataObject = readOptional(store, path);
-        if (optionalDataObject.isPresent()) {
-            return optionalDataObject.get();
-        }
-        LOG.debug("{}: Failed to read {}",
-                Thread.currentThread().getStackTrace()[1], path);
-        return null;
-    }
-
-    public <D extends DataObject> Optional<D> readOptional(
-            final LogicalDatastoreType store, final InstanceIdentifier<? extends DataObject> path)  {
-        int trialNo = 0;
-        ReadTransaction transaction = databroker.newReadOnlyTransaction();
-        do {
-            try {
-                Optional<D> result = transaction.read(store, (InstanceIdentifier<D>)path).get();
-                transaction.close();
-                return result;
-            } catch (InterruptedException | ExecutionException e) {
-                if (trialNo == 0) {
-                    logReadFailureError(path, " mdsal Read failed exception retrying the read after sleep");
-                }
-                try {
-                    transaction.close();
-                    Thread.sleep(MDSAL_READ_SLEEP_INTERVAL_MS);
-                    transaction = databroker.newReadOnlyTransaction();
-                } catch (InterruptedException e1) {
-                    logReadFailureError(path, " Sleep interrupted");
-                }
-            }
-        } while (trialNo++ < MDSAL_MAX_READ_TRIALS);
-        logReadFailureError(path, " All read trials exceeded");
-        return Optional.empty();
-    }
-
-    private <D extends org.opendaylight.yangtools.yang.binding.DataObject> void logReadFailureError(
-            InstanceIdentifier<D> path, String cause) {
-        LOG.error("{}: Failed to read {} Cause : {}", Thread.currentThread().getStackTrace()[2], path, cause);
-
-    }
-}
diff --git a/utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtilsAsync.java b/utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtilsAsync.java
deleted file mode 100644 (file)
index 624ece6..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2016 Inocybe Technologies 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.utils.mdsal.utils;
-
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.Optional;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class ControllerMdsalUtilsAsync {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ControllerMdsalUtilsAsync.class);
-    private final DataBroker databroker;
-
-    /**
-     * Class constructor setting the data broker.
-     *
-     * @param dataBroker the {@link DataBroker}
-     */
-    public ControllerMdsalUtilsAsync(final DataBroker dataBroker) {
-        this.databroker = dataBroker;
-    }
-
-    /**
-     * Executes delete as a non blocking transaction and returns the future.
-     *
-     * @param store
-     *            {@link LogicalDatastoreType} which should be modified
-     * @param path
-     *            {@link InstanceIdentifier} to read from
-     * @return The {@link FluentFuture} object to which you can assign a
-     *         callback
-     */
-    public <D extends DataObject> FluentFuture<? extends @NonNull CommitInfo> delete(
-                                    final LogicalDatastoreType store,
-                                    final InstanceIdentifier<D> path)  {
-        final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
-        transaction.delete(store, path);
-        return transaction.commit();
-    }
-
-    /**
-     * Executes delete as a non blocking transaction and assign a default callback.
-     *
-     * @param store
-     *            {@link LogicalDatastoreType} which should be modified
-     * @param path
-     *            {@link InstanceIdentifier} to read from
-     * @param operationDesc
-     *            A brief description of the operation to perform
-     */
-    public <D extends DataObject> void delete(
-                                    final LogicalDatastoreType store,
-                                    final InstanceIdentifier<D> path,
-                                    final String operationDesc)  {
-        assignDefaultCallback(delete(store, path), operationDesc);
-    }
-
-    /**
-     * Executes put as non blocking transaction and return the future.
-     *
-     * @param logicalDatastoreType
-     *            {@link LogicalDatastoreType} which should be modified
-     * @param path
-     *            {@link InstanceIdentifier} for path to read
-     * @param <D>
-     *            The data object type
-     * @return The {@link FluentFuture} object to which you can assign a
-     *         callback
-     */
-    public <D extends DataObject> FluentFuture<? extends @NonNull CommitInfo> put(
-                                        final LogicalDatastoreType logicalDatastoreType,
-                                        final InstanceIdentifier<D> path,
-                                        final D data)  {
-        final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
-        transaction.mergeParentStructurePut(logicalDatastoreType, path, data);
-        return transaction.commit();
-    }
-
-    /**
-     * Executes put as non blocking transaction and assign default callback.
-     *
-     * @param logicalDatastoreType
-     *            {@link LogicalDatastoreType} which should be modified
-     * @param path
-     *            {@link InstanceIdentifier} for path to read
-     * @param <D>
-     *            The data object type
-     * @param operationDesc
-     *            A brief description of the operation to perform
-     */
-    public <D extends DataObject> void put(
-                                        final LogicalDatastoreType logicalDatastoreType,
-                                        final InstanceIdentifier<D> path,
-                                        final D data,
-                                        final String operationDesc)  {
-        assignDefaultCallback(put(logicalDatastoreType, path, data), operationDesc);
-    }
-
-    /**
-     * Executes merge as non blocking transaction and return the future.
-     *
-     * @param logicalDatastoreType
-     *            {@link LogicalDatastoreType} which should be modified
-     * @param path
-     *            {@link InstanceIdentifier} for path to read
-     * @param <D>
-     *            The data object type
-     * @param withParent
-     *            Whether or not to create missing parent.
-     * @return The {@link FluentFuture} object to which you can assign a
-     *         callback
-     */
-    // FIXME: eliminate the boolean flag here to separate out the distinct code paths
-    public <D extends DataObject> FluentFuture<? extends @NonNull CommitInfo> merge(
-                                        final LogicalDatastoreType logicalDatastoreType,
-                                        final InstanceIdentifier<D> path,
-                                        final D data,
-                                        final boolean withParent)  {
-        final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
-        if (withParent) {
-            transaction.mergeParentStructureMerge(logicalDatastoreType, path, data);
-        } else {
-            transaction.merge(logicalDatastoreType, path, data);
-        }
-        return transaction.commit();
-    }
-
-    /**
-     * Executes merge as non blocking transaction and assign default callback.
-     *
-     * @param logicalDatastoreType
-     *            {@link LogicalDatastoreType} which should be modified
-     * @param path
-     *            {@link InstanceIdentifier} for path to read
-     * @param <D>
-     *            The data object type
-     * @param operationDesc
-     *            A brief description of the operation to perform
-     * @param withParent
-     *            Whether or not to create missing parent.
-     */
-    // FIXME: eliminate the boolean flag here to separate out the distinct code paths
-    public <D extends DataObject> void merge(
-                                        final LogicalDatastoreType logicalDatastoreType,
-                                        final InstanceIdentifier<D> path,
-                                        final D data,
-                                        final String operationDesc,
-                                        final boolean withParent)  {
-        assignDefaultCallback(merge(logicalDatastoreType, path, data, withParent), operationDesc);
-    }
-
-    /**
-     * Executes read as non blocking transaction and assign a default callback
-     * to close the transaction.
-     *
-     * @param store
-     *            {@link LogicalDatastoreType} to read
-     * @param path
-     *            {@link InstanceIdentifier} for path to read
-     * @param <D>
-     *            The data object type
-     * @return The {@link FluentFuture} object to which you can assign a
-     *         callback
-     */
-    public <D extends DataObject> FluentFuture<Optional<D>> read(
-                                        final LogicalDatastoreType store,
-                                        final InstanceIdentifier<D> path)  {
-        final ReadTransaction transaction = databroker.newReadOnlyTransaction();
-        final FluentFuture<Optional<D>> future = transaction.read(store, path);
-        final FutureCallback<Optional<D>> closeTransactionCallback = new FutureCallback<Optional<D>>() {
-            @Override
-            public void onSuccess(final Optional<D> result) {
-                transaction.close();
-            }
-
-            @Override
-            public void onFailure(final Throwable ex) {
-                transaction.close();
-            }
-        };
-        future.addCallback(closeTransactionCallback, MoreExecutors.directExecutor());
-        return future;
-    }
-
-    /**
-     * Assign a default callback to a {@link FluentFuture}. It will either log
-     * a message at DEBUG level if the transaction succeed, or will log at ERROR
-     * level and throw an {@link IllegalStateException} if the transaction
-     * failed.
-     *
-     * @param transaction
-     *            The transaction to commit.
-     * @param operationDesc
-     *            A description of the transaction to commit.
-     */
-    void assignDefaultCallback(final FluentFuture<? extends @NonNull CommitInfo> transactionFuture,
-            final String operationDesc) {
-        transactionFuture.addCallback(new FutureCallback<CommitInfo>() {
-            @Override
-            public void onSuccess(final CommitInfo result) {
-                LOG.debug("Transaction({}) SUCCESSFUL", operationDesc);
-            }
-
-            @Override
-            public void onFailure(final Throwable ex) {
-                LOG.error("Transaction({}) FAILED!", operationDesc, ex);
-                throw new IllegalStateException("  Transaction(" + operationDesc + ") not committed correctly", ex);
-            }
-        }, MoreExecutors.directExecutor());
-    }
-}
diff --git a/utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerNotifyingDataChangeListener.java b/utils/mdsal-utils/src/main/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerNotifyingDataChangeListener.java
deleted file mode 100644 (file)
index eca594e..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2016 Red Hat, 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.utils.mdsal.utils;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class provides methods for checking or waiting for various md-sal operations to complete.
- * Once an instance is created one must invoke the registerDataChangeListener method
- * with a DataBroker.
- */
-@Deprecated
-public class ControllerNotifyingDataChangeListener implements AutoCloseable, DataTreeChangeListener<DataObject> {
-    private static final Logger LOG = LoggerFactory.getLogger(ControllerNotifyingDataChangeListener.class);
-    private static final int RETRY_WAIT = 100;
-    private static final int MDSAL_TIMEOUT_OPERATIONAL = 10000;
-    private static final int MDSAL_TIMEOUT_CONFIG = 1000;
-
-    public static final int BIT_CREATE = 1;
-    public static final int BIT_UPDATE = 2;
-    public static final int BIT_DELETE = 4;
-    public static final int BIT_ALL = 7;
-
-    private final Set<InstanceIdentifier<?>> createdIids = ConcurrentHashMap.newKeySet();
-    private final Set<InstanceIdentifier<?>> removedIids = ConcurrentHashMap.newKeySet();
-    private final Set<InstanceIdentifier<?>> updatedIids = ConcurrentHashMap.newKeySet();
-    private final List<ControllerNotifyingDataChangeListener> waitList;
-    private ListenerRegistration<?> listenerRegistration;
-    private int mdsalTimeout = MDSAL_TIMEOUT_OPERATIONAL;
-    private volatile InstanceIdentifier<?> iid;
-    private volatile  LogicalDatastoreType type;
-    private volatile boolean listen;
-    private volatile int mask;
-
-    public ControllerNotifyingDataChangeListener(LogicalDatastoreType type, int mask,
-                                                 InstanceIdentifier<?> iid,
-                                                 List<ControllerNotifyingDataChangeListener> waitList) {
-        this(type, iid, waitList);
-        this.mask = mask;
-    }
-
-    /**
-     * Create a new ControllerNotifyingDataChangeListener.
-     *
-     * @param type DataStore type
-     * @param iid of the md-sal object we're waiting for
-     * @param waitList for tracking outstanding changes
-     */
-    public ControllerNotifyingDataChangeListener(LogicalDatastoreType type, InstanceIdentifier<?> iid,
-                                                 List<ControllerNotifyingDataChangeListener> waitList) {
-        this.type = type;
-        this.iid = iid;
-        this.waitList = waitList;
-        if (this.waitList != null) {
-            this.waitList.add(this);
-        }
-
-        mdsalTimeout = MDSAL_TIMEOUT_OPERATIONAL;
-        if (type == LogicalDatastoreType.CONFIGURATION) {
-            mdsalTimeout = MDSAL_TIMEOUT_CONFIG;
-        }
-        listen = true;
-        mask = BIT_ALL;
-    }
-
-    /**
-     * Completely reset the state of this ControllerNotifyingDataChangeListener.
-     *
-     * @param newType DataStore type
-     * @param newIid of the md-sal object we're waiting for
-     */
-    public void modify(LogicalDatastoreType newType, InstanceIdentifier<?> newIid) {
-        this.close();
-        this.clear();
-        this.type = newType;
-        this.iid = newIid;
-    }
-
-    public void setlisten(boolean value) {
-        this.listen = value;
-    }
-
-    public void setMask(int mask) {
-        this.mask = mask;
-    }
-
-    @Override
-    @SuppressFBWarnings("NN_NAKED_NOTIFY")
-    public void onDataTreeChanged(Collection<DataTreeModification<DataObject>> changes) {
-        if (!listen) {
-            return;
-        }
-
-        for (DataTreeModification<DataObject> change: changes) {
-            DataObjectModification<DataObject> rootNode = change.getRootNode();
-            final InstanceIdentifier<DataObject> identifier = change.getRootPath().getRootIdentifier();
-            switch (rootNode.getModificationType()) {
-                case SUBTREE_MODIFIED:
-                case WRITE:
-                    if (rootNode.getDataBefore() == null) {
-                        if ((mask & BIT_CREATE) == BIT_CREATE) {
-                            LOG.info("{} DataTreeChanged: created {}", type, identifier);
-                            createdIids.add(identifier);
-                        }
-                    } else if ((mask & BIT_UPDATE) == BIT_UPDATE) {
-                        LOG.info("{} DataTreeChanged: updated {}", type, identifier);
-                        updatedIids.add(identifier);
-                    }
-                    break;
-                case DELETE:
-                    if ((mask & BIT_DELETE) == BIT_DELETE) {
-                        LOG.info("{} DataTreeChanged: removed {}", type, identifier);
-                        removedIids.add(identifier);
-                    }
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        synchronized (this) {
-            notifyAll();
-        }
-    }
-
-    public boolean isCreated(InstanceIdentifier<?> path) {
-        return createdIids.remove(path);
-    }
-
-    public boolean isUpdated(InstanceIdentifier<?> path) {
-        return updatedIids.remove(path);
-    }
-
-    public boolean isRemoved(InstanceIdentifier<?> path) {
-        return removedIids.remove(path);
-    }
-
-    public void clear() {
-        createdIids.clear();
-        updatedIids.clear();
-        removedIids.clear();
-    }
-
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    public void registerDataChangeListener(DataBroker dataBroker) {
-
-        listenerRegistration = dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(type,
-            (InstanceIdentifier)iid), this);
-    }
-
-    public void waitForCreation() throws InterruptedException {
-        waitForCreation(mdsalTimeout);
-    }
-
-    public void waitForCreation(long timeout) throws InterruptedException {
-        synchronized (this) {
-            long start = System.currentTimeMillis();
-            LOG.info("Waiting for {} DataChanged creation on {}", type, iid);
-            while (!isCreated(iid) && System.currentTimeMillis() - start < timeout) {
-                wait(RETRY_WAIT);
-            }
-            LOG.info("Woke up, waited {}ms for creation of {}", System.currentTimeMillis() - start, iid);
-        }
-    }
-
-    public void waitForUpdate() throws InterruptedException {
-        waitForUpdate(mdsalTimeout);
-    }
-
-    public void waitForUpdate(long timeout) throws InterruptedException {
-        synchronized (this) {
-            long start = System.currentTimeMillis();
-            LOG.info("Waiting for {} DataChanged update on {}", type, iid);
-            while (!isUpdated(iid) && System.currentTimeMillis() - start < timeout) {
-                wait(RETRY_WAIT);
-            }
-            LOG.info("Woke up, waited {}ms for update of {}", System.currentTimeMillis() - start, iid);
-        }
-    }
-
-    public void waitForDeletion() throws InterruptedException {
-        waitForDeletion(mdsalTimeout);
-    }
-
-    public void waitForDeletion(long timeout) throws InterruptedException {
-        synchronized (this) {
-            long start = System.currentTimeMillis();
-            LOG.info("Waiting for {} DataChanged deletion on {}", type, iid);
-            while (!isRemoved(iid) && System.currentTimeMillis() - start < timeout) {
-                wait(RETRY_WAIT);
-            }
-            LOG.info("Woke up, waited {}ms for deletion of {}", System.currentTimeMillis() - start, iid);
-        }
-    }
-
-    @Override
-    public void close() {
-        if (listenerRegistration != null) {
-            listenerRegistration.close();
-        }
-
-        if (waitList != null) {
-            waitList.remove(this);
-        }
-
-        listenerRegistration = null;
-    }
-}
index 298662151eaa1a26ee85b7ca64af08c5f68a07c7..4b467f0e33e536b22d5b55c76508f6258b352fda 100644 (file)
@@ -58,7 +58,7 @@ public class NotifyingDataChangeListener implements AutoCloseable, DataTreeChang
     }
 
     /**
-     * Create a new ControllerNotifyingDataChangeListener.
+     * Create a new NotifyingDataChangeListener.
      *
      * @param type DataStore type
      * @param iid of the md-sal object we're waiting for
@@ -82,7 +82,7 @@ public class NotifyingDataChangeListener implements AutoCloseable, DataTreeChang
     }
 
     /**
-     * Completely reset the state of this ControllerNotifyingDataChangeListener.
+     * Completely reset the state of this NotifyingDataChangeListener.
      *
      * @param newType DataStore type
      * @param newIid of the md-sal object we're waiting for
diff --git a/utils/mdsal-utils/src/test/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtilsAsyncTest.java b/utils/mdsal-utils/src/test/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtilsAsyncTest.java
deleted file mode 100644 (file)
index abe9b46..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright © 2016, 2017 Inocybe 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.utils.mdsal.utils;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.Collections;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-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.TopologyId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ControllerMdsalUtilsAsyncTest extends AbstractDataBrokerTest {
-
-    private ControllerMdsalUtilsAsync mdsalUtilsAsync;
-    private DataBroker databroker;
-
-    private static final TopologyId TOPOLOGY_TEST = new TopologyId("test:1");
-
-    private static final NodeId NODE_ID = new NodeId("test");
-    private static final NodeKey NODE_KEY =  new NodeKey(NODE_ID);
-    private static final Node DATA = new NodeBuilder().withKey(NODE_KEY).setNodeId(NODE_ID).build();
-
-    private static final InstanceIdentifier<Node> TEST_IID = InstanceIdentifier
-            .create(NetworkTopology.class)
-            .child(Topology.class, new TopologyKey(TOPOLOGY_TEST))
-            .child(Node.class, NODE_KEY);
-
-    @Before
-    public void setUp() {
-        databroker = getDataBroker();
-        mdsalUtilsAsync = Mockito.spy(new ControllerMdsalUtilsAsync(databroker));
-    }
-
-    @Test
-    public void testDelete() {
-        final FluentFuture<? extends @NonNull CommitInfo> fut = mdsalUtilsAsync.put(
-                LogicalDatastoreType.CONFIGURATION, TEST_IID, DATA);
-        fut.addCallback(new FutureCallback<CommitInfo>() {
-
-            @Override
-            public void onSuccess(final CommitInfo result) {
-                final FluentFuture<? extends @NonNull CommitInfo> future =
-                        mdsalUtilsAsync.delete(LogicalDatastoreType.CONFIGURATION, TEST_IID);
-                future.addCallback(new FutureCallback<CommitInfo>() {
-
-                    @Override
-                    public void onSuccess(final CommitInfo result) {
-                        assertNull(readDS());
-                    }
-
-                    @Override
-                    public void onFailure(final Throwable ex) {
-                        fail(ex.getMessage());
-                    }
-                }, MoreExecutors.directExecutor());
-            }
-
-            @Override
-            public void onFailure(final Throwable ex) {
-                fail(ex.getMessage());
-            }
-        }, MoreExecutors.directExecutor());
-    }
-
-    @Test
-    public void testPutWithoutCallback() {
-        final String operationDesc = "testPut";
-        final SupportingNode supportingNodeBuilder1 = new SupportingNodeBuilder().withKey(
-                new SupportingNodeKey(new NodeId("id1"), TOPOLOGY_TEST)).build();
-        final SupportingNode supportingNodeBuilder2 = new SupportingNodeBuilder().withKey(
-                new SupportingNodeKey(new NodeId("id2"), TOPOLOGY_TEST)).build();
-
-        final Node data1 = new NodeBuilder(DATA).setSupportingNode(
-                Collections.singletonList(supportingNodeBuilder1)).build();
-        final Node data2 = new NodeBuilder(DATA).setSupportingNode(
-                Collections.singletonList(supportingNodeBuilder2)).build();
-
-        mdsalUtilsAsync.put(LogicalDatastoreType.CONFIGURATION, TEST_IID, data1, operationDesc);
-        assertEquals(data1, readDS());
-
-        final FluentFuture<? extends @NonNull CommitInfo> future = mdsalUtilsAsync.put(
-                LogicalDatastoreType.CONFIGURATION, TEST_IID, data2);
-        future.addCallback(new FutureCallback<CommitInfo>() {
-
-            @Override
-            public void onSuccess(final CommitInfo result) {
-                assertEquals(1, readDS().getSupportingNode().size());
-            }
-
-            @Override
-            public void onFailure(final Throwable ex) {
-                fail(ex.getMessage());
-            }
-        }, MoreExecutors.directExecutor());
-    }
-
-    @Test
-    public void testMerge() {
-        final String operationDesc = "testMerge";
-        final SupportingNode supportingNodeBuilder1 = new SupportingNodeBuilder().withKey(
-                new SupportingNodeKey(new NodeId("id1"), TOPOLOGY_TEST)).build();
-        final SupportingNode supportingNodeBuilder2 = new SupportingNodeBuilder().withKey(
-                new SupportingNodeKey(new NodeId("id2"), TOPOLOGY_TEST)).build();
-
-        final Node data1 = new NodeBuilder(DATA).setSupportingNode(
-                Collections.singletonList(supportingNodeBuilder1)).build();
-        final Node data2 = new NodeBuilder(DATA).setSupportingNode(
-                Collections.singletonList(supportingNodeBuilder2)).build();
-
-        mdsalUtilsAsync.merge(LogicalDatastoreType.CONFIGURATION, TEST_IID, data1, operationDesc, true);
-        assertEquals(data1, readDS());
-
-        final FluentFuture<? extends @NonNull CommitInfo> future =
-                mdsalUtilsAsync.merge(LogicalDatastoreType.CONFIGURATION, TEST_IID, data2, true);
-        future.addCallback(new FutureCallback<CommitInfo>() {
-
-            @Override
-            public void onSuccess(final CommitInfo result) {
-                assertEquals(2, readDS().getSupportingNode().size());
-            }
-
-            @Override
-            public void onFailure(final Throwable ex) {
-                fail(ex.getMessage());
-            }
-        }, MoreExecutors.directExecutor());
-    }
-
-    @Test
-    public void testRead() {
-        final FluentFuture<? extends @NonNull CommitInfo> fut =
-                mdsalUtilsAsync.put(LogicalDatastoreType.CONFIGURATION, TEST_IID, DATA);
-
-        fut.addCallback(new FutureCallback<CommitInfo>() {
-            @Override
-            public void onSuccess(final CommitInfo result) {
-                final FluentFuture<Optional<Node>> future =
-                        mdsalUtilsAsync.read(LogicalDatastoreType.CONFIGURATION, TEST_IID);
-                Optional<Node> optNode;
-                try {
-                    optNode = future.get();
-                    if (optNode.isPresent()) {
-                        assertEquals(DATA, optNode.get());
-                    } else {
-                        fail("Couldn't read node");
-                    }
-                } catch (InterruptedException | ExecutionException e) {
-                    fail(e.getMessage());
-                }
-            }
-
-            @Override
-            public void onFailure(final Throwable ex) {
-                fail(ex.getMessage());
-            }
-        }, MoreExecutors.directExecutor());
-    }
-
-    private Node readDS() {
-        try {
-            final Optional<Node> result = databroker.newReadOnlyTransaction().read(
-                    LogicalDatastoreType.CONFIGURATION, TEST_IID).get();
-            if (result.isPresent()) {
-                return result.get();
-            }
-        } catch (InterruptedException | ExecutionException e) {
-            fail(e.getMessage());
-        }
-        return null;
-    }
-}
diff --git a/utils/mdsal-utils/src/test/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtilsTest.java b/utils/mdsal-utils/src/test/java/org/opendaylight/ovsdb/utils/mdsal/utils/ControllerMdsalUtilsTest.java
deleted file mode 100644 (file)
index d9d58a9..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2015 Inocybe 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.utils.mdsal.utils;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.util.concurrent.FluentFutures;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Unit test for class {@link ControllerMdsalUtils}.
- */
-@RunWith(MockitoJUnitRunner.class)
-@SuppressWarnings({ "unchecked", "rawtypes" })
-public class ControllerMdsalUtilsTest {
-
-    @InjectMocks private ControllerMdsalUtils mdsalUtils;
-
-    @Mock private DataBroker databroker;
-
-    @Test
-    public void testDelete() {
-        WriteTransaction writeTransaction = mock(WriteTransaction.class);
-        when(databroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
-        FluentFuture<? extends @NonNull CommitInfo> future = mock(FluentFuture.class);
-        Mockito.when(writeTransaction.commit()).thenReturn(FluentFutures.immediateNullFluentFuture());
-
-        boolean result = mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, mock(InstanceIdentifier.class));
-
-        verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(1)).commit();
-
-        assertTrue("Error, the delete transaction failed", result);
-    }
-
-    @Test
-    public void testMerge() {
-        WriteTransaction writeTransaction = mock(WriteTransaction.class);
-        when(databroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
-        FluentFuture<? extends @NonNull CommitInfo> future = mock(FluentFuture.class);
-        Mockito.when(writeTransaction.commit()).thenReturn(FluentFutures.immediateNullFluentFuture());
-
-        boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
-                mock(InstanceIdentifier.class), mock(DataObject.class));
-
-        verify(writeTransaction, times(1)).mergeParentStructureMerge(any(LogicalDatastoreType.class),
-                any(InstanceIdentifier.class), any(DataObject.class));
-        verify(writeTransaction, times(1)).commit();
-
-        assertTrue("Error, the merge transaction failed", result);
-    }
-
-    @Test
-    public void testPut() {
-        WriteTransaction writeTransaction = mock(WriteTransaction.class);
-        when(databroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
-        FluentFuture<? extends @NonNull CommitInfo> future = mock(FluentFuture.class);
-        Mockito.when(writeTransaction.commit()).thenReturn(FluentFutures.immediateNullFluentFuture());
-
-        boolean result = mdsalUtils.put(LogicalDatastoreType.CONFIGURATION,
-                mock(InstanceIdentifier.class), mock(DataObject.class));
-
-        verify(writeTransaction, times(1)).mergeParentStructurePut(any(LogicalDatastoreType.class),
-                any(InstanceIdentifier.class), any(DataObject.class));
-        verify(writeTransaction, times(1)).commit();
-
-        assertTrue("Error, the put transaction failed", result);
-    }
-
-    @Test
-    public void testRead() throws InterruptedException, ExecutionException {
-        ReadTransaction readOnlyTransaction = mock(ReadTransaction.class);
-        when(databroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction);
-        FluentFuture<Optional> future = mock(FluentFuture.class);
-        DataObject obj = mock(DataObject.class);
-        Optional opt = Optional.of(obj);
-        when(future.get()).thenReturn(opt);
-        when(readOnlyTransaction.read(any(LogicalDatastoreType.class),
-                any(InstanceIdentifier.class))).thenReturn(future);
-
-        DataObject result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, mock(InstanceIdentifier.class));
-
-        verify(readOnlyTransaction, times(1)).read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(readOnlyTransaction, times(1)).close();
-
-        assertEquals("Error, the read transaction failed", obj, result);
-    }
-}
index f4ad031d6ca58ee82fd6de7b3b718444a35d0fc9..37a7b038c8857289ef3ee5b98ad42912f66bb874 100644 (file)
@@ -15,7 +15,6 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.List;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerNotifyingDataChangeListener;
 import org.opendaylight.ovsdb.utils.mdsal.utils.NotifyingDataChangeListener;
 import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
@@ -38,9 +37,9 @@ public class NodeInfo {
     public long datapathId;
     public Node ovsdbNode;
     public Node bridgeNode;
-    private ControllerNotifyingDataChangeListener ovsdbWaiter;
-    private ControllerNotifyingDataChangeListener bridgeWaiter;
-    private final List<ControllerNotifyingDataChangeListener> waitList;
+    private NotifyingDataChangeListener ovsdbWaiter;
+    private NotifyingDataChangeListener bridgeWaiter;
+    private final List<NotifyingDataChangeListener> waitList;
     private final OvsdbItUtils itUtils;
 
     /**
@@ -50,7 +49,7 @@ public class NodeInfo {
      * @param waitList for tracking outstanding md-sal events
      */
     NodeInfo(ConnectionInfo connectionInfo, OvsdbItUtils itUtils,
-            List<ControllerNotifyingDataChangeListener> waitList) {
+            List<NotifyingDataChangeListener> waitList) {
         this.connectionInfo = connectionInfo;
         this.itUtils = itUtils;
         this.waitList = waitList;
@@ -59,11 +58,11 @@ public class NodeInfo {
     }
 
     private void addWaiters() {
-        ovsdbWaiter = new ControllerNotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                ControllerNotifyingDataChangeListener.BIT_CREATE, ovsdbIid, waitList);
+        ovsdbWaiter = new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+            NotifyingDataChangeListener.BIT_CREATE, ovsdbIid, waitList);
         ovsdbWaiter.registerDataChangeListener(itUtils.dataBroker);
-        bridgeWaiter = new ControllerNotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                ControllerNotifyingDataChangeListener.BIT_CREATE, bridgeIid, waitList);
+        bridgeWaiter = new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+            NotifyingDataChangeListener.BIT_CREATE, bridgeIid, waitList);
         bridgeWaiter.registerDataChangeListener(itUtils.dataBroker);
     }
 
index 1b36ff49e5e71d0989be14a8577349aa92248dda..226c97a78b338962bf6688f27fb4eed0ffdc0025 100644 (file)
@@ -13,8 +13,8 @@ import static org.junit.Assert.assertNotNull;
 
 import java.util.List;
 import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerNotifyingDataChangeListener;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.NotifyingDataChangeListener;
 import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
 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;
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
  */
 public class OvsdbItUtils {
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbItUtils.class);
-    ControllerMdsalUtils mdsalUtils;
+    MdsalUtils mdsalUtils;
     SouthboundUtils southboundUtils;
     DataBroker dataBroker;
 
@@ -38,7 +38,7 @@ public class OvsdbItUtils {
      */
     public OvsdbItUtils(DataBroker dataBroker) {
         this.dataBroker = dataBroker;
-        mdsalUtils = new ControllerMdsalUtils(dataBroker);
+        mdsalUtils = new MdsalUtils(dataBroker);
         southboundUtils = new SouthboundUtils(mdsalUtils);
     }
 
@@ -49,7 +49,7 @@ public class OvsdbItUtils {
      * @return a new NodeInfo object
      */
     public NodeInfo createNodeInfo(ConnectionInfo connectionInfo,
-            List<ControllerNotifyingDataChangeListener> waitList) {
+            List<NotifyingDataChangeListener> waitList) {
         return new NodeInfo(connectionInfo, this, waitList);
     }
 
index fff3561ef620251f424e30825e43d67b904dbbd4..d2e26f18380ed6b7a656c9017dd32338106fb684 100644 (file)
@@ -28,7 +28,6 @@ import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.ovsdb.utils.config.ConfigProperties;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
 import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -133,36 +132,6 @@ public class SouthboundUtils {
         abstract <T extends DataObject> boolean merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
     }
 
-    @Deprecated
-    private static final class ControllerUtilsProvider extends UtilsProvider {
-        private final ControllerMdsalUtils mdsalUtils;
-
-        ControllerUtilsProvider(final ControllerMdsalUtils mdsalUtils) {
-            this.mdsalUtils = requireNonNull(mdsalUtils);
-        }
-
-        @Override
-        <T extends DataObject> T read(LogicalDatastoreType store, InstanceIdentifier<T> path) {
-            return mdsalUtils.read(store, path);
-        }
-
-        @Override
-        <T extends DataObject> boolean put(LogicalDatastoreType store,
-                InstanceIdentifier<T> path, T data) {
-            return mdsalUtils.put(store, path, data);
-        }
-
-        @Override
-        boolean delete(LogicalDatastoreType store, InstanceIdentifier<?> path) {
-            return mdsalUtils.delete(store, path);
-        }
-
-        @Override
-        <T extends DataObject> boolean merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
-            return mdsalUtils.merge(store, path, data);
-        }
-    }
-
     private static final class MdsalUtilsProvider extends UtilsProvider {
         private final MdsalUtils mdsalUtils;
 
@@ -212,11 +181,6 @@ public class SouthboundUtils {
 
     private final UtilsProvider provider;
 
-    @Deprecated
-    public SouthboundUtils(ControllerMdsalUtils mdsalUtils) {
-        provider = new ControllerUtilsProvider(mdsalUtils);
-    }
-
     public SouthboundUtils(MdsalUtils mdsalUtils) {
         provider = new MdsalUtilsProvider(mdsalUtils);
     }