void run()

in accord-core/src/main/java/accord/impl/SimpleProgressLog.java [211:272]


                void run(Command command)
                {
                    setProgress(Investigating);
                    switch (status)
                    {
                        default: throw new AssertionError("Unexpected status: " + status);
                        case NotWitnessed: // can't make progress if we haven't witnessed it yet
                        case Committed: // can't make progress if we aren't yet ReadyToExecute
                        case Done: // shouldn't be trying to make progress, as we're done
                            throw new IllegalStateException("Unexpected status: " + status);

                        case Uncommitted:
                        case ReadyToExecute:
                        {
                            if (status.isAtLeastCommitted() && command.durability().isDurable())
                            {
                                // must also be committed, as at the time of writing we do not guarantee dissemination of Commit
                                // records to the home shard, so we only know the executeAt shards will have witnessed this
                                // if the home shard is at an earlier phase, it must run recovery
                                long epoch = command.executeAt().epoch();
                                node.withEpoch(epoch, () -> debugInvestigating = FetchData.fetch(PreApplied.minKnown, node, txnId, command.route(), epoch, (success, fail) -> {
                                    commandStore.execute(PreLoadContext.empty(), ignore -> {
                                        // should have found enough information to apply the result, but in case we did not reset progress
                                        if (progress() == Investigating)
                                            setProgress(Expected);
                                    }).begin(commandStore.agent());
                                }));
                            }
                            else
                            {
                                RoutingKey homeKey = command.homeKey();
                                node.withEpoch(txnId.epoch(), () -> {

                                    AsyncResult<? extends Outcome> recover = node.maybeRecover(txnId, homeKey, command.route(), token);
                                    recover.addCallback((success, fail) -> {
                                        commandStore.execute(PreLoadContext.empty(), ignore -> {
                                            if (status.isAtMostReadyToExecute() && progress() == Investigating)
                                            {
                                                setProgress(Expected);
                                                if (fail != null)
                                                    return;

                                                ProgressToken token = success.asProgressToken();
                                                if (token.durability.isDurable())
                                                {
                                                    commandStore.execute(contextFor(txnId), safeStore -> {
                                                        Command cmd = Commands.setDurability(safeStore, txnId, token.durability, homeKey, null);
                                                        safeStore.progressLog().durable(txnId, cmd.maxUnseekables(), null);
                                                    }).begin(commandStore.agent());
                                                }

                                                updateMax(token);
                                            }
                                        }).begin(commandStore.agent());
                                    });

                                    debugInvestigating = recover;
                                });
                            }
                        }
                    }
                }