<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>
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();
}
}
--- /dev/null
+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");
+ }
+}
--- /dev/null
+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");
+ }
+}
--- /dev/null
+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");
+ }
+}
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) {
@Override
public java.lang.AutoCloseable createInstance() {
- new DOMStoreProxy();
+ new DistributedDataStore();
final class AutoCloseableDistributedDataStore implements AutoCloseable {
--- /dev/null
+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);
+ }
+}