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%2FDataTreeCohortActorRegistry.java;h=3ff6a9f0e61ba90e7e17a9f2a6b0bf34a7a3a818;hb=HEAD;hp=f213cc7588ab3c6d3b7794bf10ac914824ce9477;hpb=e84f63ee098fff5b02cbce1281ca0d1208f966fa;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortActorRegistry.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortActorRegistry.java index f213cc7588..fa10f947db 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortActorRegistry.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortActorRegistry.java @@ -26,27 +26,24 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.spi.AbstractRegistrationTree; -import org.opendaylight.mdsal.dom.spi.RegistrationTreeNode; -import org.opendaylight.mdsal.dom.spi.RegistrationTreeSnapshot; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode; import org.opendaylight.yangtools.yang.data.tree.api.ModificationType; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Registry of user commit cohorts, which is responsible for handling registration and calculation * of affected cohorts based on {@link DataTreeCandidate}. This class is NOT thread-safe. - * */ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { private static final Logger LOG = LoggerFactory.getLogger(DataTreeCohortActorRegistry.class); - private final Map> cohortToNode = new HashMap<>(); + private final Map> cohortToNode = new HashMap<>(); Collection getCohortActors() { return new ArrayList<>(cohortToNode.keySet()); @@ -57,8 +54,7 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { takeLock(); try { final ActorRef cohortRef = cohort.getCohort(); - final RegistrationTreeNode node = - findNodeFor(cohort.getPath().getRootIdentifier().getPathArguments()); + final Node node = findNodeFor(cohort.getPath().path().getPathArguments()); addRegistration(node, cohort.getCohort()); cohortToNode.put(cohortRef, node); } catch (final Exception e) { @@ -72,7 +68,7 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { void removeCommitCohort(final ActorRef sender, final RemoveCohort message) { final ActorRef cohort = message.getCohort(); - final RegistrationTreeNode node = cohortToNode.get(cohort); + final Node node = cohortToNode.get(cohort); if (node != null) { removeRegistration(node, cohort); cohortToNode.remove(cohort); @@ -82,8 +78,8 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { } List createCanCommitMessages(final TransactionIdentifier txId, - final DataTreeCandidate candidate, final SchemaContext schema) { - try (RegistrationTreeSnapshot cohorts = takeSnapshot()) { + final DataTreeCandidate candidate, final EffectiveModelContext schema) { + try (var cohorts = takeSnapshot()) { return new CanCommitMessageBuilder(txId, candidate, schema).perform(cohorts.getRootNode()); } } @@ -131,54 +127,52 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { private final Multimap actorToCandidates = ArrayListMultimap.create(); private final TransactionIdentifier txId; private final DataTreeCandidate candidate; - private final SchemaContext schema; + private final EffectiveModelContext schema; CanCommitMessageBuilder(final TransactionIdentifier txId, final DataTreeCandidate candidate, - final SchemaContext schema) { + final EffectiveModelContext schema) { this.txId = requireNonNull(txId); this.candidate = requireNonNull(candidate); this.schema = schema; } private void lookupAndCreateCanCommits(final List args, final int offset, - final RegistrationTreeNode node) { + final Node node) { if (args.size() != offset) { final PathArgument arg = args.get(offset); - final RegistrationTreeNode exactChild = node.getExactChild(arg); + final var exactChild = node.getExactChild(arg); if (exactChild != null) { lookupAndCreateCanCommits(args, offset + 1, exactChild); } - for (final RegistrationTreeNode c : node.getInexactChildren(arg)) { - lookupAndCreateCanCommits(args, offset + 1, c); + for (var inexact : node.getInexactChildren(arg)) { + lookupAndCreateCanCommits(args, offset + 1, inexact); } } else { lookupAndCreateCanCommits(candidate.getRootPath(), node, candidate.getRootNode()); } } - private void lookupAndCreateCanCommits(final YangInstanceIdentifier path, - final RegistrationTreeNode regNode, final DataTreeCandidateNode candNode) { - if (candNode.getModificationType() == ModificationType.UNMODIFIED) { + private void lookupAndCreateCanCommits(final YangInstanceIdentifier path, final Node regNode, + final DataTreeCandidateNode candNode) { + if (candNode.modificationType() == ModificationType.UNMODIFIED) { LOG.debug("Skipping unmodified candidate {}", path); return; } - final Collection regs = regNode.getRegistrations(); + final var regs = regNode.getRegistrations(); if (!regs.isEmpty()) { createCanCommits(regs, path, candNode); } - for (final DataTreeCandidateNode candChild : candNode.getChildNodes()) { - if (candChild.getModificationType() != ModificationType.UNMODIFIED) { - final RegistrationTreeNode regChild = - regNode.getExactChild(candChild.getIdentifier()); + for (var candChild : candNode.childNodes()) { + if (candChild.modificationType() != ModificationType.UNMODIFIED) { + final var regChild = regNode.getExactChild(candChild.name()); if (regChild != null) { - lookupAndCreateCanCommits(path.node(candChild.getIdentifier()), regChild, candChild); + lookupAndCreateCanCommits(path.node(candChild.name()), regChild, candChild); } - for (final RegistrationTreeNode rc : regNode - .getInexactChildren(candChild.getIdentifier())) { - lookupAndCreateCanCommits(path.node(candChild.getIdentifier()), rc, candChild); + for (var rc : regNode.getInexactChildren(candChild.name())) { + lookupAndCreateCanCommits(path.node(candChild.name()), rc, candChild); } } } @@ -193,11 +187,11 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { } private static DOMDataTreeIdentifier treeIdentifier(final YangInstanceIdentifier path) { - return new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, path); + return DOMDataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, path); } - List perform(final RegistrationTreeNode rootNode) { - final List toLookup = candidate.getRootPath().getPathArguments(); + List perform(final Node rootNode) { + final var toLookup = candidate.getRootPath().getPathArguments(); lookupAndCreateCanCommits(toLookup, 0, rootNode); final Map> mapView = actorToCandidates.asMap(); @@ -210,7 +204,7 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { } } - CompositeDataTreeCohort createCohort(final SchemaContext schemaContext, final TransactionIdentifier txId, + CompositeDataTreeCohort createCohort(final EffectiveModelContext schemaContext, final TransactionIdentifier txId, final Executor callbackExecutor, final Timeout commitStepTimeout) { return new CompositeDataTreeCohort(this, txId, schemaContext, callbackExecutor, commitStepTimeout); }