Add some unimplemented proxy classes related to DOMStore 64/7964/2
authorMoiz Raja <moraja@cisco.com>
Fri, 13 Jun 2014 00:51:11 +0000 (17:51 -0700)
committerMoiz Raja <moraja@cisco.com>
Mon, 16 Jun 2014 21:09:54 +0000 (14:09 -0700)
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 <moraja@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/pom.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java [moved from opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DOMStoreProxy.java with 76% similarity]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ListenerRegistrationProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedDataStoreProviderModule.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java [new file with mode: 0644]

index 027477d0c2606fba733a2b028b1ed99226c270ce..e7fcd83328f86c425e7a95092da1b3cc5f36bc47 100644 (file)
       <artifactId>sal-binding-api</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-binding-config</artifactId>
+    </dependency>
+
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-common-api</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-common-util</artifactId>
+    </dependency>
+
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-core-spi</artifactId>
       <artifactId>concepts</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-binding</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-common</artifactId>
+    </dependency>
+
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-data-api</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+    </dependency>
+
     <!-- AKKA Dependencies -->
     <dependency>
       <groupId>org.scala-lang</groupId>
@@ -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 <L extends AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L> 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 (file)
index 0000000..19e7f19
--- /dev/null
@@ -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 (file)
index 0000000..20a74e3
--- /dev/null
@@ -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 (file)
index 0000000..c9a6304
--- /dev/null
@@ -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<Optional<NormalizedNode<?, ?>>> 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");
+    }
+}
index 38bf756cfa40e14523b7e59c883b70aa694d65a1..241bcb0a41654987835c249374c0c953d83e8814 100644 (file)
@@ -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 (file)
index 0000000..6544f33
--- /dev/null
@@ -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<InstanceIdentifier, NormalizedNode<?, ?>>() {
+            @Override
+            public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> 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);
+    }
+}