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.
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
TransactionRateLimitingCallback(actorContext);
commitOperationCallback.run();
final Iterator<CohortInfo> iterator = cohorts.iterator();
final OnComplete<Object> onComplete = new OnComplete<Object>() {
@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()) {
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) {
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: [email protected]
_______________________________________________
controller-dev mailing list
[email protected]
https://lists.opendaylight.org/mailman/listinfo/controller-dev