Search in sources :

Example 1 with Hop

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

the class RPCNetwork method allocServiceAddress.

@Override
public boolean allocServiceAddress(RoutingNode recipient) {
    Hop hop = recipient.getRoute().getHop(0);
    String service = hop.getServiceName();
    Error error = resolveServiceAddress(recipient, service);
    if (error == null) {
        // service address resolved
        return true;
    }
    recipient.setError(error);
    // service address not resolved
    return false;
}
Also used : Hop(com.yahoo.messagebus.routing.Hop) Error(com.yahoo.messagebus.Error)

Example 2 with Hop

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

the class DocumentOperationMessageV3 method newErrorMessage.

static DocumentOperationMessageV3 newErrorMessage(String operationId, Exception exception) {
    Message feedErrorMessageV3 = new FeedErrorMessage(operationId);
    DocumentOperationMessageV3 msg = new DocumentOperationMessageV3(operationId, feedErrorMessageV3);
    Hop hop = new Hop();
    hop.addDirective(new ErrorDirective(Exceptions.toMessageString(exception)));
    Route route = new Route();
    route.addHop(hop);
    feedErrorMessageV3.setRoute(route);
    return msg;
}
Also used : UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) Hop(com.yahoo.messagebus.routing.Hop) ErrorDirective(com.yahoo.messagebus.routing.ErrorDirective) Route(com.yahoo.messagebus.routing.Route)

Example 3 with Hop

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

the class Feeder method newErrorMessage.

private Tuple2<String, Message> newErrorMessage(String operationId, Exception e) {
    Message m = new FeedErrorMessage(operationId);
    Tuple2<String, Message> msg = new Tuple2<>(operationId, m);
    Hop hop = new Hop();
    hop.addDirective(new ErrorDirective(Exceptions.toMessageString(e)));
    Route route = new Route();
    route.addHop(hop);
    m.setRoute(route);
    return msg;
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) Tuple2(com.yahoo.collections.Tuple2) Hop(com.yahoo.messagebus.routing.Hop) Utf8String(com.yahoo.text.Utf8String) ErrorDirective(com.yahoo.messagebus.routing.ErrorDirective) Route(com.yahoo.messagebus.routing.Route)

Example 4 with Hop

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

the class RPCSend method send.

@Override
public final void send(RoutingNode recipient, Version version, byte[] payload, long timeRemaining) {
    SendContext ctx = new SendContext(recipient, timeRemaining);
    RPCServiceAddress address = (RPCServiceAddress) recipient.getServiceAddress();
    Message msg = recipient.getMessage();
    Route route = new Route(recipient.getRoute());
    Hop hop = route.removeHop(0);
    Request req = encodeRequest(version, route, address, msg, timeRemaining, payload, ctx.trace.getLevel());
    if (ctx.trace.shouldTrace(TraceLevel.SEND_RECEIVE)) {
        ctx.trace.trace(TraceLevel.SEND_RECEIVE, "Sending message (version " + version + ") from " + clientIdent + " to '" + address.getServiceName() + "' with " + ctx.timeout + " seconds timeout.");
    }
    if (hop.getIgnoreResult()) {
        address.getTarget().getJRTTarget().invokeVoid(req);
        if (ctx.trace.shouldTrace(TraceLevel.SEND_RECEIVE)) {
            ctx.trace.trace(TraceLevel.SEND_RECEIVE, "Not waiting for a reply from '" + address.getServiceName() + "'.");
        }
        Reply reply = new EmptyReply();
        reply.getTrace().swap(ctx.trace);
        net.getOwner().deliverReply(reply, recipient);
    } else {
        req.setContext(ctx);
        address.getTarget().getJRTTarget().invokeAsync(req, ctx.timeout, this);
    }
    // allow garbage collection of request parameters
    req.discardParameters();
}
Also used : Message(com.yahoo.messagebus.Message) Hop(com.yahoo.messagebus.routing.Hop) Request(com.yahoo.jrt.Request) Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) Route(com.yahoo.messagebus.routing.Route) EmptyReply(com.yahoo.messagebus.EmptyReply)

Example 5 with Hop

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

the class ANDPolicy method select.

// Inherit doc from RoutingPolicy.
public void select(RoutingContext context) {
    if (hops.isEmpty()) {
        context.addChildren(context.getAllRecipients());
    } else {
        for (Hop hop : hops) {
            Route route = new Route(context.getRoute());
            route.setHop(0, hop);
            context.addChild(route);
        }
    }
    context.setSelectOnRetry(false);
    context.addConsumableError(DocumentProtocol.ERROR_MESSAGE_IGNORED);
}
Also used : Hop(com.yahoo.messagebus.routing.Hop) Route(com.yahoo.messagebus.routing.Route)

Aggregations

Hop (com.yahoo.messagebus.routing.Hop)6 Route (com.yahoo.messagebus.routing.Route)5 Message (com.yahoo.messagebus.Message)3 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)2 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)2 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)2 EmptyReply (com.yahoo.messagebus.EmptyReply)2 Error (com.yahoo.messagebus.Error)2 Reply (com.yahoo.messagebus.Reply)2 ErrorDirective (com.yahoo.messagebus.routing.ErrorDirective)2 Tuple2 (com.yahoo.collections.Tuple2)1 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)1 Request (com.yahoo.jrt.Request)1 Utf8String (com.yahoo.text.Utf8String)1