Search in sources :

Example 6 with com.linkedin.d2.quarantineInfo

use of com.linkedin.d2.quarantineInfo in project rest.li by linkedin.

the class PartitionPropertiesConverterTest method testHashMD5PartitionProperties.

@Test
public void testHashMD5PartitionProperties() {
    final String partitionKeyRegex = "/foo/bar/(\\d+)";
    final int partitionCount = 8;
    final HashBasedPartitionProperties.HashAlgorithm hashAlgorithm = HashBasedPartitionProperties.HashAlgorithm.MD5;
    PartitionProperties partitionProperties = new HashBasedPartitionProperties(partitionKeyRegex, partitionCount, hashAlgorithm);
    D2ClusterPartitionConfiguration.PartitionTypeSpecificData data = new D2ClusterPartitionConfiguration.PartitionTypeSpecificData();
    data.setHashAlgorithm(com.linkedin.d2.hashAlgorithm.MD5);
    D2ClusterPartitionConfiguration partitionConfig = new D2ClusterPartitionConfiguration().setType(PartitionTypeEnum.HASH).setPartitionKeyRegex(partitionKeyRegex).setPartitionCount(partitionCount).setPartitionTypeSpecificData(data);
    Assert.assertEquals(PartitionPropertiesConverter.toProperties(partitionConfig), partitionProperties);
    Assert.assertEquals(PartitionPropertiesConverter.toConfig(partitionProperties), partitionConfig);
}
Also used : com.linkedin.d2.rangedPartitionProperties(com.linkedin.d2.rangedPartitionProperties) PartitionProperties(com.linkedin.d2.balancer.properties.PartitionProperties) NullPartitionProperties(com.linkedin.d2.balancer.properties.NullPartitionProperties) HashBasedPartitionProperties(com.linkedin.d2.balancer.properties.HashBasedPartitionProperties) RangeBasedPartitionProperties(com.linkedin.d2.balancer.properties.RangeBasedPartitionProperties) HashBasedPartitionProperties(com.linkedin.d2.balancer.properties.HashBasedPartitionProperties) D2ClusterPartitionConfiguration(com.linkedin.d2.D2ClusterPartitionConfiguration) Test(org.testng.annotations.Test)

Aggregations

HashMap (java.util.HashMap)4 com.linkedin.d2.hashConfigType (com.linkedin.d2.hashConfigType)3 com.linkedin.d2.quarantineInfo (com.linkedin.d2.quarantineInfo)3 Test (org.testng.annotations.Test)3 D2ClusterPartitionConfiguration (com.linkedin.d2.D2ClusterPartitionConfiguration)2 D2LoadBalancerStrategyProperties (com.linkedin.d2.D2LoadBalancerStrategyProperties)2 HashBasedPartitionProperties (com.linkedin.d2.balancer.properties.HashBasedPartitionProperties)2 NullPartitionProperties (com.linkedin.d2.balancer.properties.NullPartitionProperties)2 PartitionProperties (com.linkedin.d2.balancer.properties.PartitionProperties)2 RangeBasedPartitionProperties (com.linkedin.d2.balancer.properties.RangeBasedPartitionProperties)2 com.linkedin.d2.rangedPartitionProperties (com.linkedin.d2.rangedPartitionProperties)2 StringArray (com.linkedin.data.template.StringArray)2 ConsistentHashAlgorithmEnum (com.linkedin.d2.ConsistentHashAlgorithmEnum)1 LoadBalancerState (com.linkedin.d2.balancer.LoadBalancerState)1 ServiceUnavailableException (com.linkedin.d2.balancer.ServiceUnavailableException)1 TrackerClient (com.linkedin.d2.balancer.clients.TrackerClient)1 ClusterProperties (com.linkedin.d2.balancer.properties.ClusterProperties)1 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)1 UriProperties (com.linkedin.d2.balancer.properties.UriProperties)1 HostToKeyMapper (com.linkedin.d2.balancer.util.HostToKeyMapper)1