Convert CDS implementation to use msdal APIs 69/50269/13
authorTom Pantelis <tpanteli@brocade.com>
Tue, 3 Jan 2017 11:09:47 +0000 (06:09 -0500)
committerTom Pantelis <tompantelis@gmail.com>
Sun, 11 Mar 2018 03:34:03 +0000 (22:34 -0500)
The LegacyDOMDataBrokerAdapter is the proxy for the controller API.

Change-Id: I697e2979bef4dcffe544717af1380aa7d7b89d50
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
71 files changed:
opendaylight/md-sal/mdsal-trace/dom-impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMTransactionFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBroker.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadOnlyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerWriteOnlyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMStoreThreePhaseCommitCohortAdaptor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/compat/LegacyDOMDataBrokerAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractThreePhaseCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerSupport.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DefaultShardDataTreeChangeListenerPublisher.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreInterface.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ForwardingDataTreeChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisher.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangeListenerPublisherActorProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangePublisherActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SingleCommitCohortProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/compat/LegacyDOMStoreAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractEntityOwnerChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/PrefixedShardConfigUpdateHandler.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModuleFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModuleFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/ForwardingDistributedDataStore.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStoreTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadWriteTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedWriteTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/compat/LegacyDOMDataBrokerAdapterTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataTreeChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregatorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java

index 6135259..7535f95 100644 (file)
@@ -20,7 +20,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
         odl:type="default" />
 
   <reference id="realDefaultDOMBroker"
-      component-name="clusteredDOMDataBroker"
       interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
       odl:type="default" />
 
index fa7927e..df5cef2 100644 (file)
@@ -73,11 +73,11 @@ import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
 import org.opendaylight.controller.cluster.sharding.messages.PrefixShardCreated;
 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.Cars;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.People;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddPrefixShardReplicaInput;
index 6e6ddf6..e3b1c30 100644 (file)
@@ -15,28 +15,25 @@ import com.google.common.collect.ImmutableMap.Builder;
 import java.util.EnumMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionChainListener;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStore;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory<DOMStore>
-        implements DOMDataBroker {
+public abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory<DOMStore> implements DOMDataBroker {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMBroker.class);
 
@@ -61,14 +58,13 @@ abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory<DOMStore>
             });
         }
 
-        if (isSupported(datastores, org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry.class)) {
+        if (isSupported(datastores, DOMDataTreeCommitCohortRegistry.class)) {
             extBuilder.put(DOMDataTreeCommitCohortRegistry.class, new DOMDataTreeCommitCohortRegistry() {
                 @Override
                 public <T extends DOMDataTreeCommitCohort> DOMDataTreeCommitCohortRegistration<T> registerCommitCohort(
-                        org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier path, T cohort) {
-                    DOMStore store = getDOMStore(toLegacy(path.getDatastoreType()));
-                    return ((org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) store)
-                            .registerCommitCohort(path, cohort);
+                        DOMDataTreeIdentifier path, T cohort) {
+                    DOMStore store = getDOMStore(path.getDatastoreType());
+                    return ((DOMDataTreeCommitCohortRegistry) store).registerCommitCohort(path, cohort);
                 }
             });
         }
@@ -76,17 +72,6 @@ abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory<DOMStore>
         extensions = extBuilder.build();
     }
 
-    private static LogicalDatastoreType toLegacy(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType) {
-        switch (datastoreType) {
-            case CONFIGURATION:
-                return LogicalDatastoreType.CONFIGURATION;
-            case OPERATIONAL:
-                return LogicalDatastoreType.OPERATIONAL;
-            default:
-                throw new IllegalArgumentException("Unsupported data store type: " + datastoreType);
-        }
-    }
-
     private static boolean isSupported(Map<LogicalDatastoreType, DOMStore> datastores,
             Class<?> expDOMStoreInterface) {
         for (DOMStore ds : datastores.values()) {
@@ -121,14 +106,6 @@ abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory<DOMStore>
         return "DOM-" + txNum.getAndIncrement();
     }
 
-    @Override
-    public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
-            final YangInstanceIdentifier path, final DOMDataChangeListener listener,
-            final DataChangeScope triggeringScope) {
-        DOMStore potentialStore = getDOMStore(store);
-        return potentialStore.registerChangeListener(path, listener, triggeringScope);
-    }
-
     @Override
     public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
         return extensions;
index 180623e..2053a0f 100644 (file)
@@ -14,10 +14,10 @@ import com.google.common.base.Preconditions;
 import java.util.Collection;
 import java.util.EnumMap;
 import java.util.Map;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
+import org.opendaylight.mdsal.common.api.AsyncTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
index 7d519ba..9dcc71f 100644 (file)
@@ -12,22 +12,18 @@ import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.broker.impl.TransactionCommitFailedExceptionMapper;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -35,7 +31,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractDOMBrokerWriteTransaction<T extends DOMStoreWriteTransaction>
-        extends AbstractDOMBrokerTransaction<T> implements DOMDataWriteTransaction {
+        extends AbstractDOMBrokerTransaction<T> implements DOMDataTreeWriteTransaction {
 
     @SuppressWarnings("rawtypes")
     private static final AtomicReferenceFieldUpdater<AbstractDOMBrokerWriteTransaction, AbstractDOMTransactionFactory>
@@ -126,12 +122,6 @@ public abstract class AbstractDOMBrokerWriteTransaction<T extends DOMStoreWriteT
         return future.cancel(false);
     }
 
-    @Deprecated
-    @Override
-    public ListenableFuture<RpcResult<TransactionStatus>> commit() {
-        return AbstractDataTransaction.convertToLegacyCommitFuture(submit());
-    }
-
     @Override
     @SuppressWarnings("checkstyle:illegalcatch")
     public CheckedFuture<Void, TransactionCommitFailedException> submit() {
index 43db918..f80ea94 100644 (file)
@@ -14,13 +14,13 @@ import java.util.Collection;
 import java.util.EnumMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
 
 public abstract class AbstractDOMTransactionFactory<T extends DOMStoreTransactionFactory> implements AutoCloseable {
     @SuppressWarnings("rawtypes")
@@ -48,15 +48,15 @@ public abstract class AbstractDOMTransactionFactory<T extends DOMStoreTransactio
      * @param cohorts the associated cohorts
      * @return a resulting Future
      */
-    protected abstract CheckedFuture<Void,TransactionCommitFailedException> submit(DOMDataWriteTransaction transaction,
-            Collection<DOMStoreThreePhaseCommitCohort> cohorts);
+    protected abstract CheckedFuture<Void,TransactionCommitFailedException> submit(
+            DOMDataTreeWriteTransaction transaction, Collection<DOMStoreThreePhaseCommitCohort> cohorts);
 
     /**
      * Creates a new read-only transaction.
      *
      * @return the transaction instance
      */
-    public final DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+    public final DOMDataTreeReadTransaction newReadOnlyTransaction() {
         checkNotClosed();
 
         return new DOMBrokerReadOnlyTransaction(newTransactionIdentifier(), storeTxFactories);
@@ -68,7 +68,7 @@ public abstract class AbstractDOMTransactionFactory<T extends DOMStoreTransactio
      *
      * @return the transaction instance
      */
-    public final DOMDataWriteTransaction newWriteOnlyTransaction() {
+    public final DOMDataTreeWriteTransaction newWriteOnlyTransaction() {
         checkNotClosed();
 
         return new DOMBrokerWriteOnlyTransaction(newTransactionIdentifier(), storeTxFactories, this);
@@ -80,7 +80,7 @@ public abstract class AbstractDOMTransactionFactory<T extends DOMStoreTransactio
      *
      * @return the transaction instance
      */
-    public final DOMDataReadWriteTransaction newReadWriteTransaction() {
+    public final DOMDataTreeReadWriteTransaction newReadWriteTransaction() {
         checkNotClosed();
 
         return new DOMBrokerReadWriteTransaction(newTransactionIdentifier(), storeTxFactories, this);
@@ -96,7 +96,7 @@ public abstract class AbstractDOMTransactionFactory<T extends DOMStoreTransactio
      *
      * @return Map of backing transaction factories.
      */
-    protected final Map<LogicalDatastoreType, T> getTxFactories() {
+    public final Map<LogicalDatastoreType, T> getTxFactories() {
         return storeTxFactories;
     }
 
index 8aebe5b..73622a0 100644 (file)
@@ -17,10 +17,10 @@ import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 
 /**
  * Implements a distributed DOMStore using ClientActor.
index 3cbda25..2a05519 100644 (file)
@@ -13,8 +13,8 @@ import com.google.common.util.concurrent.Futures;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
index 9a73fc8..0e673e7 100644 (file)
@@ -12,8 +12,8 @@ import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
index 36d1b5d..4168fc9 100644 (file)
@@ -15,11 +15,11 @@ import org.opendaylight.controller.cluster.databroker.actors.dds.AbstractClientH
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientLocalHistory;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.TransactionChainClosedException;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index 56ec344..737e70d 100644 (file)
@@ -9,8 +9,8 @@ package org.opendaylight.controller.cluster.databroker;
 
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
index b80a605..043a26c 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
-import static org.opendaylight.controller.md.sal.dom.broker.impl.TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER;
-import static org.opendaylight.controller.md.sal.dom.broker.impl.TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER;
-import static org.opendaylight.controller.md.sal.dom.broker.impl.TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER;
+import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER;
+import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER;
+import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Preconditions;
@@ -27,14 +27,14 @@ import java.util.Map;
 import java.util.concurrent.Executor;
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
 import org.opendaylight.controller.cluster.datastore.exceptions.ShardLeaderNotRespondingException;
-import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.broker.impl.TransactionCommitFailedExceptionMapper;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.common.api.DataStoreUnavailableException;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper;
+import org.opendaylight.mdsal.dom.spi.store.DOMStore;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.util.DurationStatisticsTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -77,8 +77,8 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     }
 
     @Override
-    protected CheckedFuture<Void, TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
-            final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
+    protected CheckedFuture<Void, TransactionCommitFailedException> submit(
+            final DOMDataTreeWriteTransaction transaction, final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
 
         Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
         Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
@@ -97,7 +97,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     }
 
     private void doCanCommit(final AsyncNotifyingSettableFuture clientSubmitFuture,
-            final DOMDataWriteTransaction transaction,
+            final DOMDataTreeWriteTransaction transaction,
             final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
 
         final long startTime = System.nanoTime();
@@ -130,7 +130,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     }
 
     private void doPreCommit(final long startTime, final AsyncNotifyingSettableFuture clientSubmitFuture,
-            final DOMDataWriteTransaction transaction,
+            final DOMDataTreeWriteTransaction transaction,
             final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
 
         final Iterator<DOMStoreThreePhaseCommitCohort> cohortIterator = cohorts.iterator();
@@ -159,7 +159,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     }
 
     private void doCommit(final long startTime, final AsyncNotifyingSettableFuture clientSubmitFuture,
-            final DOMDataWriteTransaction transaction,
+            final DOMDataTreeWriteTransaction transaction,
             final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
 
         final Iterator<DOMStoreThreePhaseCommitCohort> cohortIterator = cohorts.iterator();
@@ -194,7 +194,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
                 + "uncomfirmed cast but the generic type in TransactionCommitFailedExceptionMapper is "
                 + "TransactionCommitFailedException and thus should be deemed as confirmed.")
     private static void handleException(final AsyncNotifyingSettableFuture clientSubmitFuture,
-            final DOMDataWriteTransaction transaction,
+            final DOMDataTreeWriteTransaction transaction,
             final Collection<DOMStoreThreePhaseCommitCohort> cohorts,
             final String phase, final TransactionCommitFailedExceptionMapper exMapper,
             final Throwable throwable) {
index 3575731..0dccb42 100644 (file)
@@ -11,17 +11,17 @@ package org.opendaylight.controller.cluster.databroker;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Map;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 public class DOMBrokerReadOnlyTransaction
-    extends AbstractDOMBrokerTransaction<DOMStoreReadTransaction>
-        implements DOMDataReadOnlyTransaction {
+        extends AbstractDOMBrokerTransaction<DOMStoreReadTransaction> implements DOMDataTreeReadTransaction {
+
     /**
      * Creates new composite Transactions.
      *
@@ -54,6 +54,4 @@ public class DOMBrokerReadOnlyTransaction
     protected DOMStoreReadTransaction createTransaction(LogicalDatastoreType key) {
         return getTxFactory(key).newReadOnlyTransaction();
     }
-
-
 }
index a2693a6..d5a0939 100644 (file)
@@ -11,16 +11,16 @@ package org.opendaylight.controller.cluster.databroker;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Map;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
-public class DOMBrokerReadWriteTransaction
-        extends AbstractDOMBrokerWriteTransaction<DOMStoreReadWriteTransaction> implements DOMDataReadWriteTransaction {
+public class DOMBrokerReadWriteTransaction extends AbstractDOMBrokerWriteTransaction<DOMStoreReadWriteTransaction>
+        implements DOMDataTreeReadWriteTransaction {
 
     /**
      * Constructs an instance.
@@ -51,4 +51,9 @@ public class DOMBrokerReadWriteTransaction
     protected DOMStoreReadWriteTransaction createTransaction(LogicalDatastoreType key) {
         return getTxFactory(key).newReadWriteTransaction();
     }
+
+    @Override
+    public void close() {
+        cancel();
+    }
 }
index a25b07b..2eabe79 100644 (file)
@@ -18,13 +18,13 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionChainListener;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -81,7 +81,7 @@ final class DOMBrokerTransactionChain extends AbstractDOMTransactionFactory<DOMS
 
     @Override
     public CheckedFuture<Void, TransactionCommitFailedException> submit(
-            final DOMDataWriteTransaction transaction, final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
+            final DOMDataTreeWriteTransaction transaction, final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
         checkNotFailed();
         checkNotClosed();
 
@@ -132,7 +132,7 @@ final class DOMBrokerTransactionChain extends AbstractDOMTransactionFactory<DOMS
         }
     }
 
-    private void transactionFailed(final DOMDataWriteTransaction tx, final Throwable cause) {
+    private void transactionFailed(final DOMDataTreeWriteTransaction tx, final Throwable cause) {
         state = State.FAILED;
         LOG.debug("Transaction chain {}¬†failed.", this, cause);
         listener.onTransactionChainFailed(this, tx, cause);
index 65f11c2..2f0915d 100644 (file)
@@ -9,9 +9,9 @@
 package org.opendaylight.controller.cluster.databroker;
 
 import java.util.Map;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 
 public class DOMBrokerWriteOnlyTransaction extends AbstractDOMBrokerWriteTransaction<DOMStoreWriteTransaction> {
 
index e9a5a7d..5111a32 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.cluster.databroker;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ForwardingObject;
 import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 
 /**
  * Utility class from bridging {@link DOMStoreThreePhaseCommitCohort} and
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/compat/LegacyDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/compat/LegacyDOMDataBrokerAdapter.java
new file mode 100644 (file)
index 0000000..f495037
--- /dev/null
@@ -0,0 +1,343 @@
+/*
+ * Copyright (c) 2017 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.controller.cluster.databroker.compat;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ForwardingObject;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.cluster.databroker.AbstractDOMBroker;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
+import org.opendaylight.controller.cluster.datastore.compat.LegacyDOMStoreAdapter;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction;
+import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker.
+ *
+ * @author Thomas Pantelis
+ */
+public class LegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMDataBroker {
+    private static final ExceptionMapper<TransactionCommitFailedException> SUBMIT_EX_MAPPER =
+            new ExceptionMapper<TransactionCommitFailedException>("submit", TransactionCommitFailedException.class) {
+        @Override
+        protected TransactionCommitFailedException newWithCause(String message, Throwable cause) {
+            if (cause instanceof org.opendaylight.mdsal.common.api.OptimisticLockFailedException) {
+                return new OptimisticLockFailedException(cause.getMessage(), cause.getCause());
+            } else if (cause instanceof org.opendaylight.mdsal.common.api.TransactionCommitFailedException) {
+                Throwable rootCause = cause.getCause();
+                if (rootCause instanceof org.opendaylight.mdsal.common.api.DataStoreUnavailableException) {
+                    rootCause = new DataStoreUnavailableException(rootCause.getMessage(), rootCause.getCause());
+                }
+
+                return new TransactionCommitFailedException(cause.getMessage(), rootCause);
+            }
+
+            return new TransactionCommitFailedException(message, cause);
+        }
+    };
+
+    private final AbstractDOMBroker delegate;
+    private final Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> extensions;
+
+    public LegacyDOMDataBrokerAdapter(AbstractDOMBroker delegate) {
+        this.delegate = delegate;
+
+        Map<Class<? extends org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension>,
+            org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> delegateExtensions =
+                delegate.getSupportedExtensions();
+
+        Builder<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> extBuilder = ImmutableMap.builder();
+        final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService delegateTreeChangeService =
+                (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) delegateExtensions.get(
+                        org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService.class);
+        if (delegateTreeChangeService != null) {
+            extBuilder.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
+                @Override
+                public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(
+                        DOMDataTreeIdentifier treeId, final L listener) {
+                    final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener delegateListener;
+                    if (listener instanceof ClusteredDOMDataTreeChangeListener) {
+                        delegateListener = (org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener)
+                            changes -> listener.onDataTreeChanged(changes);
+                    } else {
+                        delegateListener = changes -> listener.onDataTreeChanged(changes);
+                    }
+
+                    final ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> reg =
+                        delegateTreeChangeService.registerDataTreeChangeListener(
+                            new org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier(convert(treeId.getDatastoreType()),
+                                    treeId.getRootIdentifier()), delegateListener);
+
+                    return new ListenerRegistration<L>() {
+                        @Override
+                        public L getInstance() {
+                            return listener;
+                        }
+
+                        @Override
+                        public void close() {
+                            reg.close();
+                        }
+                    };
+                }
+            });
+        }
+
+        final org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry delegateCohortRegistry =
+                (org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) delegateExtensions.get(
+                        org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry.class);
+        if (delegateCohortRegistry != null) {
+            extBuilder.put(DOMDataTreeCommitCohortRegistry.class, new DOMDataTreeCommitCohortRegistry() {
+                @Override
+                public <T extends DOMDataTreeCommitCohort> DOMDataTreeCommitCohortRegistration<T> registerCommitCohort(
+                        org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier path, T cohort) {
+                    return delegateCohortRegistry.registerCommitCohort(path, cohort);
+                }
+            });
+        }
+
+        extensions = extBuilder.build();
+    }
+
+    @Override
+    protected AbstractDOMBroker delegate() {
+        return delegate;
+    }
+
+    @Override
+    public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
+        return extensions;
+    }
+
+    @Override
+    public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+        return new DOMDataReadOnlyTransactionAdapter(delegate().newReadOnlyTransaction());
+    }
+
+    @Override
+    public DOMDataReadWriteTransaction newReadWriteTransaction() {
+        return new DOMDataTransactionAdapter(delegate().newReadWriteTransaction());
+    }
+
+    @Override
+    public DOMDataWriteTransaction newWriteOnlyTransaction() {
+        return new DOMDataTransactionAdapter(delegate().newWriteOnlyTransaction());
+    }
+
+    @Override
+    public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
+        AtomicReference<DOMTransactionChain> legacyChain = new AtomicReference<>();
+        org.opendaylight.mdsal.common.api.TransactionChainListener delegateListener =
+                new org.opendaylight.mdsal.common.api.TransactionChainListener() {
+            @SuppressWarnings("rawtypes")
+            @Override
+            public void onTransactionChainFailed(final org.opendaylight.mdsal.common.api.TransactionChain<?, ?> chain,
+                    final org.opendaylight.mdsal.common.api.AsyncTransaction<?, ?> transaction, final Throwable cause) {
+                listener.onTransactionChainFailed(legacyChain.get(),
+                        (AsyncTransaction) () -> transaction.getIdentifier(),
+                            cause instanceof Exception ? SUBMIT_EX_MAPPER.apply((Exception)cause) : cause);
+            }
+
+            @Override
+            public void onTransactionChainSuccessful(org.opendaylight.mdsal.common.api.TransactionChain<?, ?> chain) {
+                listener.onTransactionChainSuccessful(legacyChain.get());
+            }
+        };
+
+        final org.opendaylight.mdsal.dom.api.DOMTransactionChain delegateChain =
+                delegate().createTransactionChain(delegateListener);
+        legacyChain.set(new DOMTransactionChain() {
+            @Override
+            public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+                return new DOMDataReadOnlyTransactionAdapter(delegateChain.newReadOnlyTransaction());
+            }
+
+            @Override
+            public DOMDataReadWriteTransaction newReadWriteTransaction() {
+                return new DOMDataTransactionAdapter(delegateChain.newReadWriteTransaction());
+            }
+
+            @Override
+            public DOMDataWriteTransaction newWriteOnlyTransaction() {
+                return new DOMDataTransactionAdapter(delegateChain.newWriteOnlyTransaction());
+            }
+
+            @Override
+            public void close() {
+                delegateChain.close();
+            }
+        });
+
+        return legacyChain.get();
+    }
+
+    @Override
+    public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
+            final YangInstanceIdentifier path, final DOMDataChangeListener listener,
+            final DataChangeScope triggeringScope) {
+        org.opendaylight.mdsal.dom.spi.store.DOMStore potentialStore = delegate().getTxFactories().get(convert(store));
+        checkState(potentialStore != null, "Requested logical data store is not available.");
+        checkState(potentialStore instanceof DistributedDataStoreInterface,
+                "Requested logical data store does not support DataChangeListener.");
+        return ((DistributedDataStoreInterface)potentialStore).registerChangeListener(path, listener, triggeringScope);
+    }
+
+    private static org.opendaylight.mdsal.common.api.LogicalDatastoreType convert(LogicalDatastoreType datastoreType) {
+        return org.opendaylight.mdsal.common.api.LogicalDatastoreType.valueOf(datastoreType.name());
+    }
+
+    private static class DOMDataTransactionAdapter implements DOMDataReadWriteTransaction {
+        private final DOMDataTreeReadTransaction readDelegate;
+        private final DOMDataTreeWriteTransaction writeDelegate;
+        private final Object identifier;
+
+        DOMDataTransactionAdapter(@Nonnull DOMDataTreeReadTransaction readDelegate) {
+            this.readDelegate = Preconditions.checkNotNull(readDelegate);
+            this.identifier = readDelegate.getIdentifier();
+            this.writeDelegate = null;
+        }
+
+        DOMDataTransactionAdapter(@Nonnull DOMDataTreeWriteTransaction writeDelegate) {
+            this.writeDelegate = Preconditions.checkNotNull(writeDelegate);
+            this.identifier = writeDelegate.getIdentifier();
+            this.readDelegate = null;
+        }
+
+        DOMDataTransactionAdapter(@Nonnull DOMDataTreeReadWriteTransaction rwDelegate) {
+            this.readDelegate = Preconditions.checkNotNull(rwDelegate);
+            this.writeDelegate = rwDelegate;
+            this.identifier = readDelegate.getIdentifier();
+        }
+
+        DOMDataTreeReadTransaction readDelegate() {
+            return readDelegate;
+        }
+
+        DOMDataTreeWriteTransaction writeDelegate() {
+            return writeDelegate;
+        }
+
+        @Override
+        public Object getIdentifier() {
+            return identifier;
+        }
+
+        @Override
+        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(LogicalDatastoreType store,
+                YangInstanceIdentifier path) {
+            return MappingCheckedFuture.create(readDelegate().read(convert(store), path),
+                    LegacyDOMStoreAdapter.READ_EX_MAPPER);
+        }
+
+        @Override
+        public CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store,
+                YangInstanceIdentifier path) {
+            return MappingCheckedFuture.create(readDelegate().exists(convert(store), path),
+                    LegacyDOMStoreAdapter.READ_EX_MAPPER);
+        }
+
+        @Override
+        public void delete(LogicalDatastoreType store, YangInstanceIdentifier path) {
+            writeDelegate().delete(convert(store), path);
+        }
+
+        @Override
+        public void put(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+            writeDelegate().put(convert(store), path, data);
+        }
+
+        @Override
+        public void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+            writeDelegate().merge(convert(store), path, data);
+        }
+
+        @Override
+        public boolean cancel() {
+            return writeDelegate().cancel();
+        }
+
+        @Override
+        public CheckedFuture<Void, TransactionCommitFailedException> submit() {
+            return MappingCheckedFuture.create(writeDelegate().submit(), SUBMIT_EX_MAPPER);
+        }
+
+        @Override
+        public ListenableFuture<RpcResult<TransactionStatus>> commit() {
+            return AbstractDataTransaction.convertToLegacyCommitFuture(submit());
+        }
+    }
+
+    private static class DOMDataReadOnlyTransactionAdapter implements DOMDataReadOnlyTransaction {
+        private final DOMDataTransactionAdapter adapter;
+
+        DOMDataReadOnlyTransactionAdapter(DOMDataTreeReadTransaction delegateTx) {
+            adapter = new DOMDataTransactionAdapter(delegateTx);
+        }
+
+        @Override
+        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(LogicalDatastoreType store,
+                YangInstanceIdentifier path) {
+            return adapter.read(store, path);
+        }
+
+        @Override
+        public CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store,
+                YangInstanceIdentifier path) {
+            return adapter.exists(store, path);
+        }
+
+        @Override
+        public Object getIdentifier() {
+            return adapter.getIdentifier();
+        }
+
+        @Override
+        public void close() {
+            adapter.readDelegate().close();
+        }
+    }
+}
index de6bc7e..5c0daca 100644 (file)
@@ -33,13 +33,13 @@ import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils;
 import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher;
+import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -164,6 +164,7 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface
 
     @SuppressWarnings("unchecked")
     @Override
+    @Deprecated
     public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
                                               ListenerRegistration<L> registerChangeListener(
         final YangInstanceIdentifier path, final L listener,
index 7c56f26..7ef1cd4 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.cluster.datastore;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import scala.concurrent.Future;
 
 /**
index e877a4d..c7dfbc9 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.controller.cluster.datastore.messages.DataTreeChangedRep
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeListenerInfo;
 import org.opendaylight.controller.cluster.datastore.messages.EnableNotification;
 import org.opendaylight.controller.cluster.datastore.messages.GetInfo;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 /**
index 73e5080..0a33842 100644 (file)
@@ -19,8 +19,8 @@ import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotif
 import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.slf4j.Logger;
index 8dba005..c7fb05f 100644 (file)
@@ -11,7 +11,7 @@ import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import org.opendaylight.controller.cluster.datastore.actors.DataTreeNotificationListenerRegistrationActor;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 
 final class DataTreeChangeListenerSupport extends AbstractDataListenerSupport<DOMDataTreeChangeListener,
         RegisterDataTreeChangeListener> {
index df5d70f..764cd35 100644 (file)
@@ -22,8 +22,8 @@ import org.opendaylight.controller.cluster.common.actor.FileAkkaConfigurationRea
 import org.opendaylight.controller.cluster.raft.ConfigParams;
 import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl;
 import org.opendaylight.controller.cluster.raft.PeerAddressResolver;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 2757c2d..b71174d 100644 (file)
@@ -11,7 +11,7 @@ import com.google.common.base.Optional;
 import java.util.Collection;
 import java.util.function.Consumer;
 import javax.annotation.concurrent.NotThreadSafe;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
 import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -65,17 +65,10 @@ final class DefaultShardDataTreeChangeListenerPublisher extends AbstractDOMStore
             Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
         LOG.debug("{}: registerTreeChangeListener: path: {}, listener: {}", logContext, treeId, listener);
 
-        AbstractDOMDataTreeChangeListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener>
-            registration = super.registerTreeChangeListener(treeId, new ForwardingDOMDataTreeChangeListener(listener));
+        AbstractDOMDataTreeChangeListenerRegistration<DOMDataTreeChangeListener> registration =
+                super.registerTreeChangeListener(treeId, listener);
 
-        onRegistration.accept(
-            new org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration<
-                    DOMDataTreeChangeListener>(listener) {
-                @Override
-                protected void removeRegistration() {
-                    registration.close();
-                }
-            });
+        onRegistration.accept(registration);
 
         if (initialState.isPresent()) {
             notifySingleListener(treeId, listener, initialState.get(), logContext);
@@ -91,23 +84,4 @@ final class DefaultShardDataTreeChangeListenerPublisher extends AbstractDOMStore
         publisher.registerTreeChangeListener(treeId, listener, Optional.absent(), noop -> { /* NOOP */ });
         publisher.publishChanges(state);
     }
-
-    private static class ForwardingDOMDataTreeChangeListener
-            implements org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener {
-        final DOMDataTreeChangeListener delegate;
-
-        ForwardingDOMDataTreeChangeListener(DOMDataTreeChangeListener delegate) {
-            this.delegate = delegate;
-        }
-
-        @Override
-        public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
-            delegate.onDataTreeChanged(changes);
-        }
-
-        @Override
-        public String toString() {
-            return delegate.toString();
-        }
-    }
 }
index 2c1e0a7..5811506 100644 (file)
@@ -14,10 +14,10 @@ import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 
 /**
  * Implements a distributed DOMStore using Akka Patterns.ask().
index b678d17..861cd61 100644 (file)
@@ -8,7 +8,12 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
+import org.opendaylight.mdsal.dom.spi.store.DOMStore;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 /**
  * The public interface exposed vi a DistributedDataStore via the OSGi registry.
@@ -17,5 +22,9 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStore;
  */
 public interface DistributedDataStoreInterface extends DOMStore {
 
+    @Deprecated
+    <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L>
+        registerChangeListener(YangInstanceIdentifier path, L listener, DataChangeScope scope);
+
     ActorContext getActorContext();
-}
\ No newline at end of file
+}
index 6cda0de..dd3155b 100644 (file)
@@ -12,7 +12,7 @@ import akka.actor.ActorSelection;
 import com.google.common.base.Preconditions;
 import java.util.Collection;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 009c964..b9c2e13 100644 (file)
@@ -13,8 +13,8 @@ import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
 import org.opendaylight.controller.cluster.datastore.messages.AbstractRead;
 import org.opendaylight.controller.cluster.datastore.modification.AbstractModification;
-import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.mdsal.common.api.DataStoreUnavailableException;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Future;
index a155e5e..5459cfa 100644 (file)
@@ -60,9 +60,9 @@ import org.opendaylight.controller.cluster.datastore.utils.PruningDataTreeModifi
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.common.api.OptimisticLockFailedException;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.concepts.Identifier;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
index 7f20bee..3b4fdc9 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.datastore;
 
 import com.google.common.base.Optional;
 import java.util.function.Consumer;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
index 0203192..f439758 100644 (file)
@@ -13,7 +13,7 @@ import akka.actor.Props;
 import com.google.common.base.Optional;
 import java.util.function.Consumer;
 import javax.annotation.concurrent.NotThreadSafe;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
index 72d0ee8..356300e 100644 (file)
@@ -11,7 +11,7 @@ import akka.actor.Props;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.function.Consumer;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
index 033cbea..a600be9 100644 (file)
@@ -15,7 +15,7 @@ import java.util.Arrays;
 import java.util.List;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Future;
index 91658a2..1e5f58f 100644 (file)
@@ -23,11 +23,11 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain;
 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.TransactionChainClosedException;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index d7f4935..56e8e6e 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import scala.concurrent.Future;
 
index b774fc4..7bb62aa 100644 (file)
@@ -36,10 +36,10 @@ import org.opendaylight.controller.cluster.datastore.modification.MergeModificat
 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.cluster.datastore.utils.NormalizedNodeAggregator;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.core.spi.data.AbstractDOMStoreTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
 import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/compat/LegacyDOMStoreAdapter.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/compat/LegacyDOMStoreAdapter.java
new file mode 100644 (file)
index 0000000..114193f
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2016 Brocade Communications 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.controller.cluster.datastore.compat;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Adapter between the legacy controller API-based DOMStore and the mdsal API-based DOMStore.
+ *
+ * @author Thomas Pantelis
+ */
+public class LegacyDOMStoreAdapter extends ForwardingObject implements DOMStore, AutoCloseable {
+    public static final ExceptionMapper<ReadFailedException> READ_EX_MAPPER =
+            new ExceptionMapper<ReadFailedException>("read", ReadFailedException.class) {
+        @Override
+        protected ReadFailedException newWithCause(String message, Throwable cause) {
+            if (cause instanceof org.opendaylight.mdsal.common.api.ReadFailedException) {
+                return new ReadFailedException(cause.getMessage(), cause.getCause());
+            }
+
+            return new ReadFailedException(message, cause);
+        }
+    };
+
+    private final DistributedDataStoreInterface delegate;
+
+    public LegacyDOMStoreAdapter(DistributedDataStoreInterface delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public DOMStoreReadTransaction newReadOnlyTransaction() {
+        return new DOMStoreTransactionAdapter(delegate().newReadOnlyTransaction());
+    }
+
+    @Override
+    public DOMStoreWriteTransaction newWriteOnlyTransaction() {
+        return new DOMStoreTransactionAdapter(delegate().newWriteOnlyTransaction());
+    }
+
+    @Override
+    public DOMStoreReadWriteTransaction newReadWriteTransaction() {
+        return new DOMStoreTransactionAdapter(delegate().newReadWriteTransaction());
+    }
+
+    @Override
+    public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L>
+            registerChangeListener(YangInstanceIdentifier path, L listener, DataChangeScope scope) {
+        return delegate().registerChangeListener(path, listener, scope);
+    }
+
+    @Override
+    public DOMStoreTransactionChain createTransactionChain() {
+        final org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain delegateChain =
+                delegate().createTransactionChain();
+        return new DOMStoreTransactionChain() {
+            @Override
+            public DOMStoreReadTransaction newReadOnlyTransaction() {
+                return new DOMStoreTransactionAdapter(delegateChain.newReadOnlyTransaction());
+            }
+
+            @Override
+            public DOMStoreWriteTransaction newWriteOnlyTransaction() {
+                return new DOMStoreTransactionAdapter(delegateChain.newWriteOnlyTransaction());
+            }
+
+            @Override
+            public DOMStoreReadWriteTransaction newReadWriteTransaction() {
+                return new DOMStoreTransactionAdapter(delegateChain.newReadWriteTransaction());
+            }
+
+            @Override
+            public void close() {
+                delegateChain.close();
+            }
+        };
+    }
+
+    @Override
+    public void close() {
+    }
+
+    @Override
+    protected DistributedDataStoreInterface delegate() {
+        return delegate;
+    }
+
+    private static class DOMStoreTransactionAdapter implements DOMStoreReadWriteTransaction {
+        private final org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction readDelegate;
+        private final org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction writeDelegate;
+        private final Object identifier;
+
+        DOMStoreTransactionAdapter(@Nonnull org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction readDelegate) {
+            this.readDelegate = Preconditions.checkNotNull(readDelegate);
+            this.identifier = readDelegate.getIdentifier();
+            this.writeDelegate = null;
+        }
+
+        DOMStoreTransactionAdapter(
+                @Nonnull org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction writeDelegate) {
+            this.writeDelegate = Preconditions.checkNotNull(writeDelegate);
+            this.identifier = writeDelegate.getIdentifier();
+            this.readDelegate = null;
+        }
+
+        DOMStoreTransactionAdapter(
+                @Nonnull org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction rwDelegate) {
+            this.readDelegate = Preconditions.checkNotNull(rwDelegate);
+            this.writeDelegate = rwDelegate;
+            this.identifier = readDelegate.getIdentifier();
+        }
+
+        @Override
+        public Object getIdentifier() {
+            return identifier;
+        }
+
+        @Override
+        public void close() {
+            if (writeDelegate != null) {
+                writeDelegate.close();
+            } else {
+                readDelegate.close();
+            }
+        }
+
+        @Override
+        public void write(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+            writeDelegate.write(path, data);
+        }
+
+        @Override
+        public void merge(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+            writeDelegate.merge(path, data);
+        }
+
+        @Override
+        public void delete(YangInstanceIdentifier path) {
+            writeDelegate.delete(path);
+        }
+
+        @Override
+        public DOMStoreThreePhaseCommitCohort ready() {
+            final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort cohort = writeDelegate.ready();
+            return new DOMStoreThreePhaseCommitCohort() {
+                @Override
+                public ListenableFuture<Boolean> canCommit() {
+                    return cohort.canCommit();
+                }
+
+                @Override
+                public ListenableFuture<Void> preCommit() {
+                    return cohort.preCommit();
+                }
+
+                @Override
+                public ListenableFuture<Void> commit() {
+                    return cohort.commit();
+                }
+
+                @Override
+                public ListenableFuture<Void> abort() {
+                    return cohort.abort();
+                }
+            };
+        }
+
+        @Override
+        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(YangInstanceIdentifier path) {
+            return MappingCheckedFuture.create(readDelegate.read(path), READ_EX_MAPPER);
+        }
+
+        @Override
+        public CheckedFuture<Boolean, ReadFailedException> exists(YangInstanceIdentifier path) {
+            return MappingCheckedFuture.create(readDelegate.exists(path), READ_EX_MAPPER);
+        }
+    }
+}
index 0b3ac7a..cf1fd43 100644 (file)
@@ -14,7 +14,7 @@ import static org.opendaylight.controller.cluster.datastore.entityownership.Enti
 
 import com.google.common.base.Optional;
 import org.opendaylight.controller.cluster.datastore.ShardDataTree;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.EntityType;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
index 729b7d8..005de87 100644 (file)
@@ -27,7 +27,7 @@ import java.util.Map.Entry;
 import org.opendaylight.controller.cluster.datastore.ShardDataTree;
 import org.opendaylight.controller.cluster.datastore.entityownership.messages.CandidateAdded;
 import org.opendaylight.controller.cluster.datastore.entityownership.messages.CandidateRemoved;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.EntityType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.entity.type.entity.Candidate;
 import org.opendaylight.yangtools.yang.common.QName;
index 187d252..fdd66c9 100644 (file)
@@ -112,7 +112,6 @@ import org.opendaylight.controller.cluster.sharding.PrefixedShardConfigUpdateHan
 import org.opendaylight.controller.cluster.sharding.messages.InitConfigListener;
 import org.opendaylight.controller.cluster.sharding.messages.PrefixShardCreated;
 import org.opendaylight.controller.cluster.sharding.messages.PrefixShardRemoved;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -653,7 +652,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
         configuration.addPrefixShardConfiguration(config);
 
         final Builder builder = newShardDatastoreContextBuilder(shardName);
-        builder.logicalStoreType(LogicalDatastoreType.valueOf(config.getPrefix().getDatastoreType().name()))
+        builder.logicalStoreType(config.getPrefix().getDatastoreType())
                 .storeRoot(config.getPrefix().getRootIdentifier());
         DatastoreContext shardDatastoreContext = builder.build();
 
index f587889..edbfa1f 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.datastore.utils;
 
 import com.google.common.base.Optional;
 import java.util.List;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
index 759410a..b4b4444 100644 (file)
@@ -154,8 +154,8 @@ public class DistributedShardChangePublisher
                 findNodeFor(listenerPath.getPathArguments());
 
         // register listener in CDS
-        final ProxyRegistration proxyReg = new ProxyRegistration(distributedDataStore
-                .registerProxyListener(shardLookup, listenerPath, listener), listener);
+        ListenerRegistration<DOMDataTreeChangeListener> listenerReg = distributedDataStore
+                .registerProxyListener(shardLookup, listenerPath, listener);
 
         @SuppressWarnings("unchecked")
         final AbstractDOMDataTreeChangeListenerRegistration<L> registration =
@@ -165,7 +165,7 @@ public class DistributedShardChangePublisher
                     listener.close();
                     DistributedShardChangePublisher.this.removeRegistration(node, this);
                     registrationRemoved(this);
-                    proxyReg.close();
+                    listenerReg.close();
                 }
             };
         addRegistration(node, registration);
@@ -194,30 +194,6 @@ public class DistributedShardChangePublisher
         return listenerPathArgs;
     }
 
-    private static final class ProxyRegistration implements ListenerRegistration<DOMDataTreeChangeListener> {
-
-        private final ListenerRegistration<org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener> proxy;
-        private final DOMDataTreeChangeListener listener;
-
-        private ProxyRegistration(
-                final ListenerRegistration<
-                        org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener> proxy,
-                final DOMDataTreeChangeListener listener) {
-            this.proxy = proxy;
-            this.listener = listener;
-        }
-
-        @Override
-        public DOMDataTreeChangeListener getInstance() {
-            return listener;
-        }
-
-        @Override
-        public void close() {
-            proxy.close();
-        }
-    }
-
     synchronized DataTreeCandidate applyChanges(final YangInstanceIdentifier listenerPath,
             final Collection<DataTreeCandidate> changes) throws DataValidationFailedException {
         final DataTreeModification modification = dataTree.takeSnapshot().newModification();
index ac209e3..0fdd25b 100644 (file)
@@ -27,8 +27,9 @@ import org.opendaylight.controller.cluster.datastore.shardstrategy.PrefixShardSt
 import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils;
 import org.opendaylight.controller.cluster.sharding.messages.PrefixShardCreated;
 import org.opendaylight.controller.cluster.sharding.messages.PrefixShardRemoved;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -53,8 +54,7 @@ public class PrefixedShardConfigUpdateHandler {
     private final ActorRef handlingActor;
     private final MemberName memberName;
 
-    private final EnumMap<LogicalDatastoreType,
-            ListenerRegistration<org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener>> registrations =
+    private final EnumMap<LogicalDatastoreType,ListenerRegistration<DOMDataTreeChangeListener>> registrations =
             new EnumMap<>(LogicalDatastoreType.class);
 
     public PrefixedShardConfigUpdateHandler(final ActorRef handlingActor, final MemberName memberName) {
index 18071e5..79b276d 100644 (file)
@@ -10,12 +10,14 @@ package org.opendaylight.controller.config.yang.config.distributed_datastore_pro
 
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
+import org.opendaylight.controller.cluster.datastore.compat.LegacyDOMStoreAdapter;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.osgi.framework.BundleContext;
 
+@Deprecated
 public class DistributedConfigDataStoreProviderModule extends AbstractDistributedConfigDataStoreProviderModule {
     private BundleContext bundleContext;
 
@@ -48,7 +50,12 @@ public class DistributedConfigDataStoreProviderModule extends AbstractDistribute
         WaitingServiceTracker<DistributedDataStoreInterface> tracker = WaitingServiceTracker.create(
                 DistributedDataStoreInterface.class, bundleContext, "(type=distributed-config)");
         DistributedDataStoreInterface delegate = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
-        return new ForwardingDistributedDataStore(delegate, tracker);
+        return new LegacyDOMStoreAdapter(delegate) {
+            @Override
+            public void close() {
+                tracker.close();
+            }
+        };
     }
 
     public static DatastoreContext newDatastoreContext() {
index 8a87466..e9c3454 100644 (file)
@@ -10,12 +10,14 @@ package org.opendaylight.controller.config.yang.config.distributed_datastore_pro
 
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
+import org.opendaylight.controller.cluster.datastore.compat.LegacyDOMStoreAdapter;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.osgi.framework.BundleContext;
 
+@Deprecated
 public class DistributedOperationalDataStoreProviderModule
         extends AbstractDistributedOperationalDataStoreProviderModule {
     private BundleContext bundleContext;
@@ -48,7 +50,12 @@ public class DistributedOperationalDataStoreProviderModule
         WaitingServiceTracker<DistributedDataStoreInterface> tracker = WaitingServiceTracker.create(
                 DistributedDataStoreInterface.class, bundleContext, "(type=distributed-operational)");
         DistributedDataStoreInterface delegate = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
-        return new ForwardingDistributedDataStore(delegate, tracker);
+        return new LegacyDOMStoreAdapter(delegate) {
+            @Override
+            public void close() {
+                tracker.close();
+            }
+        };
     }
 
     public static DatastoreContext newDatastoreContext() {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/ForwardingDistributedDataStore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/ForwardingDistributedDataStore.java
deleted file mode 100644 (file)
index de74726..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2016 Brocade Communications 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.controller.config.yang.config.distributed_datastore_provider;
-
-import com.google.common.collect.ForwardingObject;
-import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
-import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * DOMStore implementation that forwards to a delegate.
- *
- * @author Thomas Pantelis
- */
-class ForwardingDistributedDataStore extends ForwardingObject implements DistributedDataStoreInterface, AutoCloseable {
-    private final DistributedDataStoreInterface delegate;
-    private final AutoCloseable closeable;
-
-    ForwardingDistributedDataStore(DistributedDataStoreInterface delegate, AutoCloseable closeable) {
-        this.delegate = delegate;
-        this.closeable = closeable;
-    }
-
-    @Override
-    public DOMStoreReadTransaction newReadOnlyTransaction() {
-        return delegate().newReadOnlyTransaction();
-    }
-
-    @Override
-    public DOMStoreWriteTransaction newWriteOnlyTransaction() {
-        return delegate().newWriteOnlyTransaction();
-    }
-
-    @Override
-    public DOMStoreReadWriteTransaction newReadWriteTransaction() {
-        return delegate().newReadWriteTransaction();
-    }
-
-    @Override
-    public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L>
-            registerChangeListener(YangInstanceIdentifier path, L listener, DataChangeScope scope) {
-        return delegate().registerChangeListener(path, listener, scope);
-    }
-
-    @Override
-    public DOMStoreTransactionChain createTransactionChain() {
-        return delegate().createTransactionChain();
-    }
-
-    @Override
-    public ActorContext getActorContext() {
-        return delegate().getActorContext();
-    }
-
-    @Override
-    public void close() throws Exception {
-        closeable.close();
-    }
-
-    @Override
-    protected DistributedDataStoreInterface delegate() {
-        return delegate;
-    }
-}
index 8c6723b..395930b 100644 (file)
     <argument ref="commitStatsTracker"/>
   </bean>
 
-  <service ref="clusteredDOMDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
+  <service ref="clusteredDOMDataBroker" interface="org.opendaylight.mdsal.dom.api.DOMDataBroker"
+          odl:type="default"/>
+
+  <bean id="legacyDOMDataBroker" class="org.opendaylight.controller.cluster.databroker.compat.LegacyDOMDataBrokerAdapter">
+    <argument ref="clusteredDOMDataBroker"/>
+  </bean>
+
+  <service ref="legacyDOMDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
           odl:type="default"/>
 
   <!-- JMX beans for the data broker -->
index 69265dd..5263ab6 100644 (file)
@@ -18,9 +18,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 
 public class AbstractDOMBrokerWriteTransactionTest {
 
@@ -88,4 +88,4 @@ public class AbstractDOMBrokerWriteTransactionTest {
             abstractDOMBrokerWriteTransactionTestImpl.cancel();
         }
     }
-}
\ No newline at end of file
+}
index d7d774d..cf08d33 100644 (file)
@@ -26,10 +26,10 @@ import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class ClientBackedDataStoreTest {
index db81e5b..e369fd5 100644 (file)
@@ -17,7 +17,7 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -66,4 +66,4 @@ public class ClientBackedReadWriteTransactionTest
     public void testExists() throws Exception {
         Assert.assertTrue(object().exists(YangInstanceIdentifier.EMPTY).get());
     }
-}
\ No newline at end of file
+}
index 8091f70..78a5c4b 100644 (file)
@@ -65,8 +65,8 @@ public class ClientBackedWriteTransactionTest extends ClientBackedTransactionTes
 
     @Test
     public void testReady() throws Exception {
-        final org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort result = object().ready();
+        final DOMStoreThreePhaseCommitCohort result = object().ready();
         Assert.assertNotNull(result);
         Mockito.verify(delegate).ready();
     }
-}
\ No newline at end of file
+}
index 9044728..ca255c8 100644 (file)
@@ -48,26 +48,26 @@ import org.mockito.InOrder;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
-import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.DataStoreUnavailableException;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionChainListener;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStore;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
@@ -78,7 +78,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
  */
 public class ConcurrentDOMDataBrokerTest {
 
-    private final DOMDataWriteTransaction transaction = mock(DOMDataWriteTransaction.class);
+    private final DOMDataTreeWriteTransaction transaction = mock(DOMDataTreeWriteTransaction.class);
     private final DOMStoreThreePhaseCommitCohort mockCohort1 = mock(DOMStoreThreePhaseCommitCohort.class);
     private final DOMStoreThreePhaseCommitCohort mockCohort2 = mock(DOMStoreThreePhaseCommitCohort.class);
     private final ThreadPoolExecutor futureExecutor =
@@ -89,8 +89,7 @@ public class ConcurrentDOMDataBrokerTest {
     public void setup() {
         doReturn("tx").when(transaction).getIdentifier();
 
-        DOMStore store = new InMemoryDOMDataStore("OPER",
-            MoreExecutors.newDirectExecutorService());
+        DOMStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
 
         coordinator = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, store),
                 futureExecutor);
@@ -354,7 +353,7 @@ public class ConcurrentDOMDataBrokerTest {
         try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(
                 LogicalDatastoreType.OPERATIONAL, operationalDomStore, LogicalDatastoreType.CONFIGURATION,
                 configDomStore), futureExecutor)) {
-            DOMDataReadWriteTransaction dataTxn = dataBroker.newReadWriteTransaction();
+            DOMDataTreeReadWriteTransaction dataTxn = dataBroker.newReadWriteTransaction();
 
             dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
             dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
@@ -383,7 +382,7 @@ public class ConcurrentDOMDataBrokerTest {
         try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(
                 LogicalDatastoreType.OPERATIONAL, operationalDomStore, LogicalDatastoreType.CONFIGURATION,
                 configDomStore), futureExecutor)) {
-            DOMDataWriteTransaction dataTxn = dataBroker.newWriteOnlyTransaction();
+            DOMDataTreeWriteTransaction dataTxn = dataBroker.newWriteOnlyTransaction();
 
             dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
             dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
@@ -410,7 +409,7 @@ public class ConcurrentDOMDataBrokerTest {
         try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(
                 LogicalDatastoreType.OPERATIONAL, operationalDomStore, LogicalDatastoreType.CONFIGURATION,
                 configDomStore), futureExecutor)) {
-            DOMDataReadOnlyTransaction dataTxn = dataBroker.newReadOnlyTransaction();
+            DOMDataTreeReadTransaction dataTxn = dataBroker.newReadOnlyTransaction();
 
             dataTxn.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
             dataTxn.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
@@ -444,14 +443,14 @@ public class ConcurrentDOMDataBrokerTest {
                 LogicalDatastoreType.OPERATIONAL, operationalDomStore, LogicalDatastoreType.CONFIGURATION,
                 configDomStore), futureExecutor) {
             @Override
-            public CheckedFuture<Void, TransactionCommitFailedException> submit(DOMDataWriteTransaction writeTx,
+            public CheckedFuture<Void, TransactionCommitFailedException> submit(DOMDataTreeWriteTransaction writeTx,
                     Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
                 commitCohorts.addAll(cohorts);
                 latch.countDown();
                 return super.submit(writeTx, cohorts);
             }
         }) {
-            DOMDataReadWriteTransaction domDataReadWriteTransaction = dataBroker.newReadWriteTransaction();
+            DOMDataTreeReadWriteTransaction domDataReadWriteTransaction = dataBroker.newReadWriteTransaction();
 
             domDataReadWriteTransaction.delete(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
 
@@ -491,14 +490,14 @@ public class ConcurrentDOMDataBrokerTest {
                 configDomStore), futureExecutor) {
             @Override
             @SuppressWarnings("checkstyle:hiddenField")
-            public CheckedFuture<Void, TransactionCommitFailedException> submit(DOMDataWriteTransaction transaction,
+            public CheckedFuture<Void, TransactionCommitFailedException> submit(DOMDataTreeWriteTransaction writeTx,
                     Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
                 commitCohorts.addAll(cohorts);
                 latch.countDown();
-                return super.submit(transaction, cohorts);
+                return super.submit(writeTx, cohorts);
             }
         }) {
-            DOMDataReadWriteTransaction domDataReadWriteTransaction = dataBroker.newReadWriteTransaction();
+            DOMDataTreeReadWriteTransaction domDataReadWriteTransaction = dataBroker.newReadWriteTransaction();
 
             domDataReadWriteTransaction.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY,
                     mock(NormalizedNode.class));
@@ -543,7 +542,7 @@ public class ConcurrentDOMDataBrokerTest {
             DOMTransactionChain transactionChain = dataBroker.createTransactionChain(
                     mock(TransactionChainListener.class));
 
-            DOMDataWriteTransaction domDataWriteTransaction = transactionChain.newWriteOnlyTransaction();
+            DOMDataTreeWriteTransaction domDataWriteTransaction = transactionChain.newWriteOnlyTransaction();
 
             verify(mockChain, never()).newWriteOnlyTransaction();
 
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/compat/LegacyDOMDataBrokerAdapterTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/compat/LegacyDOMDataBrokerAdapterTest.java
new file mode 100644 (file)
index 0000000..f908792
--- /dev/null
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2017 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.controller.cluster.databroker.compat;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.cluster.databroker.ConcurrentDOMDataBroker;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
+import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
+import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+
+/**
+ * Unit tests for LegacyDOMDataBrokerAdapter.
+ *
+ * @author Thomas Pantelis
+ */
+public class LegacyDOMDataBrokerAdapterTest {
+    @Mock
+    private TestDOMStore mockOperStore;
+
+    @Mock
+    private TestDOMStore mockConfigStore;
+
+    @Mock
+    private DOMStoreReadTransaction mockReadTx;
+
+    @Mock
+    private DOMStoreWriteTransaction mockWriteTx;
+
+    @Mock
+    private DOMStoreReadWriteTransaction mockReadWriteTx;
+
+    @Mock
+    private DOMStoreThreePhaseCommitCohort mockCommitCohort;
+
+    private LegacyDOMDataBrokerAdapter adapter;
+    private NormalizedNode<?,?> dataNode;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+
+        ConcurrentDOMDataBroker backendBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(
+                org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL, mockOperStore,
+                org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, mockConfigStore),
+                MoreExecutors.newDirectExecutorService());
+
+        adapter = new LegacyDOMDataBrokerAdapter(backendBroker);
+
+        doReturn(Futures.immediateFuture(Boolean.TRUE)).when(mockCommitCohort).canCommit();
+        doReturn(Futures.immediateFuture(null)).when(mockCommitCohort).preCommit();
+        doReturn(Futures.immediateFuture(null)).when(mockCommitCohort).commit();
+        doReturn(Futures.immediateFuture(null)).when(mockCommitCohort).abort();
+
+        dataNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+        doReturn(mockWriteTx).when(mockConfigStore).newWriteOnlyTransaction();
+        doNothing().when(mockWriteTx).write(TestModel.TEST_PATH, dataNode);
+        doNothing().when(mockWriteTx).merge(TestModel.TEST_PATH, dataNode);
+        doNothing().when(mockWriteTx).delete(TestModel.TEST_PATH);
+        doNothing().when(mockWriteTx).close();
+        doReturn(mockCommitCohort).when(mockWriteTx).ready();
+
+        doReturn(mockReadTx).when(mockConfigStore).newReadOnlyTransaction();
+        doReturn(Futures.immediateCheckedFuture(Optional.of(dataNode))).when(mockReadTx).read(TestModel.TEST_PATH);
+        doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(mockReadTx).exists(TestModel.TEST_PATH);
+
+        doReturn(mockReadWriteTx).when(mockConfigStore).newReadWriteTransaction();
+        doNothing().when(mockReadWriteTx).write(TestModel.TEST_PATH, dataNode);
+        doReturn(mockCommitCohort).when(mockReadWriteTx).ready();
+        doReturn(Futures.immediateCheckedFuture(Optional.of(dataNode))).when(mockReadWriteTx).read(TestModel.TEST_PATH);
+
+        DOMStoreTransactionChain mockTxChain = mock(DOMStoreTransactionChain.class);
+        doReturn(mockReadTx).when(mockTxChain).newReadOnlyTransaction();
+        doReturn(mockWriteTx).when(mockTxChain).newWriteOnlyTransaction();
+        doReturn(mockReadWriteTx).when(mockTxChain).newReadWriteTransaction();
+        doReturn(mockTxChain).when(mockConfigStore).createTransactionChain();
+
+        doReturn(mock(DOMStoreTransactionChain.class)).when(mockOperStore).createTransactionChain();
+    }
+
+    @Test
+    public void testReadOnlyTransaction() throws Exception {
+        DOMDataReadOnlyTransaction tx = adapter.newReadOnlyTransaction();
+
+        // Test successful read
+
+        CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
+                tx.read(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
+        Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
+        assertEquals("isPresent", true, readOptional.isPresent());
+        assertEquals("NormalizedNode", dataNode, readOptional.get());
+
+        // Test successful exists
+
+        CheckedFuture<Boolean, ReadFailedException> existsFuture =
+                tx.exists(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
+        assertEquals("exists", Boolean.TRUE, existsFuture.get());
+
+        // Test failed read
+
+        String errorMsg = "mock read error";
+        Throwable cause = new RuntimeException();
+        doReturn(Futures.immediateFailedCheckedFuture(new org.opendaylight.mdsal.common.api.ReadFailedException(
+                errorMsg, cause))).when(mockReadTx).read(TestModel.TEST_PATH);
+
+        try {
+            tx.read(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH).checkedGet();
+            fail("Expected ReadFailedException");
+        } catch (ReadFailedException e) {
+            assertEquals("getMessage", errorMsg, e.getMessage());
+            assertEquals("getCause", cause, e.getCause());
+        }
+
+        // Test close
+        tx.close();
+        verify(mockReadTx).close();
+    }
+
+    @Test
+    public void testWriteOnlyTransaction() throws Exception {
+        // Test successful write operations and submit
+
+        DOMDataWriteTransaction tx = adapter.newWriteOnlyTransaction();
+
+        tx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+        verify(mockWriteTx).write(TestModel.TEST_PATH, dataNode);
+
+        tx.merge(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+        verify(mockWriteTx).merge(TestModel.TEST_PATH, dataNode);
+
+        tx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
+        verify(mockWriteTx).delete(TestModel.TEST_PATH);
+
+        CheckedFuture<Void, TransactionCommitFailedException> submitFuture = tx.submit();
+        submitFuture.get(5, TimeUnit.SECONDS);
+
+        InOrder inOrder = inOrder(mockCommitCohort);
+        inOrder.verify(mockCommitCohort).canCommit();
+        inOrder.verify(mockCommitCohort).preCommit();
+        inOrder.verify(mockCommitCohort).commit();
+
+        // Test cancel
+
+        tx = adapter.newWriteOnlyTransaction();
+        tx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+        tx.cancel();
+        verify(mockWriteTx).close();
+
+        // Test submit with OptimisticLockFailedException
+
+        String errorMsg = "mock OptimisticLockFailedException";
+        Throwable cause = new ConflictingModificationAppliedException(TestModel.TEST_PATH, "mock");
+        doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.OptimisticLockFailedException(
+                errorMsg, cause))).when(mockCommitCohort).canCommit();
+
+        try {
+            tx = adapter.newWriteOnlyTransaction();
+            tx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+            submitFuture = tx.submit();
+            submitFuture.checkedGet(5, TimeUnit.SECONDS);
+            fail("Expected OptimisticLockFailedException");
+        } catch (OptimisticLockFailedException e) {
+            assertEquals("getMessage", errorMsg, e.getMessage());
+            assertEquals("getCause", cause, e.getCause());
+        }
+
+        // Test submit with TransactionCommitFailedException
+
+        errorMsg = "mock TransactionCommitFailedException";
+        cause = new DataValidationFailedException(TestModel.TEST_PATH, "mock");
+        doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.TransactionCommitFailedException(
+                errorMsg, cause))).when(mockCommitCohort).canCommit();
+
+        try {
+            tx = adapter.newWriteOnlyTransaction();
+            tx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+            submitFuture = tx.submit();
+            submitFuture.checkedGet(5, TimeUnit.SECONDS);
+            fail("Expected TransactionCommitFailedException");
+        } catch (TransactionCommitFailedException e) {
+            assertEquals("getMessage", errorMsg, e.getMessage());
+            assertEquals("getCause", cause, e.getCause());
+        }
+
+        // Test submit with DataStoreUnavailableException
+
+        errorMsg = "mock NoShardLeaderException";
+        cause = new NoShardLeaderException("mock");
+        doReturn(Futures.immediateFailedFuture(cause)).when(mockCommitCohort).canCommit();
+
+        try {
+            tx = adapter.newWriteOnlyTransaction();
+            tx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+            submitFuture = tx.submit();
+            submitFuture.checkedGet(5, TimeUnit.SECONDS);
+            fail("Expected TransactionCommitFailedException");
+        } catch (TransactionCommitFailedException e) {
+            assertEquals("getCause type", DataStoreUnavailableException.class, e.getCause().getClass());
+            assertEquals("Root cause", cause, e.getCause().getCause());
+        }
+
+        // Test submit with RuntimeException
+
+        errorMsg = "mock RuntimeException";
+        cause = new RuntimeException(errorMsg);
+        doReturn(Futures.immediateFailedFuture(cause)).when(mockCommitCohort).canCommit();
+
+        try {
+            tx = adapter.newWriteOnlyTransaction();
+            tx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+            submitFuture = tx.submit();
+            submitFuture.checkedGet(5, TimeUnit.SECONDS);
+            fail("Expected TransactionCommitFailedException");
+        } catch (TransactionCommitFailedException e) {
+            assertEquals("getCause", cause, e.getCause());
+        }
+    }
+
+    @Test
+    public void testReadWriteTransaction() throws Exception {
+        DOMDataReadWriteTransaction tx = adapter.newReadWriteTransaction();
+
+        CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
+                tx.read(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
+        Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
+        assertEquals("isPresent", true, readOptional.isPresent());
+        assertEquals("NormalizedNode", dataNode, readOptional.get());
+
+        tx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+        verify(mockReadWriteTx).write(TestModel.TEST_PATH, dataNode);
+
+        CheckedFuture<Void, TransactionCommitFailedException> submitFuture = tx.submit();
+        submitFuture.get(5, TimeUnit.SECONDS);
+
+        InOrder inOrder = inOrder(mockCommitCohort);
+        inOrder.verify(mockCommitCohort).canCommit();
+        inOrder.verify(mockCommitCohort).preCommit();
+        inOrder.verify(mockCommitCohort).commit();
+    }
+
+    @SuppressWarnings("rawtypes")
+    @Test
+    public void testTransactionChain() throws Exception {
+        TransactionChainListener mockListener = mock(TransactionChainListener.class);
+        doNothing().when(mockListener).onTransactionChainSuccessful(anyObject());
+        doNothing().when(mockListener).onTransactionChainFailed(anyObject(), anyObject(), anyObject());
+
+        DOMTransactionChain chain = adapter.createTransactionChain(mockListener);
+
+        // Test read-only tx
+
+        DOMDataReadOnlyTransaction readTx = chain.newReadOnlyTransaction();
+
+        CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
+                readTx.read(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
+        Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
+        assertEquals("isPresent", true, readOptional.isPresent());
+        assertEquals("NormalizedNode", dataNode, readOptional.get());
+
+        // Test write-only tx
+
+        DOMDataWriteTransaction writeTx = chain.newWriteOnlyTransaction();
+
+        writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+        verify(mockWriteTx).write(TestModel.TEST_PATH, dataNode);
+        CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTx.submit();
+        submitFuture.get(5, TimeUnit.SECONDS);
+
+        InOrder inOrder = inOrder(mockCommitCohort);
+        inOrder.verify(mockCommitCohort).canCommit();
+        inOrder.verify(mockCommitCohort).preCommit();
+        inOrder.verify(mockCommitCohort).commit();
+
+        // Test read-write tx
+
+        DOMDataReadWriteTransaction readWriteTx = chain.newReadWriteTransaction();
+
+        readFuture = readWriteTx.read(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
+        readOptional = readFuture.get();
+        assertEquals("isPresent", true, readOptional.isPresent());
+        assertEquals("NormalizedNode", dataNode, readOptional.get());
+
+        chain.close();
+        verify(mockListener).onTransactionChainSuccessful(chain);
+
+        // Test failed chain
+
+        doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.TransactionCommitFailedException(
+                "mock", (Throwable)null))).when(mockCommitCohort).canCommit();
+
+        chain = adapter.createTransactionChain(mockListener);
+
+        writeTx = chain.newWriteOnlyTransaction();
+
+        try {
+            writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, dataNode);
+            writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
+            fail("Expected TransactionCommitFailedException");
+        } catch (TransactionCommitFailedException e) {
+            // expected
+        }
+
+        ArgumentCaptor<AsyncTransaction> failedTx = ArgumentCaptor.forClass(AsyncTransaction.class);
+        verify(mockListener).onTransactionChainFailed(eq(chain), failedTx.capture(),
+                any(TransactionCommitFailedException.class));
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testDataTreeChangeListener() {
+        DOMDataTreeChangeService domDTCLService =
+                (DOMDataTreeChangeService) adapter.getSupportedExtensions().get(DOMDataTreeChangeService.class);
+        assertNotNull("DOMDataTreeChangeService not found", domDTCLService);
+
+        ArgumentCaptor<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> storeDTCL =
+                ArgumentCaptor.forClass(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener.class);
+        ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> mockReg =
+                mock(ListenerRegistration.class);
+        doNothing().when(mockReg).close();
+        doAnswer(invocation -> storeDTCL.getValue()).when(mockReg).getInstance();
+        doReturn(mockReg).when(mockConfigStore).registerTreeChangeListener(eq(TestModel.TEST_PATH),
+                storeDTCL.capture());
+
+        DOMDataTreeChangeListener brokerDTCL = mock(DOMDataTreeChangeListener.class);
+        ListenerRegistration<DOMDataTreeChangeListener> reg = domDTCLService.registerDataTreeChangeListener(
+                new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH), brokerDTCL);
+        assertEquals("getInstance", brokerDTCL, reg.getInstance());
+
+        Collection<DataTreeCandidate> changes = Arrays.asList(mock(DataTreeCandidate.class));
+        storeDTCL.getValue().onDataTreeChanged(changes);
+        verify(brokerDTCL).onDataTreeChanged(changes);
+
+        reg.close();
+        verify(mockReg).close();
+
+        // Test ClusteredDOMDataTreeChangeListener
+
+        ArgumentCaptor<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> storeClusteredDTCL =
+                ArgumentCaptor.forClass(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener.class);
+        mockReg = mock(ListenerRegistration.class);
+        doReturn(mockReg).when(mockConfigStore).registerTreeChangeListener(eq(TestModel.TEST_PATH),
+                storeClusteredDTCL.capture());
+
+        final ClusteredDOMDataTreeChangeListener brokerClusteredDTCL = mock(ClusteredDOMDataTreeChangeListener.class);
+        domDTCLService.registerDataTreeChangeListener(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
+                TestModel.TEST_PATH), brokerClusteredDTCL);
+
+        assertTrue("Expected ClusteredDOMDataTreeChangeListener: " + storeClusteredDTCL.getValue(),
+                storeClusteredDTCL.getValue()
+                    instanceof org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener);
+        storeClusteredDTCL.getValue().onDataTreeChanged(changes);
+        verify(brokerClusteredDTCL).onDataTreeChanged(changes);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testDataTreeCommitCohortRegistry() {
+        DOMDataTreeCommitCohortRegistry domCohortRegistry = (DOMDataTreeCommitCohortRegistry)
+                adapter.getSupportedExtensions().get(DOMDataTreeCommitCohortRegistry.class);
+        assertNotNull("DOMDataTreeCommitCohortRegistry not found", domCohortRegistry);
+
+        DOMDataTreeCommitCohort mockCohort = mock(DOMDataTreeCommitCohort.class);
+        org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier treeId =
+                new org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier(
+                    org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
+        DOMDataTreeCommitCohortRegistration<DOMDataTreeCommitCohort> mockReg =
+                mock(DOMDataTreeCommitCohortRegistration.class);
+        doReturn(mockReg).when(mockConfigStore).registerCommitCohort(treeId, mockCohort);
+
+        DOMDataTreeCommitCohortRegistration<DOMDataTreeCommitCohort> reg = domCohortRegistry.registerCommitCohort(
+                treeId, mockCohort);
+        assertEquals("DOMDataTreeCommitCohortRegistration", mockReg, reg);
+
+        verify(mockConfigStore).registerCommitCohort(treeId, mockCohort);
+    }
+
+    @Test
+    public void testDataChangeListener() {
+        DOMDataChangeListener listener = mock(DOMDataChangeListener.class);
+        ListenerRegistration<DOMDataChangeListener> mockReg = mock(ListenerRegistration.class);
+        doReturn(mockReg).when(mockConfigStore).registerChangeListener(
+                TestModel.TEST_PATH, listener, DataChangeScope.ONE);
+
+        ListenerRegistration<DOMDataChangeListener> reg = adapter.registerDataChangeListener(
+                LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, listener, DataChangeScope.ONE);
+        assertEquals("ListenerRegistration<DOMDataChangeListener>", mockReg, reg);
+
+        verify(mockConfigStore).registerChangeListener(TestModel.TEST_PATH, listener, DataChangeScope.ONE);
+    }
+
+    private interface TestDOMStore extends DistributedDataStoreInterface, DOMStoreTreeChangePublisher,
+            org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry {
+    }
+}
index afa4627..0d35a17 100644 (file)
@@ -75,8 +75,8 @@ import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration;
 import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
index 7316eef..726b290 100644 (file)
@@ -21,7 +21,7 @@ import org.mockito.Mockito;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChangedReply;
 import org.opendaylight.controller.cluster.datastore.messages.EnableNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 
 public class DataTreeChangeListenerActorTest extends AbstractActorTest {
index 7b23260..399b3e2 100644 (file)
@@ -39,8 +39,8 @@ import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNo
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import scala.concurrent.ExecutionContextExecutor;
 import scala.concurrent.Future;
index 5a131cd..62dba19 100644 (file)
@@ -41,8 +41,6 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.mdsal.common.api.DataValidationFailedException;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.common.api.PostCanCommitStep;
@@ -51,6 +49,8 @@ import org.opendaylight.mdsal.common.api.ThreePhaseCommitStep;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
index b9d6f46..a735f26 100644 (file)
@@ -19,8 +19,8 @@ import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 
 /**
  * Unit tests for DatastoreContextIntrospector.
index d079868..2e5c69b 100644 (file)
@@ -69,20 +69,20 @@ import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.common.api.TransactionChainClosedException;
+import org.opendaylight.mdsal.common.api.TransactionChainListener;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStore;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -935,14 +935,14 @@ public class DistributedDataStoreIntegrationTest {
 
                     final List<CheckedFuture<Void, TransactionCommitFailedException>> futures = new ArrayList<>();
 
-                    final DOMDataWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
+                    final DOMDataTreeWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
                     writeTx.put(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, CarsModel.emptyContainer());
                     writeTx.put(LogicalDatastoreType.CONFIGURATION, CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
                     futures.add(writeTx.submit());
 
                     int numCars = 100;
                     for (int i = 0; i < numCars; i++) {
-                        final DOMDataReadWriteTransaction rwTx = txChain.newReadWriteTransaction();
+                        final DOMDataTreeReadWriteTransaction rwTx = txChain.newReadWriteTransaction();
 
                         rwTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.newCarPath("car" + i),
                                 CarsModel.newCarEntry("car" + i, BigInteger.valueOf(20000)));
@@ -1092,7 +1092,7 @@ public class DistributedDataStoreIntegrationTest {
                     final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
                     final DOMTransactionChain txChain = broker.createTransactionChain(listener);
 
-                    final DOMDataReadWriteTransaction writeTx = txChain.newReadWriteTransaction();
+                    final DOMDataTreeReadWriteTransaction writeTx = txChain.newReadWriteTransaction();
 
                     writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH,
                             PeopleModel.emptyContainer());
@@ -1135,7 +1135,7 @@ public class DistributedDataStoreIntegrationTest {
                     final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
                     final DOMTransactionChain txChain = broker.createTransactionChain(listener);
 
-                    final DOMDataReadWriteTransaction writeTx = txChain.newReadWriteTransaction();
+                    final DOMDataTreeWriteTransaction writeTx = txChain.newReadWriteTransaction();
 
                     writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH,
                             PeopleModel.emptyContainer());
index c09111e..9b2edfa 100644 (file)
@@ -80,17 +80,17 @@ import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionChainListener;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStore;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@@ -516,7 +516,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
         final DOMTransactionChain txChain = broker.createTransactionChain(listener);
 
-        final DOMDataWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
+        final DOMDataTreeWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
 
         final ContainerNode invalidData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
                 new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME))
@@ -549,7 +549,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
         final DOMTransactionChain txChain = broker.createTransactionChain(listener);
 
-        final DOMDataWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
+        final DOMDataTreeWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
 
         writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
 
index a917929..82d0535 100644 (file)
@@ -38,11 +38,11 @@ import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.cluster.raft.client.messages.GetOnDemandRaftState;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
index aa38e30..6e060f0 100644 (file)
@@ -54,7 +54,7 @@ import org.opendaylight.controller.cluster.datastore.persisted.CommitTransaction
 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
index 9fd0849..e544186 100644 (file)
@@ -34,10 +34,10 @@ import org.opendaylight.controller.cluster.datastore.messages.BatchedModificatio
 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
 import org.opendaylight.controller.cluster.datastore.shardstrategy.DefaultShardStrategy;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import scala.concurrent.Promise;
index da47b22..5fbf878 100644 (file)
@@ -66,8 +66,8 @@ import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
index c8ef127..2cc33e4 100644 (file)
@@ -57,7 +57,7 @@ import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
 import org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound;
 import org.opendaylight.controller.cluster.raft.utils.EchoActor;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index e1a881f..a441cca 100644 (file)
@@ -22,7 +22,7 @@ import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
index f84e516..5687755 100644 (file)
@@ -21,12 +21,12 @@ import org.junit.Test;
 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
index 6546538..7545cd5 100644 (file)
@@ -118,8 +118,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest {
             DatastoreContext.newBuilder()
                     .shardHeartbeatIntervalInMillis(100)
                     .shardElectionTimeoutFactor(2)
-                    .logicalStoreType(
-                            org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION);
+                    .logicalStoreType(LogicalDatastoreType.CONFIGURATION);
 
     private DistributedDataStore leaderDistributedDataStore;
     private DistributedDataStore operDistributedDatastore;

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.