Search in sources :

Example 36 with Reply

use of com.yahoo.messagebus.Reply in project vespa by vespa-engine.

the class CustomPolicy method merge.

public void merge(RoutingContext context) {
    List<String> lst = new ArrayList<String>();
    Reply ret = new EmptyReply();
    for (RoutingNodeIterator it = context.getChildIterator(); it.isValid(); it.next()) {
        lst.add(it.getRoute().toString());
        Reply reply = it.getReplyRef();
        for (int i = 0; i < reply.getNumErrors(); ++i) {
            ret.addError(reply.getError(i));
        }
    }
    context.setReply(ret);
    context.trace(1, "Merged " + lst + ".");
}
Also used : RoutingNodeIterator(com.yahoo.messagebus.routing.RoutingNodeIterator) ArrayList(java.util.ArrayList) Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) EmptyReply(com.yahoo.messagebus.EmptyReply)

Example 37 with Reply

use of com.yahoo.messagebus.Reply 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)

Example 38 with Reply

use of com.yahoo.messagebus.Reply in project vespa by vespa-engine.

the class LoadBalancerPolicy method merge.

public void merge(RoutingContext context) {
    RoutingNodeIterator it = context.getChildIterator();
    Reply reply = it.removeReply();
    LoadBalancer.Node target = (LoadBalancer.Node) context.getContext();
    boolean busy = false;
    for (int i = 0; i < reply.getNumErrors(); i++) {
        if (reply.getError(i).getCode() == ErrorCode.SESSION_BUSY) {
            busy = true;
        }
    }
    loadBalancer.received(target, busy);
    context.setReply(reply);
}
Also used : RoutingNodeIterator(com.yahoo.messagebus.routing.RoutingNodeIterator) Reply(com.yahoo.messagebus.Reply)

Example 39 with Reply

use of com.yahoo.messagebus.Reply in project vespa by vespa-engine.

the class RoundRobinPolicy method select.

// Inherit doc from RoutingPolicy.
public void select(RoutingContext ctx) {
    Hop hop = getRecipient(ctx);
    if (hop != null) {
        Route route = new Route(ctx.getRoute());
        route.setHop(0, hop);
        ctx.addChild(route);
    } else {
        Reply reply = new EmptyReply();
        reply.addError(new Error(ErrorCode.NO_ADDRESS_FOR_SERVICE, "None of the configured recipients are currently available."));
        ctx.setReply(reply);
    }
}
Also used : Hop(com.yahoo.messagebus.routing.Hop) Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) Error(com.yahoo.messagebus.Error) Route(com.yahoo.messagebus.routing.Route) EmptyReply(com.yahoo.messagebus.EmptyReply)

Aggregations

Reply (com.yahoo.messagebus.Reply)39 EmptyReply (com.yahoo.messagebus.EmptyReply)18 Message (com.yahoo.messagebus.Message)14 Error (com.yahoo.messagebus.Error)9 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)7 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)7 Test (org.junit.Test)7 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)6 BatchDocumentUpdateMessage (com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage)5 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)5 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)4 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)3 Response (com.yahoo.jdisc.Response)3 RoutingNode (com.yahoo.messagebus.routing.RoutingNode)3 RoutingNodeIterator (com.yahoo.messagebus.routing.RoutingNodeIterator)3 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)3 Version (com.yahoo.component.Version)2 Document (com.yahoo.document.Document)2 DocumentAccessException (com.yahoo.documentapi.DocumentAccessException)2 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)2