Search in sources :

Example 1 with FutureImpl

use of io.dingodb.raft.rpc.impl.FutureImpl in project dingo by dingodb.

the class DefaultRaftClientService method onConnectionFail.

// fail-fast when no connection
private Future<Message> onConnectionFail(final Endpoint endpoint, final Message request, Closure done, final Executor executor) {
    final FutureImpl<Message> future = new FutureImpl<>();
    executor.execute(() -> {
        final String fmt = "Check connection[%s] fail and try to create new one";
        if (done != null) {
            try {
                done.run(new Status(RaftError.EINTERNAL, fmt, endpoint));
            } catch (final Throwable t) {
                LOG.error("Fail to run RpcResponseClosure, the request is {}.", request, t);
            }
        }
        if (!future.isDone()) {
            future.failure(new RemotingException(String.format(fmt, endpoint)));
        }
    });
    return future;
}
Also used : Status(io.dingodb.raft.Status) Message(com.google.protobuf.Message) FutureImpl(io.dingodb.raft.rpc.impl.FutureImpl) RemotingException(io.dingodb.raft.error.RemotingException)

Aggregations

Message (com.google.protobuf.Message)1 Status (io.dingodb.raft.Status)1 RemotingException (io.dingodb.raft.error.RemotingException)1 FutureImpl (io.dingodb.raft.rpc.impl.FutureImpl)1