Search in sources :

Example 1 with RangeBasedPartitionAccessor

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

the class URIMapperTestUtil method createRangeBasedPartitionInfoProvider.

/**
 * Create a mock PartitionInfoProvider that returns {@link RangeBasedPartitionAccessor} for testing
 */
public static PartitionInfoProvider createRangeBasedPartitionInfoProvider(int partitionCount) throws ServiceUnavailableException {
    PartitionInfoProvider infoProvider = Mockito.mock(PartitionInfoProvider.class);
    RangeBasedPartitionProperties properties = new RangeBasedPartitionProperties(PARTITION_KEY_REGEX, 0, 1, partitionCount);
    RangeBasedPartitionAccessor accessor = new RangeBasedPartitionAccessor(properties);
    Mockito.when(infoProvider.getPartitionAccessor(anyObject())).thenReturn(accessor);
    return infoProvider;
}
Also used : PartitionInfoProvider(com.linkedin.d2.balancer.util.partitions.PartitionInfoProvider) RangeBasedPartitionAccessor(com.linkedin.d2.balancer.util.partitions.RangeBasedPartitionAccessor) RangeBasedPartitionProperties(com.linkedin.d2.balancer.properties.RangeBasedPartitionProperties)

Aggregations

RangeBasedPartitionProperties (com.linkedin.d2.balancer.properties.RangeBasedPartitionProperties)1 PartitionInfoProvider (com.linkedin.d2.balancer.util.partitions.PartitionInfoProvider)1 RangeBasedPartitionAccessor (com.linkedin.d2.balancer.util.partitions.RangeBasedPartitionAccessor)1