Search in sources :

Example 1 with WrongDistributionReply

use of com.yahoo.documentapi.messagebus.protocol.WrongDistributionReply in project vespa by vespa-engine.

the class BasicTests method testVerifyBucketOneNodePreferenceInTenNodeDefaultCluster.

/**
 * To be independent of changes in distribution algorithm, we programmatically calculate preferred order of
 * bucket 1, which we will be using in the tests. To avoid doing this ahead of every test, we still hardcode the
 * values, though only one place, and have this test to verify they are correct, and make it easy to update the values.
 */
public void testVerifyBucketOneNodePreferenceInTenNodeDefaultCluster() {
    int[] result = new int[10];
    setClusterNodes(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    String clusterState = " bits:16 storage:10 distributor:10";
    for (int i = 0; i < 10; ++i) {
        // Update cached cluster state, to reflect which node we want to find
        RoutingNode target = select();
        target.handleReply(new WrongDistributionReply("version:" + (i + 1) + clusterState));
        Reply reply = frame.getReceptor().getReply(60);
        assertNotNull(reply);
        assertFalse(reply.hasErrors());
        // Find correct target
        target = select();
        Pair<String, Integer> address = getAddress(target);
        result[i] = address.getSecond();
        removeNode(address.getSecond());
        clusterState += " ." + result[i] + ".s:d";
    }
    assertEquals(Arrays.toString(bucketOneNodePreference), Arrays.toString(result));
}
Also used : RoutingNode(com.yahoo.messagebus.routing.RoutingNode) Reply(com.yahoo.messagebus.Reply) WrongDistributionReply(com.yahoo.documentapi.messagebus.protocol.WrongDistributionReply) WrongDistributionReply(com.yahoo.documentapi.messagebus.protocol.WrongDistributionReply)

Aggregations

WrongDistributionReply (com.yahoo.documentapi.messagebus.protocol.WrongDistributionReply)1 Reply (com.yahoo.messagebus.Reply)1 RoutingNode (com.yahoo.messagebus.routing.RoutingNode)1