Search in sources :

Example 1 with CatchUpClosure

use of io.dingodb.raft.closure.CatchUpClosure in project dingo by dingodb.

the class Replicator method notifyOnCaughtUp.

private void notifyOnCaughtUp(final int code, final boolean beforeDestroy) {
    if (this.catchUpClosure == null) {
        return;
    }
    if (code != RaftError.ETIMEDOUT.getNumber()) {
        if (this.nextIndex - 1 + this.catchUpClosure.getMaxMargin() < this.options.getLogManager().getLastLogIndex()) {
            return;
        }
        if (this.catchUpClosure.isErrorWasSet()) {
            return;
        }
        this.catchUpClosure.setErrorWasSet(true);
        if (code != RaftError.SUCCESS.getNumber()) {
            this.catchUpClosure.getStatus().setError(code, RaftError.describeCode(code));
        }
        if (this.catchUpClosure.hasTimer()) {
            if (!beforeDestroy && !this.catchUpClosure.getTimer().cancel(true)) {
                // on_caught_up to void ABA problem
                return;
            }
        }
    } else {
        // timed out
        if (!this.catchUpClosure.isErrorWasSet()) {
            this.catchUpClosure.getStatus().setError(code, RaftError.describeCode(code));
        }
    }
    final CatchUpClosure savedClosure = this.catchUpClosure;
    this.catchUpClosure = null;
    RpcUtils.runClosureInThread(savedClosure, savedClosure.getStatus());
}
Also used : CatchUpClosure(io.dingodb.raft.closure.CatchUpClosure)

Aggregations

CatchUpClosure (io.dingodb.raft.closure.CatchUpClosure)1