Search in sources :

Example 6 with Routable

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

the class RPCSend method doInvoke.

private void doInvoke(Request request) {
    Params p = toParams(request.parameters());
    // allow garbage collection of request parameters
    request.discardParameters();
    // Make sure that the owner understands the protocol.
    Protocol protocol = net.getOwner().getProtocol(p.protocolName);
    if (protocol == null) {
        replyError(request, p.version, p.traceLevel, new Error(ErrorCode.UNKNOWN_PROTOCOL, "Protocol '" + p.protocolName + "' is not known by " + serverIdent + "."));
        return;
    }
    Routable routable = protocol.decode(p.version, p.payload);
    if (routable == null) {
        replyError(request, p.version, p.traceLevel, new Error(ErrorCode.DECODE_ERROR, "Protocol '" + protocol.getName() + "' failed to decode routable."));
        return;
    }
    if (routable instanceof Reply) {
        replyError(request, p.version, p.traceLevel, new Error(ErrorCode.DECODE_ERROR, "Payload decoded to a reply when expecting a message."));
        return;
    }
    Message msg = (Message) routable;
    if (p.route != null && p.route.length() > 0) {
        msg.setRoute(net.getRoute(p.route));
    }
    msg.setContext(new ReplyContext(request, p.version));
    msg.pushHandler(this);
    msg.setRetryEnabled(p.retryEnabled);
    msg.setRetry(p.retry);
    msg.setTimeReceivedNow();
    msg.setTimeRemaining(p.timeRemaining);
    msg.getTrace().setLevel(p.traceLevel);
    if (msg.getTrace().shouldTrace(TraceLevel.SEND_RECEIVE)) {
        msg.getTrace().trace(TraceLevel.SEND_RECEIVE, "Message (type " + msg.getType() + ") received at " + serverIdent + " for session '" + p.session + "'.");
    }
    net.getOwner().deliverMessage(msg, p.session);
}
Also used : Message(com.yahoo.messagebus.Message) Error(com.yahoo.messagebus.Error) Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) Protocol(com.yahoo.messagebus.Protocol) Routable(com.yahoo.messagebus.Routable)

Aggregations

Routable (com.yahoo.messagebus.Routable)6 Test (org.junit.Test)2 Version (com.yahoo.component.Version)1 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)1 EmptyReply (com.yahoo.messagebus.EmptyReply)1 Error (com.yahoo.messagebus.Error)1 Message (com.yahoo.messagebus.Message)1 Protocol (com.yahoo.messagebus.Protocol)1 Reply (com.yahoo.messagebus.Reply)1 IOException (java.io.IOException)1