Search in sources :

Example 36 with Message

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

the class StoragePolicyTestEnvironment method createMessage.

protected static Message createMessage(String id) {
    Message msg = new RemoveDocumentMessage(new DocumentId(id));
    msg.getTrace().setLevel(9);
    return msg;
}
Also used : Message(com.yahoo.messagebus.Message) DocumentId(com.yahoo.document.DocumentId)

Example 37 with Message

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

the class MbusClient method handleRequest.

@Override
public ContentChannel handleRequest(final Request request, final ResponseHandler handler) {
    if (!(request instanceof MbusRequest)) {
        throw new RequestDeniedException(request);
    }
    final Message msg = ((MbusRequest) request).getMessage();
    msg.getTrace().trace(6, "Request received by MbusClient.");
    // save user context
    msg.pushHandler(null);
    final Long timeout = request.timeRemaining(TimeUnit.MILLISECONDS);
    if (timeout != null) {
        msg.setTimeReceivedNow();
        // negative or zero timeout has semantics
        msg.setTimeRemaining(Math.max(1, timeout));
    }
    msg.setContext(handler);
    msg.pushHandler(this);
    queue.add((MbusRequest) request);
    return null;
}
Also used : RequestDeniedException(com.yahoo.jdisc.handler.RequestDeniedException) Message(com.yahoo.messagebus.Message)

Example 38 with Message

use of com.yahoo.messagebus.Message 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 39 with Message

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

Message (com.yahoo.messagebus.Message)39 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)17 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)15 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)15 Reply (com.yahoo.messagebus.Reply)14 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)13 Test (org.junit.Test)13 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)9 Chain (com.yahoo.component.chain.Chain)7 FeedContext (com.yahoo.feedapi.FeedContext)7 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)7 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)7 Searcher (com.yahoo.search.Searcher)7 Execution (com.yahoo.search.searchchain.Execution)7 ClusterList (com.yahoo.vespaclient.ClusterList)7 Result (com.yahoo.search.Result)6 Utf8String (com.yahoo.text.Utf8String)6 BatchDocumentUpdateMessage (com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage)5 Tuple2 (com.yahoo.collections.Tuple2)4 EmptyReply (com.yahoo.messagebus.EmptyReply)4