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%2FDataTreeCohortActorRegistry.java;fp=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDataTreeCohortActorRegistry.java;h=fb3743d426d1ac4636db0d43b8cef37eb7094b27;hp=28b3c707a92f4025d436f6c4059dbca5e921c9a3;hb=a47dd7a5d21ca68804a6d0e2e3ca765f223c2ef4;hpb=1c07afe1670c5f61a23e33bc670db5ec0aec1d87 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 28b3c707a9..fb3743d426 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 @@ -11,6 +11,7 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; import akka.actor.PoisonPill; import akka.actor.Status; +import akka.util.Timeout; import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; @@ -48,7 +49,7 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { private final Map> cohortToNode = new HashMap<>(); - void registerCohort(ActorRef sender, RegisterCohort cohort) { + void registerCohort(final ActorRef sender, final RegisterCohort cohort) { takeLock(); try { final ActorRef cohortRef = cohort.getCohort(); @@ -65,7 +66,7 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { sender.tell(new Status.Success(null), ActorRef.noSender()); } - void removeCommitCohort(ActorRef sender, RemoveCohort message) { + void removeCommitCohort(final ActorRef sender, final RemoveCohort message) { final ActorRef cohort = message.getCohort(); final RegistrationTreeNode node = cohortToNode.get(cohort); if (node != null) { @@ -76,14 +77,14 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { cohort.tell(PoisonPill.getInstance(), cohort); } - Collection createCanCommitMessages(TransactionIdentifier txId, - DataTreeCandidate candidate, SchemaContext schema) { + Collection createCanCommitMessages(final TransactionIdentifier txId, + final DataTreeCandidate candidate, final SchemaContext schema) { try (RegistrationTreeSnapshot cohorts = takeSnapshot()) { return new CanCommitMessageBuilder(txId, candidate, schema).perform(cohorts.getRootNode()); } } - void process(ActorRef sender, CohortRegistryCommand message) { + void process(final ActorRef sender, final CohortRegistryCommand message) { if (message instanceof RegisterCohort) { registerCohort(sender, (RegisterCohort) message); } else if (message instanceof RemoveCohort) { @@ -95,7 +96,7 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { private final ActorRef cohort; - CohortRegistryCommand(ActorRef cohort) { + CohortRegistryCommand(final ActorRef cohort) { this.cohort = Preconditions.checkNotNull(cohort); } @@ -108,7 +109,7 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { private final DOMDataTreeIdentifier path; - RegisterCohort(DOMDataTreeIdentifier path, ActorRef cohort) { + RegisterCohort(final DOMDataTreeIdentifier path, final ActorRef cohort) { super(cohort); this.path = path; @@ -122,7 +123,7 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { static class RemoveCohort extends CohortRegistryCommand { - RemoveCohort(ActorRef cohort) { + RemoveCohort(final ActorRef cohort) { super(cohort); } @@ -136,14 +137,14 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { private final Collection messages = new ArrayList<>(); - CanCommitMessageBuilder(TransactionIdentifier txId, DataTreeCandidate candidate, SchemaContext schema) { + CanCommitMessageBuilder(final TransactionIdentifier txId, final DataTreeCandidate candidate, final SchemaContext schema) { this.txId = Preconditions.checkNotNull(txId); this.candidate = Preconditions.checkNotNull(candidate); this.schema = schema; } - private void lookupAndCreateCanCommits(List args, int offset, - RegistrationTreeNode node) { + private void lookupAndCreateCanCommits(final List args, final int offset, + final RegistrationTreeNode node) { if (args.size() != offset) { final PathArgument arg = args.get(offset); @@ -159,8 +160,8 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { } } - private void lookupAndCreateCanCommits(YangInstanceIdentifier path, RegistrationTreeNode regNode, - DataTreeCandidateNode candNode) { + private void lookupAndCreateCanCommits(final YangInstanceIdentifier path, final RegistrationTreeNode regNode, + final DataTreeCandidateNode candNode) { if (candNode.getModificationType() == ModificationType.UNMODIFIED) { LOG.debug("Skipping unmodified candidate {}", path); return; @@ -186,8 +187,8 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { } } - private void createCanCommits(Collection regs, YangInstanceIdentifier path, - DataTreeCandidateNode node) { + private void createCanCommits(final Collection regs, final YangInstanceIdentifier path, + final DataTreeCandidateNode node) { final DOMDataTreeCandidate candidate = DOMDataTreeCandidateTO.create(treeIdentifier(path), node); for (final ActorRef reg : regs) { final CanCommit message = new DataTreeCohortActor.CanCommit(txId, candidate, schema, reg); @@ -195,15 +196,19 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree { } } - private static DOMDataTreeIdentifier treeIdentifier(YangInstanceIdentifier path) { + private static DOMDataTreeIdentifier treeIdentifier(final YangInstanceIdentifier path) { return new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, path); } - private Collection perform(RegistrationTreeNode rootNode) { + private Collection perform(final RegistrationTreeNode rootNode) { final List toLookup = candidate.getRootPath().getPathArguments(); lookupAndCreateCanCommits(toLookup, 0, rootNode); return messages; } } + CompositeDataTreeCohort createCohort(final SchemaContext schemaContext, final TransactionIdentifier txId, + final Timeout commitStepTimeout) { + return new CompositeDataTreeCohort(this, txId, schemaContext, commitStepTimeout); + } }