use of io.atomix.protocols.backup.protocol.PrimitiveDescriptor in project atomix by atomix.
the class PrimaryBackupClient method newProxy.
@Override
@SuppressWarnings("unchecked")
public PrimitiveProxy newProxy(String primitiveName, PrimitiveType primitiveType, MultiPrimaryProtocol primitiveProtocol) {
Supplier<PrimitiveProxy> proxyBuilder = () -> new PrimaryBackupProxy(clientName, sessionIdService.nextSessionId().join(), primitiveType, new PrimitiveDescriptor(primitiveName, primitiveType.id(), primitiveProtocol.backups(), primitiveProtocol.replication()), clusterService, PrimaryBackupClient.this.protocol, primaryElection, threadContextFactory.createContext());
PrimitiveProxy proxy;
if (primitiveProtocol.recovery() == Recovery.RECOVER) {
proxy = new RecoveringPrimitiveProxy(clientName, primitiveName, primitiveType, proxyBuilder, threadContextFactory.createContext());
} else {
proxy = proxyBuilder.get();
}
// If max retries is set, wrap the client in a retrying proxy client.
if (primitiveProtocol.maxRetries() > 0) {
proxy = new RetryingPrimitiveProxy(proxy, threadContextFactory.createContext(), primitiveProtocol.maxRetries(), primitiveProtocol.retryDelay());
}
// Default the executor to use the configured thread pool executor and create a blocking aware proxy client.
Executor executor = primitiveProtocol.executor() != null ? primitiveProtocol.executor() : threadContextFactory.createContext();
return new BlockingAwarePrimitiveProxy(proxy, executor);
}
Aggregations