Search in sources :

Example 6 with D2ClusterPartitionConfiguration

use of com.linkedin.d2.D2ClusterPartitionConfiguration 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 : PartitionProperties(com.linkedin.d2.balancer.properties.PartitionProperties) RangedPartitionProperties(com.linkedin.d2.RangedPartitionProperties) 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

RangedPartitionProperties (com.linkedin.d2.RangedPartitionProperties)6 HashBasedPartitionProperties (com.linkedin.d2.balancer.properties.HashBasedPartitionProperties)6 RangeBasedPartitionProperties (com.linkedin.d2.balancer.properties.RangeBasedPartitionProperties)6 D2ClusterPartitionConfiguration (com.linkedin.d2.D2ClusterPartitionConfiguration)5 NullPartitionProperties (com.linkedin.d2.balancer.properties.NullPartitionProperties)5 PartitionProperties (com.linkedin.d2.balancer.properties.PartitionProperties)5 Test (org.testng.annotations.Test)4 CustomizedPartitionProperties (com.linkedin.d2.balancer.properties.CustomizedPartitionProperties)2 PartitionAccessorList (com.linkedin.d2.PartitionAccessorList)1 StringArray (com.linkedin.data.template.StringArray)1