Search in sources :

Example 1 with HashBasedPartitionAccessor

use of com.linkedin.d2.balancer.util.partitions.HashBasedPartitionAccessor in project rest.li by linkedin.

the class URIMapperTestUtil method createHashBasedPartitionInfoProvider.

/**
 * Create a mock PartitionInfoProvider that returns {@link HashBasedPartitionAccessor} for testing
 */
public static PartitionInfoProvider createHashBasedPartitionInfoProvider(int partitionCount, String regex) throws ServiceUnavailableException {
    PartitionInfoProvider infoProvider = Mockito.mock(PartitionInfoProvider.class);
    HashBasedPartitionProperties properties = new HashBasedPartitionProperties(regex, partitionCount, HashBasedPartitionProperties.HashAlgorithm.MODULO);
    HashBasedPartitionAccessor accessor = new HashBasedPartitionAccessor(properties);
    Mockito.when(infoProvider.getPartitionAccessor(anyObject())).thenReturn(accessor);
    return infoProvider;
}
Also used : PartitionInfoProvider(com.linkedin.d2.balancer.util.partitions.PartitionInfoProvider) HashBasedPartitionProperties(com.linkedin.d2.balancer.properties.HashBasedPartitionProperties) HashBasedPartitionAccessor(com.linkedin.d2.balancer.util.partitions.HashBasedPartitionAccessor)

Aggregations

HashBasedPartitionProperties (com.linkedin.d2.balancer.properties.HashBasedPartitionProperties)1 HashBasedPartitionAccessor (com.linkedin.d2.balancer.util.partitions.HashBasedPartitionAccessor)1 PartitionInfoProvider (com.linkedin.d2.balancer.util.partitions.PartitionInfoProvider)1