Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Remove deprecated Snapshot and related code
[controller.git]
/
opendaylight
/
md-sal
/
sal-distributed-datastore
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
datastore
/
DataTreeCohortActor.java
diff --git
a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortActor.java
b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortActor.java
index 0be8f0986557f75a763b557c3c62f84fb63b682d..da1117764f8b8146ef7f8f49e22bcc7f2ef64d8b 100644
(file)
--- a/
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortActor.java
+++ b/
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortActor.java
@@
-12,6
+12,7
@@
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.Status;
import com.google.common.base.Preconditions;
import akka.actor.Props;
import akka.actor.Status;
import com.google.common.base.Preconditions;
+import java.util.Collection;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.mdsal.common.api.PostCanCommitStep;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.mdsal.common.api.PostCanCommitStep;
@@
-19,6
+20,7
@@
import org.opendaylight.mdsal.common.api.PostPreCommitStep;
import org.opendaylight.mdsal.common.api.ThreePhaseCommitStep;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
import org.opendaylight.mdsal.common.api.ThreePhaseCommitStep;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
@@
-28,14
+30,19
@@
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
final class DataTreeCohortActor extends AbstractUntypedActor {
private final CohortBehaviour<?> idleState = new Idle();
private final DOMDataTreeCommitCohort cohort;
final class DataTreeCohortActor extends AbstractUntypedActor {
private final CohortBehaviour<?> idleState = new Idle();
private final DOMDataTreeCommitCohort cohort;
+ private final YangInstanceIdentifier registeredPath;
private CohortBehaviour<?> currentState = idleState;
private CohortBehaviour<?> currentState = idleState;
- private DataTreeCohortActor(final DOMDataTreeCommitCohort cohort) {
+ private DataTreeCohortActor(final DOMDataTreeCommitCohort cohort
, final YangInstanceIdentifier registeredPath
) {
this.cohort = Preconditions.checkNotNull(cohort);
this.cohort = Preconditions.checkNotNull(cohort);
+ this.registeredPath = Preconditions.checkNotNull(registeredPath);
}
@Override
protected void handleReceive(final Object message) {
}
@Override
protected void handleReceive(final Object message) {
+ LOG.debug("handleReceive for cohort {} - currentState: {}, message: {}", cohort.getClass().getName(),
+ currentState, message);
+
currentState = currentState.handle(message);
}
currentState = currentState.handle(message);
}
@@
-56,23
+63,29
@@
final class DataTreeCohortActor extends AbstractUntypedActor {
protected CommitProtocolCommand(TransactionIdentifier txId) {
this.txId = Preconditions.checkNotNull(txId);
}
protected CommitProtocolCommand(TransactionIdentifier txId) {
this.txId = Preconditions.checkNotNull(txId);
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + " [txId=" + txId + "]";
+ }
}
static final class CanCommit extends CommitProtocolCommand<Success> {
}
static final class CanCommit extends CommitProtocolCommand<Success> {
- private final
DOMDataTreeCandidate candidate
;
+ private final
Collection<DOMDataTreeCandidate> candidates
;
private final ActorRef cohort;
private final SchemaContext schema;
private final ActorRef cohort;
private final SchemaContext schema;
- CanCommit(TransactionIdentifier txId, DOMDataTreeCandidate candidate, SchemaContext schema, ActorRef cohort) {
+ CanCommit(TransactionIdentifier txId, Collection<DOMDataTreeCandidate> candidates, SchemaContext schema,
+ ActorRef cohort) {
super(txId);
this.cohort = Preconditions.checkNotNull(cohort);
super(txId);
this.cohort = Preconditions.checkNotNull(cohort);
- this.candidate
= Preconditions.checkNotNull(candidate
);
+ this.candidate
s = Preconditions.checkNotNull(candidates
);
this.schema = Preconditions.checkNotNull(schema);
}
this.schema = Preconditions.checkNotNull(schema);
}
-
DOMDataTreeCandidate getCandidate
() {
- return candidate;
+
Collection<DOMDataTreeCandidate> getCandidates
() {
+ return candidate
s
;
}
SchemaContext getSchema() {
}
SchemaContext getSchema() {
@@
-83,6
+96,10
@@
final class DataTreeCohortActor extends AbstractUntypedActor {
return cohort;
}
return cohort;
}
+ @Override
+ public String toString() {
+ return "CanCommit [txId=" + getTxId() + ", candidates=" + candidates + ", cohort=" + cohort + "]";
+ }
}
abstract static class CommitReply {
}
abstract static class CommitReply {
@@
-102,6
+119,11
@@
final class DataTreeCohortActor extends AbstractUntypedActor {
final TransactionIdentifier getTxId() {
return txId;
}
final TransactionIdentifier getTxId() {
return txId;
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + " [txId=" + txId + ", cohortRef=" + cohortRef + "]";
+ }
}
static final class Success extends CommitReply {
}
static final class Success extends CommitReply {
@@
-109,7
+131,6
@@
final class DataTreeCohortActor extends AbstractUntypedActor {
Success(ActorRef cohortRef, TransactionIdentifier txId) {
super(cohortRef, txId);
}
Success(ActorRef cohortRef, TransactionIdentifier txId) {
super(cohortRef, txId);
}
-
}
static final class PreCommit extends CommitProtocolCommand<Success> {
}
static final class PreCommit extends CommitProtocolCommand<Success> {
@@
-143,13
+164,18
@@
final class DataTreeCohortActor extends AbstractUntypedActor {
} else if (message instanceof Abort) {
return abort();
}
} else if (message instanceof Abort) {
return abort();
}
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException(String.format("Unexpected message %s in cohort behavior %s",
+ message.getClass(), getClass().getSimpleName()));
}
abstract CohortBehaviour<?> abort();
abstract CohortBehaviour<?> process(E message);
}
abstract CohortBehaviour<?> abort();
abstract CohortBehaviour<?> process(E message);
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
}
private class Idle extends CohortBehaviour<CanCommit> {
}
private class Idle extends CohortBehaviour<CanCommit> {
@@
-164,7
+190,7
@@
final class DataTreeCohortActor extends AbstractUntypedActor {
CohortBehaviour<?> process(CanCommit message) {
final PostCanCommitStep nextStep;
try {
CohortBehaviour<?> process(CanCommit message) {
final PostCanCommitStep nextStep;
try {
- nextStep = cohort.canCommit(message.getTxId(), message.getCandidate(), message.getSchema()).get();
+ nextStep = cohort.canCommit(message.getTxId(), message.getCandidate
s
(), message.getSchema()).get();
} catch (final Exception e) {
getSender().tell(new Status.Failure(e), getSelf());
return this;
} catch (final Exception e) {
getSender().tell(new Status.Failure(e), getSelf());
return this;
@@
-177,7
+203,6
@@
final class DataTreeCohortActor extends AbstractUntypedActor {
CohortBehaviour<?> abort() {
return this;
}
CohortBehaviour<?> abort() {
return this;
}
-
}
}
@@
-214,6
+239,10
@@
final class DataTreeCohortActor extends AbstractUntypedActor {
return idleState;
}
return idleState;
}
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + " [txId=" + txId + ", step=" + step + "]";
+ }
}
private class PostCanCommit extends CohortStateWithStep<PreCommit, PostCanCommitStep> {
}
private class PostCanCommit extends CohortStateWithStep<PreCommit, PostCanCommitStep> {
@@
-269,7
+298,7
@@
final class DataTreeCohortActor extends AbstractUntypedActor {
}
}
- static Props props(final DOMDataTreeCommitCohort cohort) {
- return Props.create(DataTreeCohortActor.class, cohort);
+ static Props props(final DOMDataTreeCommitCohort cohort
, final YangInstanceIdentifier registeredPath
) {
+ return Props.create(DataTreeCohortActor.class, cohort
, registeredPath
);
}
}
}
}