From fc0d0f3899943b85de194451f36cd35ace27cfcc Mon Sep 17 00:00:00 2001 From: Moiz Raja Date: Thu, 12 Jun 2014 17:51:11 -0700 Subject: [PATCH] Add some unimplemented proxy classes related to DOMStore Added basic implementation of DistributedDataStore which does not do much more than fill in the interface and put tests in place. All the Proxy classes are still unimplemented. Change-Id: I9506a05858404a9140f0faf436bd6fb128289693 Signed-off-by: Moiz Raja --- .../md-sal/sal-distributed-datastore/pom.xml | 25 +++++++ ...reProxy.java => DistributedDataStore.java} | 15 +++-- .../datastore/ListenerRegistrationProxy.java | 21 ++++++ .../datastore/TransactionChainProxy.java | 31 +++++++++ .../cluster/datastore/TransactionProxy.java | 56 ++++++++++++++++ .../DistributedDataStoreProviderModule.java | 4 +- .../datastore/DistributedDataStoreTest.java | 65 +++++++++++++++++++ 7 files changed, 209 insertions(+), 8 deletions(-) rename opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/{DOMStoreProxy.java => DistributedDataStore.java} (76%) create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ListenerRegistrationProxy.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java diff --git a/opendaylight/md-sal/sal-distributed-datastore/pom.xml b/opendaylight/md-sal/sal-distributed-datastore/pom.xml index 027477d0c2..e7fcd83328 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/pom.xml +++ b/opendaylight/md-sal/sal-distributed-datastore/pom.xml @@ -47,11 +47,21 @@ sal-binding-api + + org.opendaylight.controller + sal-binding-config + + org.opendaylight.controller sal-common-api + + org.opendaylight.controller + sal-common-util + + org.opendaylight.controller sal-core-spi @@ -62,11 +72,26 @@ concepts + + org.opendaylight.yangtools + yang-binding + + + + org.opendaylight.yangtools + yang-common + + org.opendaylight.yangtools yang-data-api + + org.osgi + org.osgi.core + + org.scala-lang diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DOMStoreProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java similarity index 76% rename from opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DOMStoreProxy.java rename to opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java index 9e005f99f5..1bc554f3ed 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DOMStoreProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java @@ -11,30 +11,33 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -public class DOMStoreProxy implements DOMStore { +/** + * + */ +public class DistributedDataStore implements DOMStore { @Override public >> ListenerRegistration registerChangeListener(InstanceIdentifier path, L listener, AsyncDataBroker.DataChangeScope scope) { - throw new UnsupportedOperationException("registerChangeListener"); + return new ListenerRegistrationProxy(); } @Override public DOMStoreTransactionChain createTransactionChain() { - throw new UnsupportedOperationException("createTransactionChain"); + return new TransactionChainProxy(); } @Override public DOMStoreReadTransaction newReadOnlyTransaction() { - throw new UnsupportedOperationException("newReadOnlyTransaction"); + return new TransactionProxy(); } @Override public DOMStoreWriteTransaction newWriteOnlyTransaction() { - throw new UnsupportedOperationException("newWriteOnlyTransaction"); + return new TransactionProxy(); } @Override public DOMStoreReadWriteTransaction newReadWriteTransaction() { - throw new UnsupportedOperationException("newReadWriteTransaction"); + return new TransactionProxy(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ListenerRegistrationProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ListenerRegistrationProxy.java new file mode 100644 index 0000000000..19e7f198df --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ListenerRegistrationProxy.java @@ -0,0 +1,21 @@ +package org.opendaylight.controller.cluster.datastore; + +import org.opendaylight.yangtools.concepts.ListenerRegistration; + +/** + * ListenerRegistrationProxy acts as a proxy for a ListenerRegistration that was done on a remote shard + * + * Registering a DataChangeListener on the Data Store creates a new instance of the ListenerRegistrationProxy + * The ListenerRegistrationProxy talks to a remote ListenerRegistration actor. + */ +public class ListenerRegistrationProxy implements ListenerRegistration { + @Override + public Object getInstance() { + throw new UnsupportedOperationException("getInstance"); + } + + @Override + public void close() { + throw new UnsupportedOperationException("close"); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java new file mode 100644 index 0000000000..20a74e30da --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java @@ -0,0 +1,31 @@ +package org.opendaylight.controller.cluster.datastore; + +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; + +/** + * TransactionChainProxy acts as a proxy for a DOMStoreTransactionChain created on a remote shard + */ +public class TransactionChainProxy implements DOMStoreTransactionChain{ + @Override + public DOMStoreReadTransaction newReadOnlyTransaction() { + throw new UnsupportedOperationException("newReadOnlyTransaction"); + } + + @Override + public DOMStoreReadWriteTransaction newReadWriteTransaction() { + throw new UnsupportedOperationException("newReadWriteTransaction"); + } + + @Override + public DOMStoreWriteTransaction newWriteOnlyTransaction() { + throw new UnsupportedOperationException("newWriteOnlyTransaction"); + } + + @Override + public void close() { + throw new UnsupportedOperationException("close"); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java new file mode 100644 index 0000000000..c9a630445b --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java @@ -0,0 +1,56 @@ +package org.opendaylight.controller.cluster.datastore; + +import com.google.common.base.Optional; +import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +/** + * TransactionProxy acts as a proxy for one or more transactions that were created on a remote shard + * + * Creating a transaction on the consumer side will create one instance of a transaction proxy. If during + * the transaction reads and writes are done on data that belongs to different shards then a separate transaction will + * be created on each of those shards by the TransactionProxy + * + * The TransactionProxy does not make any guarantees about atomicity or order in which the transactions on the various + * shards will be executed. + * + */ +public class TransactionProxy implements DOMStoreReadWriteTransaction { + @Override + public ListenableFuture>> read(InstanceIdentifier path) { + throw new UnsupportedOperationException("read"); + } + + @Override + public void write(InstanceIdentifier path, NormalizedNode data) { + throw new UnsupportedOperationException("write"); + } + + @Override + public void merge(InstanceIdentifier path, NormalizedNode data) { + throw new UnsupportedOperationException("merge"); + } + + @Override + public void delete(InstanceIdentifier path) { + throw new UnsupportedOperationException("delete"); + } + + @Override + public DOMStoreThreePhaseCommitCohort ready() { + throw new UnsupportedOperationException("ready"); + } + + @Override + public Object getIdentifier() { + throw new UnsupportedOperationException("getIdentifier"); + } + + @Override + public void close() { + throw new UnsupportedOperationException("close"); + } +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedDataStoreProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedDataStoreProviderModule.java index 38bf756cfa..241bcb0a41 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedDataStoreProviderModule.java @@ -1,6 +1,6 @@ package org.opendaylight.controller.config.yang.config.distributed_datastore_provider; -import org.opendaylight.controller.cluster.datastore.DOMStoreProxy; +import org.opendaylight.controller.cluster.datastore.DistributedDataStore; public class DistributedDataStoreProviderModule extends org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedDataStoreProviderModule { public DistributedDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { @@ -18,7 +18,7 @@ public class DistributedDataStoreProviderModule extends org.opendaylight.control @Override public java.lang.AutoCloseable createInstance() { - new DOMStoreProxy(); + new DistributedDataStore(); final class AutoCloseableDistributedDataStore implements AutoCloseable { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java new file mode 100644 index 0000000000..6544f33030 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java @@ -0,0 +1,65 @@ +package org.opendaylight.controller.cluster.datastore; + +import junit.framework.Assert; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; +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.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public class DistributedDataStoreTest { + + private DistributedDataStore distributedDataStore; + + @org.junit.Before + public void setUp() throws Exception { + distributedDataStore = new DistributedDataStore(); + } + + @org.junit.After + public void tearDown() throws Exception { + + } + + @org.junit.Test + public void testRegisterChangeListener() throws Exception { + ListenerRegistration registration = + distributedDataStore.registerChangeListener(InstanceIdentifier.builder().build(), new AsyncDataChangeListener>() { + @Override + public void onDataChanged(AsyncDataChangeEvent> change) { + throw new UnsupportedOperationException("onDataChanged"); + } + }, AsyncDataBroker.DataChangeScope.BASE); + + Assert.assertNotNull(registration); + } + + @org.junit.Test + public void testCreateTransactionChain() throws Exception { + final DOMStoreTransactionChain transactionChain = distributedDataStore.createTransactionChain(); + Assert.assertNotNull(transactionChain); + } + + @org.junit.Test + public void testNewReadOnlyTransaction() throws Exception { + final DOMStoreReadTransaction transaction = distributedDataStore.newReadOnlyTransaction(); + Assert.assertNotNull(transaction); + } + + @org.junit.Test + public void testNewWriteOnlyTransaction() throws Exception { + final DOMStoreWriteTransaction transaction = distributedDataStore.newWriteOnlyTransaction(); + Assert.assertNotNull(transaction); + } + + @org.junit.Test + public void testNewReadWriteTransaction() throws Exception { + final DOMStoreReadWriteTransaction transaction = distributedDataStore.newReadWriteTransaction(); + Assert.assertNotNull(transaction); + } +} -- 2.36.6