Search in sources :

Example 1 with ExponentialBackoffRetry

use of org.apache.ratis.retry.ExponentialBackoffRetry in project incubator-ratis by apache.

the class RaftUtils method createClient.

/**
 * Create a raft client to communicate to ratis server.
 * @param raftGroup the raft group
 * @return return a raft client
 */
public static RaftClient createClient(RaftGroup raftGroup) {
    RaftProperties properties = new RaftProperties();
    RaftClientConfigKeys.Rpc.setRequestTimeout(properties, TimeDuration.valueOf(15, TimeUnit.SECONDS));
    ExponentialBackoffRetry retryPolicy = ExponentialBackoffRetry.newBuilder().setBaseSleepTime(TimeDuration.valueOf(1000, TimeUnit.MILLISECONDS)).setMaxAttempts(10).setMaxSleepTime(TimeDuration.valueOf(100_000, TimeUnit.MILLISECONDS)).build();
    return RaftClient.newBuilder().setRaftGroup(raftGroup).setProperties(properties).setRetryPolicy(retryPolicy).build();
}
Also used : ExponentialBackoffRetry(org.apache.ratis.retry.ExponentialBackoffRetry) RaftProperties(org.apache.ratis.conf.RaftProperties)

Aggregations

RaftProperties (org.apache.ratis.conf.RaftProperties)1 ExponentialBackoffRetry (org.apache.ratis.retry.ExponentialBackoffRetry)1