X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardDataTree.java;h=fbe699223c3e5fd6c399c7a680d4a48130b6df89;hb=e20fff4d018e95cefd1934d2be31e5cd692fe7fa;hp=373bf499e0a9b8e90f4d8886c1ce183e787933e0;hpb=56c1339ee7dbd85bc567fc44f21ecfd322c9e803;p=controller.git 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..fbe699223c 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 @@ -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); } + }