They used to be issued in parallel but it caused deadlock - see https://bugs.opendaylight.org/show_bug.cgi?id=2792
On Sun, Oct 23, 2016 at 5:56 AM, Hangyu <fh...@mails.tsinghua.edu.cn> wrote: > Hi guys, > I've found that while submitting data that located in multiple shards > to datastore, the ThreePhaseCommitCohortProxy asks each ShardCoordinator by > sending can-commit message(RPC) One-By-One. So I wonder what if these > can-commit messages were sent parallel? Is there any side-effect to do this? > The source code is located in controller/opendaylight/md- > sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/ > cluster/datastore/ThreePhaseCommitCohortProxy.java, line 156-199, and you > can read it here > <https://github.com/opendaylight/controller/blob/master/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java#L143> > . > Thanks for answering in advance. > > > private void finishCanCommit(final SettableFuture<Boolean> > returnFuture) { > LOG.debug("Tx {} finishCanCommit", transactionId); > > // For empty transactions return immediately > if (cohorts.size() == 0) { > LOG.debug("Tx {}: canCommit returning result true", > transactionId); > returnFuture.set(Boolean.TRUE); > return; > } > > commitOperationCallback = new TransactionRateLimitingCallbac > k(actorContext); > commitOperationCallback.run(); > > final Iterator<CohortInfo> iterator = cohorts.iterator(); > > final OnComplete<Object> onComplete = new OnComplete<O bject>() { > @Override > public void onComplete(Throwable failure, Object response) { > if (failure != null) { > LOG.debug("Tx {}: a canCommit cohort Future failed", > transactionId, failure); > > returnFuture.setException(failure); > commitOperationCallback.failure(); > return; > } > > // Only the first call to pause takes effect - subsequent > calls before resume are no-ops. So > // this means we'll only time the first transaction > canCommit which should be fine. > commitOperationCallback.pause(); > > boolean result = true; > if (CanCommitTransactionReply.isSerializedType(response)) > { > CanCommitTransactionReply reply = > CanCommitTransactionReply.fromSerializable(response); > > LOG.debug("Tx {}: received {}", transactionId, > response); > > if (!reply.getCanCommit()) { > &nbs p; result = false; > } > } else { > LOG.error("Unexpected response type {}", > response.getClass()); > returnFuture.setException(new IllegalArgumentException( > String.format("Unexpected response type %s", > response.getClass()))); > return; > } > > if (iterator.hasNext() && result) { > &nb sp; sendCanCommitTransaction(iterator.next(), this); > } else { > LOG.debug("Tx {}: canCommit returning result: {}", > transactionId, result); > returnFuture.set(Boolean.valueOf(result)); > } > > } > }; > > sendCanCommitTransaction(iterator.next(), onComplete); > } > -- > Fan Hangyu > Department of Electronic Engineering, > Tsinghua University, > Beijing 100084, P. R. China > Email: fh...@mails.tsinghua.edu.cn <//fh...@mails.tsinghua.edu.cn> > > > > > _______________________________________________ > controller-dev mailing list > controller-dev@lists.opendaylight.org > https://lists.opendaylight.org/mailman/listinfo/controller-dev > >
_______________________________________________ controller-dev mailing list controller-dev@lists.opendaylight.org https://lists.opendaylight.org/mailman/listinfo/controller-dev