use of com.linkedin.d2.balancer.util.partitions.PartitionInfoProvider 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;
}
use of com.linkedin.d2.balancer.util.partitions.PartitionInfoProvider 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;
}
use of com.linkedin.d2.balancer.util.partitions.PartitionInfoProvider in project rest.li by linkedin.
the class TestRestLiScatterGather method getURIMapper.
private static URIMapper getURIMapper(boolean sticky, boolean partitioned, String regex) throws ServiceUnavailableException {
int partitionCount = partitioned ? 10 : 1;
int totalHostCount = 100;
HashRingProvider ringProvider = createStaticHashRingProvider(totalHostCount, partitionCount, getHashFunction(sticky));
PartitionInfoProvider infoProvider = createHashBasedPartitionInfoProvider(partitionCount, regex);
return new RingBasedUriMapper(ringProvider, infoProvider);
}
Aggregations