Search in sources :

Example 1 with RaftClientService

use of org.apache.ignite.raft.jraft.rpc.RaftClientService in project ignite-3 by apache.

the class ReplicatorGroupImpl method addReplicator.

// TODO asch sync flag is not used https://issues.apache.org/jira/browse/IGNITE-14832
@Override
public boolean addReplicator(final PeerId peer, final ReplicatorType replicatorType, final boolean sync) {
    Requires.requireTrue(this.commonOptions.getTerm() != 0);
    this.failureReplicators.remove(peer);
    if (this.replicatorMap.containsKey(peer)) {
        return true;
    }
    final ReplicatorOptions opts = this.commonOptions == null ? new ReplicatorOptions() : this.commonOptions.copy();
    opts.setReplicatorType(replicatorType);
    opts.setPeerId(peer);
    final RaftClientService client = opts.getRaftRpcService();
    assert client != null;
    if (!client.connect(peer.getEndpoint())) {
        LOG.error("Fail to check replicator connection to peer={}, replicatorType={}.", peer, replicatorType);
        this.failureReplicators.put(peer, replicatorType);
        return false;
    }
    // if (!sync) {
    // final RaftClientService client = opts.getRaftRpcService();
    // 
    // assert client != null;
    // 
    // if (!client.connect(peer.getEndpoint())) {
    // LOG.error("Fail to check replicator connection to peer={}, replicatorType={}.", peer, replicatorType);
    // this.failureReplicators.put(peer, replicatorType);
    // return false;
    // }
    // 
    // //            else
    // //                RpcUtils.runInThread(() -> checkReplicator(peer, true));
    // }
    final ThreadId rid = Replicator.start(opts, this.raftOptions);
    if (rid == null) {
        LOG.error("Fail to start replicator to peer={}, replicatorType={}.", peer, replicatorType);
        this.failureReplicators.put(peer, replicatorType);
        return false;
    }
    return this.replicatorMap.put(peer, rid) == null;
}
Also used : RaftClientService(org.apache.ignite.raft.jraft.rpc.RaftClientService) ThreadId(org.apache.ignite.raft.jraft.util.ThreadId) ReplicatorOptions(org.apache.ignite.raft.jraft.option.ReplicatorOptions)

Aggregations

ReplicatorOptions (org.apache.ignite.raft.jraft.option.ReplicatorOptions)1 RaftClientService (org.apache.ignite.raft.jraft.rpc.RaftClientService)1 ThreadId (org.apache.ignite.raft.jraft.util.ThreadId)1