Do not leak DataTree from backend actor 82/82182/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 21 May 2019 08:47:34 +0000 (10:47 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 21 May 2019 08:47:34 +0000 (10:47 +0200)
YANG tools is now exposing the read-only part of DataTree as
ReadOnlyDataTree. Use this interface to restrict the set of
methods accessible to frontend.

Change-Id: I9426d4cee1e68e3cc21f7a39322a0df09739e770
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
15 files changed:
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccess.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccessProxyV1.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccessTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ProxyHistory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ShardBackendInfo.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContextFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionFactoryImpl.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/messages/LocalPrimaryShardFound.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryShardInfo.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ShardLeaderStateChanged.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardInformation.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorUtils.java

index 1ec81c8..43fdb3c 100644 (file)
@@ -22,7 +22,7 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.RequestSuccess;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 
 /**
  * Successful reply to an {@link ConnectClientRequest}. Client actor which initiated this connection should use
@@ -41,24 +41,24 @@ public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier,
     private final @NonNull List<ActorSelection> alternates;
 
     @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "See justification above.")
-    private final DataTree dataTree;
+    private final ReadOnlyDataTree dataTree;
     private final @NonNull ActorRef backend;
     private final int maxMessages;
 
     ConnectClientSuccess(final ClientIdentifier target, final long sequence, final ActorRef backend,
-        final List<ActorSelection> alternates, final Optional<DataTree> dataTree, final int maxMessages) {
+        final List<ActorSelection> alternates, final int maxMessages, final ReadOnlyDataTree dataTree) {
         super(target, sequence);
         this.backend = requireNonNull(backend);
         this.alternates = ImmutableList.copyOf(alternates);
-        this.dataTree = dataTree.orElse(null);
+        this.dataTree = dataTree;
         checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
         this.maxMessages = maxMessages;
     }
 
     public ConnectClientSuccess(final @NonNull ClientIdentifier target, final long sequence,
             final @NonNull ActorRef backend, final @NonNull List<ActorSelection> alternates,
-            final @NonNull DataTree dataTree, final int maxMessages) {
-        this(target, sequence, backend, alternates, Optional.of(dataTree), maxMessages);
+            final @NonNull ReadOnlyDataTree dataTree, final int maxMessages) {
+        this(target, sequence, backend, alternates, maxMessages, requireNonNull(dataTree));
     }
 
     /**
@@ -74,7 +74,7 @@ public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier,
         return backend;
     }
 
-    public Optional<DataTree> getDataTree() {
+    public Optional<ReadOnlyDataTree> getDataTree() {
         return Optional.ofNullable(dataTree);
     }
 
index fb44e07..8dd40ac 100644 (file)
@@ -17,7 +17,6 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Optional;
 import org.opendaylight.controller.cluster.access.concepts.AbstractSuccessProxy;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 
@@ -78,7 +77,7 @@ final class ConnectClientSuccessProxyV1 extends AbstractSuccessProxy<ClientIdent
 
     @Override
     protected ConnectClientSuccess createSuccess(final ClientIdentifier target, final long sequence) {
-        return new ConnectClientSuccess(target, sequence, backend, alternates, Optional.empty(), maxMessages);
+        return new ConnectClientSuccess(target, sequence, backend, alternates, maxMessages, null);
     }
 
     @Override
index 1dfe3c3..a1892eb 100644 (file)
@@ -24,6 +24,7 @@ import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
 
 public class ConnectClientSuccessTest extends AbstractRequestSuccessTest<ConnectClientSuccess> {
@@ -62,7 +63,7 @@ public class ConnectClientSuccessTest extends AbstractRequestSuccessTest<Connect
 
     @Test
     public void testGetDataTree() {
-        final DataTree tree = OBJECT.getDataTree().get();
+        final ReadOnlyDataTree tree = OBJECT.getDataTree().get();
         Assert.assertEquals(TREE, tree);
     }
 
index 25e7222..340cc55 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.Collection;
@@ -37,8 +39,8 @@ import org.opendaylight.controller.cluster.access.concepts.RequestException;
 import org.opendaylight.controller.cluster.access.concepts.Response;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,12 +51,12 @@ import org.slf4j.LoggerFactory;
  */
 abstract class ProxyHistory implements Identifiable<LocalHistoryIdentifier> {
     private abstract static class AbstractLocal extends ProxyHistory {
-        private final DataTree dataTree;
+        private final ReadOnlyDataTree dataTree;
 
         AbstractLocal(final AbstractClientHistory parent, final AbstractClientConnection<ShardBackendInfo> connection,
-            final LocalHistoryIdentifier identifier, final DataTree dataTree) {
+            final LocalHistoryIdentifier identifier, final ReadOnlyDataTree dataTree) {
             super(parent, connection, identifier);
-            this.dataTree = Preconditions.checkNotNull(dataTree);
+            this.dataTree = requireNonNull(dataTree);
         }
 
         final DataTreeSnapshot takeSnapshot() {
@@ -80,14 +82,14 @@ abstract class ProxyHistory implements Identifiable<LocalHistoryIdentifier> {
         private volatile LocalReadWriteProxyTransaction lastSealed;
 
         Local(final AbstractClientHistory parent, final AbstractClientConnection<ShardBackendInfo> connection,
-            final LocalHistoryIdentifier identifier, final DataTree dataTree) {
+            final LocalHistoryIdentifier identifier, final ReadOnlyDataTree dataTree) {
             super(parent, connection, identifier, dataTree);
         }
 
         @Override
         AbstractProxyTransaction doCreateTransactionProxy(final AbstractClientConnection<ShardBackendInfo> connection,
                 final TransactionIdentifier txId, final boolean snapshotOnly, final boolean isDone) {
-            Preconditions.checkState(lastOpen == null, "Proxy %s has %s currently open", this, lastOpen);
+            checkState(lastOpen == null, "Proxy %s has %s currently open", this, lastOpen);
 
             if (isDone) {
                 // Done transactions do not register on our radar on should not have any state associated.
@@ -136,7 +138,7 @@ abstract class ProxyHistory implements Identifiable<LocalHistoryIdentifier> {
 
         @Override
         void onTransactionSealed(final AbstractProxyTransaction tx) {
-            Preconditions.checkState(tx.equals(lastOpen));
+            checkState(tx.equals(lastOpen));
             lastSealed = lastOpen;
             lastOpen = null;
         }
@@ -144,7 +146,7 @@ abstract class ProxyHistory implements Identifiable<LocalHistoryIdentifier> {
 
     private static final class LocalSingle extends AbstractLocal {
         LocalSingle(final AbstractClientHistory parent, final AbstractClientConnection<ShardBackendInfo> connection,
-            final LocalHistoryIdentifier identifier, final DataTree dataTree) {
+            final LocalHistoryIdentifier identifier, final ReadOnlyDataTree dataTree) {
             super(parent, connection, identifier, dataTree);
         }
 
@@ -328,14 +330,14 @@ abstract class ProxyHistory implements Identifiable<LocalHistoryIdentifier> {
 
     private ProxyHistory(final AbstractClientHistory parent,
             final AbstractClientConnection<ShardBackendInfo> connection, final LocalHistoryIdentifier identifier) {
-        this.parent = Preconditions.checkNotNull(parent);
-        this.connection = Preconditions.checkNotNull(connection);
-        this.identifier = Preconditions.checkNotNull(identifier);
+        this.parent = requireNonNull(parent);
+        this.connection = requireNonNull(connection);
+        this.identifier = requireNonNull(identifier);
     }
 
     static ProxyHistory createClient(final AbstractClientHistory parent,
             final AbstractClientConnection<ShardBackendInfo> connection, final LocalHistoryIdentifier identifier) {
-        final Optional<DataTree> dataTree = connection.getBackendInfo().flatMap(ShardBackendInfo::getDataTree);
+        final Optional<ReadOnlyDataTree> dataTree = connection.getBackendInfo().flatMap(ShardBackendInfo::getDataTree);
         return dataTree.isPresent() ? new Local(parent, connection, identifier, dataTree.get())
              : new Remote(parent, connection, identifier);
     }
@@ -343,7 +345,7 @@ abstract class ProxyHistory implements Identifiable<LocalHistoryIdentifier> {
     static ProxyHistory createSingle(final AbstractClientHistory parent,
             final AbstractClientConnection<ShardBackendInfo> connection,
             final LocalHistoryIdentifier identifier) {
-        final Optional<DataTree> dataTree = connection.getBackendInfo().flatMap(ShardBackendInfo::getDataTree);
+        final Optional<ReadOnlyDataTree> dataTree = connection.getBackendInfo().flatMap(ShardBackendInfo::getDataTree);
         return dataTree.isPresent() ? new LocalSingle(parent, connection, identifier, dataTree.get())
              : new RemoteSingle(parent, connection, identifier);
     }
index c23fc3f..0958aad 100644 (file)
@@ -7,15 +7,17 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
 import com.google.common.primitives.UnsignedLong;
 import java.util.Optional;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 import org.opendaylight.controller.cluster.access.client.BackendInfo;
 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 
 /**
  * Combined backend tracking. Aside from usual {@link BackendInfo}, this object also tracks the cookie assigned
@@ -24,26 +26,26 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
  * @author Robert Varga
  */
 final class ShardBackendInfo extends BackendInfo {
-    private final Optional<DataTree> dataTree;
+    private final Optional<ReadOnlyDataTree> dataTree;
     private final UnsignedLong cookie;
 
     ShardBackendInfo(final ActorRef actor, final long sessionId, final ABIVersion version, final String shardName,
-        final UnsignedLong cookie, final Optional<DataTree> dataTree, final int maxMessages) {
+        final UnsignedLong cookie, final Optional<ReadOnlyDataTree> dataTree, final int maxMessages) {
         super(actor, shardName, sessionId, version, maxMessages);
-        this.cookie = Preconditions.checkNotNull(cookie);
-        this.dataTree = Preconditions.checkNotNull(dataTree);
+        this.cookie = requireNonNull(cookie);
+        this.dataTree = requireNonNull(dataTree);
     }
 
     UnsignedLong getCookie() {
         return cookie;
     }
 
-    Optional<DataTree> getDataTree() {
+    Optional<ReadOnlyDataTree> getDataTree() {
         return dataTree;
     }
 
     LocalHistoryIdentifier brandHistory(final LocalHistoryIdentifier id) {
-        Preconditions.checkArgument(id.getCookie() == 0, "History %s is already branded", id);
+        checkArgument(id.getCookie() == 0, "History %s is already branded", id);
         return new LocalHistoryIdentifier(id.getClientId(), id.getHistoryId(), cookie.longValue());
     }
 
index a415a8c..6d573de 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Future;
@@ -143,7 +143,7 @@ abstract class AbstractTransactionContextFactory<F extends LocalTransactionFacto
     }
 
     private void updateShardInfo(final String shardName, final PrimaryShardInfo primaryShardInfo) {
-        final Optional<DataTree> maybeDataTree = primaryShardInfo.getLocalShardDataTree();
+        final Optional<ReadOnlyDataTree> maybeDataTree = primaryShardInfo.getLocalShardDataTree();
         if (maybeDataTree.isPresent()) {
             if (!knownLocal.containsKey(shardName)) {
                 LOG.debug("Shard {} resolved to local data tree - adding local factory", shardName);
@@ -190,7 +190,7 @@ abstract class AbstractTransactionContextFactory<F extends LocalTransactionFacto
      *                 read-only manner.
      * @return Transaction factory for local use.
      */
-    protected abstract F factoryForShard(String shardName, ActorSelection shardLeader, DataTree dataTree);
+    protected abstract F factoryForShard(String shardName, ActorSelection shardLeader, ReadOnlyDataTree dataTree);
 
     /**
      * Callback invoked from child transactions to push any futures, which need to
index 791c3ef..c995e11 100644 (file)
@@ -18,9 +18,9 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 
 /**
  * Transaction chain instantiated on top of a locally-available DataTree. It does not instantiate
@@ -31,15 +31,16 @@ final class LocalTransactionChain extends AbstractSnapshotBackedTransactionChain
     private static final Throwable ABORTED = new Throwable("Transaction aborted");
     private final TransactionChainProxy parent;
     private final ActorSelection leader;
-    private final DataTree tree;
+    private final ReadOnlyDataTree tree;
 
-    LocalTransactionChain(final TransactionChainProxy parent, final ActorSelection leader, final DataTree tree) {
+    LocalTransactionChain(final TransactionChainProxy parent, final ActorSelection leader,
+            final ReadOnlyDataTree tree) {
         this.parent = requireNonNull(parent);
         this.leader = requireNonNull(leader);
         this.tree = requireNonNull(tree);
     }
 
-    DataTree getDataTree() {
+    ReadOnlyDataTree getDataTree() {
         return tree;
     }
 
index 78046bc..8c84449 100644 (file)
@@ -20,8 +20,8 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedTransactions;
 import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
 import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 
 /**
  * {@link LocalTransactionFactory} for instantiating backing transactions which are
@@ -32,16 +32,17 @@ final class LocalTransactionFactoryImpl extends TransactionReadyPrototype<Transa
         implements LocalTransactionFactory {
 
     private final ActorSelection leader;
-    private final DataTree dataTree;
+    private final ReadOnlyDataTree dataTree;
     private final ActorUtils actorUtils;
 
-    LocalTransactionFactoryImpl(final ActorUtils actorUtils, final ActorSelection leader, final DataTree dataTree) {
+    LocalTransactionFactoryImpl(final ActorUtils actorUtils, final ActorSelection leader,
+            final ReadOnlyDataTree dataTree) {
         this.leader = requireNonNull(leader);
         this.dataTree = requireNonNull(dataTree);
         this.actorUtils = actorUtils;
     }
 
-    DataTree getDataTree() {
+    ReadOnlyDataTree getDataTree() {
         return dataTree;
     }
 
index b5806d6..c3b81d7 100644 (file)
@@ -27,7 +27,7 @@ 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.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Future;
@@ -192,7 +192,7 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory<Loca
 
     @Override
     protected LocalTransactionChain factoryForShard(final String shardName, final ActorSelection shardLeader,
-            final DataTree dataTree) {
+            final ReadOnlyDataTree dataTree) {
         final LocalTransactionChain ret = new LocalTransactionChain(this, shardLeader, dataTree);
         LOG.debug("Allocated transaction chain {} for shard {} leader {}", ret, shardName, shardLeader);
         return ret;
index 8655c68..3944b04 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier
 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
 import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 import scala.concurrent.Future;
 
 /**
@@ -36,7 +36,7 @@ final class TransactionContextFactory extends AbstractTransactionContextFactory<
 
     @Override
     protected LocalTransactionFactoryImpl factoryForShard(final String shardName, final ActorSelection shardLeader,
-            final DataTree dataTree) {
+            final ReadOnlyDataTree dataTree) {
         return new LocalTransactionFactoryImpl(getActorUtils(), shardLeader, dataTree);
     }
 
index 76d404b..e4b9174 100644 (file)
@@ -11,7 +11,7 @@ import static java.util.Objects.requireNonNull;
 
 import org.apache.commons.lang3.ObjectUtils;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 
 /**
  * Local message sent in reply to FindPrimaryShard to indicate the primary shard is local to the caller.
@@ -21,9 +21,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 public class LocalPrimaryShardFound {
 
     private final String primaryPath;
-    private final DataTree localShardDataTree;
+    private final ReadOnlyDataTree localShardDataTree;
 
-    public LocalPrimaryShardFound(@NonNull  String primaryPath, @NonNull  DataTree localShardDataTree) {
+    public LocalPrimaryShardFound(@NonNull  String primaryPath, @NonNull ReadOnlyDataTree localShardDataTree) {
         this.primaryPath = requireNonNull(primaryPath);
         this.localShardDataTree = requireNonNull(localShardDataTree);
     }
@@ -32,7 +32,7 @@ public class LocalPrimaryShardFound {
         return primaryPath;
     }
 
-    public @NonNull DataTree getLocalShardDataTree() {
+    public @NonNull ReadOnlyDataTree getLocalShardDataTree() {
         return localShardDataTree;
     }
 
index 4ecb8c4..1ca0621 100644 (file)
@@ -12,7 +12,7 @@ import static java.util.Objects.requireNonNull;
 import akka.actor.ActorSelection;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 
 /**
  * Local message DTO that contains information about the primary shard.
@@ -22,10 +22,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 public class PrimaryShardInfo {
     private final ActorSelection primaryShardActor;
     private final short primaryShardVersion;
-    private final DataTree localShardDataTree;
+    private final ReadOnlyDataTree localShardDataTree;
 
     public PrimaryShardInfo(@NonNull ActorSelection primaryShardActor, short primaryShardVersion,
-            @NonNull DataTree localShardDataTree) {
+            @NonNull ReadOnlyDataTree localShardDataTree) {
         this.primaryShardActor = requireNonNull(primaryShardActor);
         this.primaryShardVersion = primaryShardVersion;
         this.localShardDataTree = requireNonNull(localShardDataTree);
@@ -55,7 +55,7 @@ public class PrimaryShardInfo {
      * Returns an Optional whose value contains the primary shard's DataTree if the primary shard is local
      * to the caller. Otherwise the Optional value is absent.
      */
-    public @NonNull Optional<DataTree> getLocalShardDataTree() {
+    public @NonNull Optional<ReadOnlyDataTree> getLocalShardDataTree() {
         return Optional.ofNullable(localShardDataTree);
     }
 }
index 679d421..cbf2cf9 100644 (file)
@@ -13,7 +13,7 @@ import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.cluster.notifications.LeaderStateChanged;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 
 /**
  * A local message derived from LeaderStateChanged containing additional Shard-specific info that is sent
@@ -23,11 +23,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
  * @author Thomas Pantelis
  */
 public class ShardLeaderStateChanged extends LeaderStateChanged {
-
-    private final DataTree localShardDataTree;
+    private final ReadOnlyDataTree localShardDataTree;
 
     public ShardLeaderStateChanged(@NonNull String memberId, @Nullable String leaderId,
-            @NonNull DataTree localShardDataTree, short leaderPayloadVersion) {
+            @NonNull ReadOnlyDataTree localShardDataTree, short leaderPayloadVersion) {
         super(memberId, leaderId, leaderPayloadVersion);
         this.localShardDataTree = requireNonNull(localShardDataTree);
     }
@@ -38,7 +37,7 @@ public class ShardLeaderStateChanged extends LeaderStateChanged {
         this.localShardDataTree = null;
     }
 
-    public @NonNull Optional<DataTree> getLocalShardDataTree() {
+    public @NonNull Optional<ReadOnlyDataTree> getLocalShardDataTree() {
         return Optional.ofNullable(localShardDataTree);
     }
 }
index 5b1f1b7..97cbc5b 100644 (file)
@@ -31,7 +31,7 @@ import org.opendaylight.controller.cluster.datastore.messages.PeerUp;
 import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager.OnShardInitialized;
 import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager.OnShardReady;
 import org.opendaylight.controller.cluster.raft.RaftState;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,7 +51,7 @@ final class ShardInformation {
     private final AtomicShardContextProvider schemaContextProvider = new AtomicShardContextProvider();
     private ActorRef actor;
 
-    private Optional<DataTree> localShardDataTree;
+    private Optional<ReadOnlyDataTree> localShardDataTree;
     private boolean leaderAvailable = false;
 
     // flag that determines if the actor is ready for business
@@ -101,11 +101,11 @@ final class ShardInformation {
         return shardId;
     }
 
-    void setLocalDataTree(final Optional<DataTree> dataTree) {
+    void setLocalDataTree(final Optional<ReadOnlyDataTree> dataTree) {
         this.localShardDataTree = dataTree;
     }
 
-    Optional<DataTree> getLocalShardDataTree() {
+    Optional<ReadOnlyDataTree> getLocalShardDataTree() {
         return localShardDataTree;
     }
 
index 3d45f64..a1efbf2 100644 (file)
@@ -51,7 +51,7 @@ import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy
 import org.opendaylight.controller.cluster.raft.client.messages.Shutdown;
 import org.opendaylight.controller.cluster.reporting.MetricsReporter;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -242,7 +242,7 @@ public class ActorUtils {
     }
 
     private PrimaryShardInfo onPrimaryShardFound(final String shardName, final String primaryActorPath,
-            final short primaryVersion, final DataTree localShardDataTree) {
+            final short primaryVersion, final ReadOnlyDataTree localShardDataTree) {
         ActorSelection actorSelection = actorSystem.actorSelection(primaryActorPath);
         PrimaryShardInfo info = localShardDataTree == null ? new PrimaryShardInfo(actorSelection, primaryVersion) :
             new PrimaryShardInfo(actorSelection, primaryVersion, localShardDataTree);

©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.