// initialize this command with components specific to the intended cache instance
commandsFactory.initializeReplicableCommand(cmd, true);
if (cmd instanceof TotalOrderPrepareCommand) {
final TotalOrderRemoteTransactionState state = ((TotalOrderPrepareCommand) cmd).getOrCreateState();
final TotalOrderManager totalOrderManager = cr.getTotalOrderManager();
totalOrderManager.ensureOrder(state, ((PrepareCommand) cmd).getAffectedKeysToLock(false));
totalOrderExecutorService.execute(new BlockingRunnable() {
@Override
public boolean isReady() {
for (TotalOrderLatch block : state.getConflictingTransactionBlocks()) {
if (block.isBlocked()) {
return false;
}
}
return true;
}
@Override
public void run() {
Response resp;
try {
resp = handleInternal(cmd, cr);
} catch (RetryPrepareException retry) {
log.debugf(retry, "Prepare [%s] conflicted with state transfer", cmd);
resp = new ExceptionResponse(retry);
} catch (Throwable throwable) {
log.exceptionHandlingCommand(cmd, throwable);
resp = new ExceptionResponse(new CacheException("Problems invoking command.", throwable));
}
//the ResponseGenerated is null in this case because the return value is a Response
reply(response, resp);
if (resp instanceof ExceptionResponse) {
totalOrderManager.release(state);
}
afterResponseSent(cmd, resp);
}
});
} else {