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%2FCompositeDataTreeCohort.java;h=4044a4cb3a0ec991ca429a1d5c3dac63db426768;hb=ec870dee9bacb971f11bc747b69e84ac37f5d746;hp=006555f1f8b97d9007cbe0ba19865e2bcb8f3904;hpb=225ff4000ac10d6dbdc2301d8d2165d282721413;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java index 006555f1f8..4044a4cb3a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java @@ -28,6 +28,8 @@ import org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.CanComm import org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.Success; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import scala.concurrent.Await; import scala.concurrent.Future; @@ -39,6 +41,7 @@ import scala.concurrent.Future; * */ class CompositeDataTreeCohort { + private static final Logger LOG = LoggerFactory.getLogger(CompositeDataTreeCohort.class); private enum State { /** @@ -120,7 +123,12 @@ class CompositeDataTreeCohort { } void canCommit(final DataTreeCandidate tip) throws ExecutionException, TimeoutException { + LOG.debug("{}: canCommit - candidate: {}", txId, tip); + Collection messages = registry.createCanCommitMessages(txId, tip, schema); + + LOG.debug("{}: canCommit - messages: {}", txId, messages); + // FIXME: Optimize empty collection list with pre-created futures, containing success. Future> canCommitsFuture = Futures.traverse(messages, input -> Patterns.ask(input.getCohort(), input, timeout).recover(EXCEPTION_TO_MESSAGE, @@ -130,6 +138,8 @@ class CompositeDataTreeCohort { } void preCommit() throws ExecutionException, TimeoutException { + LOG.debug("{}: preCommit - successfulFromPrevious: {}", txId, successfulFromPrevious); + Preconditions.checkState(successfulFromPrevious != null); Future> preCommitFutures = sendMesageToSuccessful(new DataTreeCohortActor.PreCommit(txId)); changeStateFrom(State.CAN_COMMIT_SUCCESSFUL, State.PRE_COMMIT_SENT); @@ -137,6 +147,8 @@ class CompositeDataTreeCohort { } void commit() throws ExecutionException, TimeoutException { + LOG.debug("{}: commit - successfulFromPrevious: {}", txId, successfulFromPrevious); + Preconditions.checkState(successfulFromPrevious != null); Future> commitsFuture = sendMesageToSuccessful(new DataTreeCohortActor.Commit(txId)); changeStateFrom(State.PRE_COMMIT_SUCCESSFUL, State.COMMIT_SENT); @@ -144,6 +156,8 @@ class CompositeDataTreeCohort { } Optional>> abort() { + LOG.debug("{}: abort - successfulFromPrevious: {}", txId, successfulFromPrevious); + state = State.ABORTED; if (successfulFromPrevious != null && !Iterables.isEmpty(successfulFromPrevious)) { return Optional.of(sendMesageToSuccessful(new DataTreeCohortActor.Abort(txId))); @@ -153,6 +167,8 @@ class CompositeDataTreeCohort { } private Future> sendMesageToSuccessful(final Object message) { + LOG.debug("{}: sendMesageToSuccessful: {}", txId, message); + return Futures.traverse(successfulFromPrevious, cohortResponse -> Patterns.ask( cohortResponse.getCohort(), message, timeout), ExecutionContexts.global()); } @@ -160,16 +176,22 @@ class CompositeDataTreeCohort { @SuppressWarnings("checkstyle:IllegalCatch") private void processResponses(final Future> resultsFuture, final State currentState, final State afterState) throws TimeoutException, ExecutionException { + LOG.debug("{}: processResponses - currentState: {}, afterState: {}", txId, currentState, afterState); + final Iterable results; try { results = Await.result(resultsFuture, timeout.duration()); } catch (Exception e) { successfulFromPrevious = null; + LOG.debug("{}: processResponses - error from Future", txId, e); Throwables.propagateIfInstanceOf(e, TimeoutException.class); throw Throwables.propagate(e); } Iterable failed = Iterables.filter(results, Status.Failure.class); Iterable successful = Iterables.filter(results, DataTreeCohortActor.Success.class); + + LOG.debug("{}: processResponses - successful: {}, failed: {}", txId, successful, failed); + successfulFromPrevious = successful; if (!Iterables.isEmpty(failed)) { changeStateFrom(currentState, State.FAILED);