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=56c5eb65bf087c3a0d979de2ecaff7b0a65467a2;hp=373bf499e0a9b8e90f4d8886c1ce183e787933e0;hb=9f17976f66bc0d3b58bcb96f325a241e34871d54;hpb=56c1339ee7dbd85bc567fc44f21ecfd322c9e803 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 373bf499e0..56c5eb65bf 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 @@ -21,14 +21,13 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent; import org.opendaylight.controller.md.sal.dom.store.impl.ResolveDataChangeEventsTask; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree; import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -93,7 +92,7 @@ public final class ShardDataTree extends ShardDataTreeTransactionParent { return ensureTransactionChain(chainId).newReadWriteTransaction(txId); } - void notifyListeners(final DataTreeCandidateTip candidate) { + void notifyListeners(final DataTreeCandidate candidate) { LOG.debug("Notifying listeners on candidate {}", candidate); // DataTreeChanges first, as they are more light-weight @@ -116,7 +115,7 @@ public final class ShardDataTree extends ShardDataTreeTransactionParent { if (chain != null) { chain.close(); } else { - LOG.warn("Closing non-existent transaction chain {}", transactionChainId); + LOG.debug("Closing non-existent transaction chain {}", transactionChainId); } } @@ -152,15 +151,30 @@ public final class ShardDataTree extends ShardDataTreeTransactionParent { return new SimpleEntry<>(reg, event); } + void applyForeignCandidate(final String identifier, final DataTreeCandidate foreign) throws DataValidationFailedException { + LOG.debug("Applying foreign transaction {}", identifier); + + final DataTreeModification mod = dataTree.takeSnapshot().newModification(); + DataTreeCandidates.applyToModification(mod, foreign); + mod.ready(); + + LOG.trace("Applying foreign modification {}", mod); + dataTree.validate(mod); + final DataTreeCandidate candidate = dataTree.prepare(mod); + dataTree.commit(candidate); + notifyListeners(candidate); + } + @Override void abortTransaction(final AbstractShardDataTreeTransaction transaction) { // Intentional no-op } @Override - DOMStoreThreePhaseCommitCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction) { + ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction) { final DataTreeModification snapshot = transaction.getSnapshot(); snapshot.ready(); - return new ShardDataTreeCohort(this, snapshot); + return new SimpleShardDataTreeCohort(this, snapshot); } + }