use of io.atomix.protocols.raft.session.impl.DefaultRaftSessionClient in project atomix by atomix.
the class DefaultRaftClient method sessionBuilder.
@Override
public RaftSessionClient.Builder sessionBuilder(String primitiveName, PrimitiveType primitiveType, ServiceConfig serviceConfig) {
return new RaftSessionClient.Builder() {
@Override
public SessionClient build() {
// Create a proxy builder that uses the session manager to open a session.
Supplier<CompletableFuture<SessionClient>> proxyFactory = () -> CompletableFuture.completedFuture(new DefaultRaftSessionClient(primitiveName, primitiveType, serviceConfig, partitionId, DefaultRaftClient.this.protocol, selectorManager, sessionManager, readConsistency, communicationStrategy, threadContextFactory.createContext(), minTimeout, maxTimeout));
SessionClient proxy;
ThreadContext context = threadContextFactory.createContext();
// If the recovery strategy is set to RECOVER, wrap the builder in a recovering proxy client.
if (recoveryStrategy == Recovery.RECOVER) {
proxy = new RecoveringSessionClient(clientId, partitionId, primitiveName, primitiveType, proxyFactory, context);
} else {
proxy = proxyFactory.get().join();
}
// If max retries is set, wrap the client in a retrying proxy client.
if (maxRetries > 0) {
proxy = new RetryingSessionClient(proxy, context, maxRetries, retryDelay);
}
return new BlockingAwareSessionClient(proxy, context);
}
};
}
Aggregations