use of io.atomix.protocols.backup.partition.PrimaryBackupPartition in project atomix by atomix.
the class MultiPrimaryProtocol method newProxy.
@Override
public <S> ProxyClient<S> newProxy(String primitiveName, PrimitiveType primitiveType, Class<S> serviceType, ServiceConfig serviceConfig, PartitionService partitionService) {
PartitionGroup partitionGroup = partitionService.getPartitionGroup(this);
if (partitionGroup == null) {
throw new ConfigurationException("No Raft partition group matching the configured protocol exists");
}
Collection<SessionClient> partitions = partitionGroup.getPartitions().stream().map(partition -> ((PrimaryBackupPartition) partition).getClient().sessionBuilder(primitiveName, primitiveType, serviceConfig).withConsistency(config.getConsistency()).withReplication(config.getReplication()).withRecovery(config.getRecovery()).withNumBackups(config.getBackups()).withMaxRetries(config.getMaxRetries()).withRetryDelay(config.getRetryDelay()).build()).collect(Collectors.toList());
return new DefaultProxyClient<>(primitiveName, primitiveType, this, serviceType, partitions, config.getPartitioner());
}
Aggregations