Search in sources :

Example 36 with Request

use of com.yahoo.jrt.Request 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)

Aggregations

Request (com.yahoo.jrt.Request)36 Test (org.junit.Test)18 Spec (com.yahoo.jrt.Spec)14 StringValue (com.yahoo.jrt.StringValue)14 Target (com.yahoo.jrt.Target)13 Supervisor (com.yahoo.jrt.Supervisor)10 Transport (com.yahoo.jrt.Transport)10 Int32Value (com.yahoo.jrt.Int32Value)6 NodeState (com.yahoo.vdslib.state.NodeState)5 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)4 Node (com.yahoo.vdslib.state.Node)4 DataValue (com.yahoo.jrt.DataValue)3 Int8Value (com.yahoo.jrt.Int8Value)3 Distribution (com.yahoo.vdslib.distribution.Distribution)3 StringArray (com.yahoo.jrt.StringArray)2 Values (com.yahoo.jrt.Values)2 ClusterState (com.yahoo.vdslib.state.ClusterState)2 RawConfig (com.yahoo.vespa.config.RawConfig)2 JRTServerConfigRequestV3 (com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3)2 ArrayList (java.util.ArrayList)2