assertEquals(d2Conf.runDiscovery(_zkHosts), 0);
verifyPartitionProperties("partitioned-cluster", partitionProperties);
final ClusterProperties clusterprops = getClusterProperties(_zkclient, "partitioned-cluster" );
final PartitionAccessor accessor = PartitionAccessorFactory.getPartitionAccessor(clusterprops.getPartitionProperties());
try
{
accessor.getPartitionId(-1 + "");
fail("Exception expected");
}
catch (PartitionAccessException e){}
try
{
accessor.getPartitionId(1000 + "");
fail("Exception expected");
}
catch (PartitionAccessException e){}
assertEquals(0, accessor.getPartitionId(0 + ""));
assertEquals(0, accessor.getPartitionId(99 + ""));
assertEquals(1, accessor.getPartitionId(176 + ""));
assertEquals(8, accessor.getPartitionId(833 + ""));
final String legalUri1 = "/profiles?field=position&id=100";
final String legalUri2 = "/profiles?wid=99&id=176&randid=301";
final String illegalUri1 = "/profiles?wid=99";
final String illegalUri2 = "/profiles?id=1000000000000000000000000000000000000000000000111111111";
try
{
accessor.getPartitionId(URI.create(illegalUri1));
fail("Exception expected");
}
catch (PartitionAccessException e) {}
try
{
accessor.getPartitionId(URI.create(illegalUri2));
fail("Exception expected");
}
catch (PartitionAccessException e) {}
assertEquals(1, accessor.getPartitionId(URI.create(legalUri1)));
assertEquals(1, accessor.getPartitionId(URI.create(legalUri2)));
// Start Echo server on cluster-1
Map<Integer, Double> serverConfig1 = new HashMap<Integer, Double>();
serverConfig1.put(0, 0.5d);