Search in sources :

Example 1 with PrimaryBackupPartition

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());
}
Also used : PartitionGroup(io.atomix.primitive.partition.PartitionGroup) ProxyProtocol(io.atomix.primitive.protocol.ProxyProtocol) ProxyClient(io.atomix.primitive.proxy.ProxyClient) PrimaryBackupPartition(io.atomix.protocols.backup.partition.PrimaryBackupPartition) Collection(java.util.Collection) PartitionGroup(io.atomix.primitive.partition.PartitionGroup) Collectors(java.util.stream.Collectors) ConfigurationException(io.atomix.utils.config.ConfigurationException) ServiceConfig(io.atomix.primitive.service.ServiceConfig) PrimitiveType(io.atomix.primitive.PrimitiveType) PartitionService(io.atomix.primitive.partition.PartitionService) PrimitiveProtocol(io.atomix.primitive.protocol.PrimitiveProtocol) DefaultProxyClient(io.atomix.primitive.proxy.impl.DefaultProxyClient) SessionClient(io.atomix.primitive.session.SessionClient) MoreObjects.toStringHelper(com.google.common.base.MoreObjects.toStringHelper) DefaultProxyClient(io.atomix.primitive.proxy.impl.DefaultProxyClient) ConfigurationException(io.atomix.utils.config.ConfigurationException) SessionClient(io.atomix.primitive.session.SessionClient) PrimaryBackupPartition(io.atomix.protocols.backup.partition.PrimaryBackupPartition)

Aggregations

MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)1 PrimitiveType (io.atomix.primitive.PrimitiveType)1 PartitionGroup (io.atomix.primitive.partition.PartitionGroup)1 PartitionService (io.atomix.primitive.partition.PartitionService)1 PrimitiveProtocol (io.atomix.primitive.protocol.PrimitiveProtocol)1 ProxyProtocol (io.atomix.primitive.protocol.ProxyProtocol)1 ProxyClient (io.atomix.primitive.proxy.ProxyClient)1 DefaultProxyClient (io.atomix.primitive.proxy.impl.DefaultProxyClient)1 ServiceConfig (io.atomix.primitive.service.ServiceConfig)1 SessionClient (io.atomix.primitive.session.SessionClient)1 PrimaryBackupPartition (io.atomix.protocols.backup.partition.PrimaryBackupPartition)1 ConfigurationException (io.atomix.utils.config.ConfigurationException)1 Collection (java.util.Collection)1 Collectors (java.util.stream.Collectors)1