X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardDataTree.java;h=c167ec630637fc3ac6e98401edbd397ed9702e4d;hp=56c5eb65bf087c3a0d979de2ecaff7b0a65467a2;hb=30507b196fa240a4176ba12102ac0469280feff9;hpb=2b2517144e4eb9c17d9b41e9d9ec20d0264f5e12 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java index 56c5eb65bf..c167ec6306 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java @@ -7,8 +7,8 @@ */ package org.opendaylight.controller.cluster.datastore; -import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; +import com.google.common.base.Preconditions; import com.google.common.base.Strings; import java.util.AbstractMap.SimpleEntry; import java.util.HashMap; @@ -42,27 +42,32 @@ import org.slf4j.LoggerFactory; * This class is not part of the API contract and is subject to change at any time. */ @NotThreadSafe -@VisibleForTesting -public final class ShardDataTree extends ShardDataTreeTransactionParent { +public class ShardDataTree extends ShardDataTreeTransactionParent { private static final Logger LOG = LoggerFactory.getLogger(ShardDataTree.class); private static final ShardDataTreeNotificationManager MANAGER = new ShardDataTreeNotificationManager(); private final Map transactionChains = new HashMap<>(); private final ShardDataTreeChangePublisher treeChangePublisher = new ShardDataTreeChangePublisher(); private final ListenerTree listenerTree = ListenerTree.create(); private final TipProducingDataTree dataTree; + private SchemaContext schemaContext; - ShardDataTree(final SchemaContext schemaContext) { + public ShardDataTree(final SchemaContext schemaContext) { dataTree = InMemoryDataTreeFactory.getInstance().create(); - if (schemaContext != null) { - dataTree.setSchemaContext(schemaContext); - } + updateSchemaContext(schemaContext); + } - TipProducingDataTree getDataTree() { + public TipProducingDataTree getDataTree() { return dataTree; } + SchemaContext getSchemaContext() { + return schemaContext; + } + void updateSchemaContext(final SchemaContext schemaContext) { + Preconditions.checkNotNull(schemaContext); + this.schemaContext = schemaContext; dataTree.setSchemaContext(schemaContext); } @@ -86,13 +91,14 @@ public final class ShardDataTree extends ShardDataTreeTransactionParent { ReadWriteShardDataTreeTransaction newReadWriteTransaction(final String txId, final String chainId) { if (Strings.isNullOrEmpty(chainId)) { - return new ReadWriteShardDataTreeTransaction(this, txId, dataTree.takeSnapshot().newModification()); + return new ReadWriteShardDataTreeTransaction(ShardDataTree.this, txId, dataTree.takeSnapshot() + .newModification()); } return ensureTransactionChain(chainId).newReadWriteTransaction(txId); } - void notifyListeners(final DataTreeCandidate candidate) { + public void notifyListeners(final DataTreeCandidate candidate) { LOG.debug("Notifying listeners on candidate {}", candidate); // DataTreeChanges first, as they are more light-weight @@ -137,7 +143,7 @@ public final class ShardDataTree extends ShardDataTreeTransactionParent { return new SimpleEntry<>(reg, event); } - Entry, DataTreeCandidate> registerTreeChangeListener(final YangInstanceIdentifier path, + public Entry, DataTreeCandidate> registerTreeChangeListener(final YangInstanceIdentifier path, final DOMDataTreeChangeListener listener) { final ListenerRegistration reg = treeChangePublisher.registerTreeChangeListener(path, listener); @@ -174,7 +180,6 @@ public final class ShardDataTree extends ShardDataTreeTransactionParent { ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction) { final DataTreeModification snapshot = transaction.getSnapshot(); snapshot.ready(); - return new SimpleShardDataTreeCohort(this, snapshot); + return new SimpleShardDataTreeCohort(this, snapshot, transaction.getId()); } - }