Search in sources :

Example 1 with Int8Value

use of com.yahoo.jrt.Int8Value in project vespa by vespa-engine.

the class RPCSendV1 method encodeRequest.

@Override
protected Request encodeRequest(Version version, Route route, RPCServiceAddress address, Message msg, long timeRemaining, byte[] payload, int traceLevel) {
    Request req = new Request(METHOD_NAME);
    Values v = req.parameters();
    v.add(new StringValue(version.toString()));
    v.add(new StringValue(route.toString()));
    v.add(new StringValue(address.getSessionName()));
    v.add(new Int8Value(msg.getRetryEnabled() ? (byte) 1 : (byte) 0));
    v.add(new Int32Value(msg.getRetry()));
    v.add(new Int64Value(timeRemaining));
    v.add(new StringValue(msg.getProtocol()));
    v.add(new DataValue(payload));
    v.add(new Int32Value(traceLevel));
    return req;
}
Also used : Int64Value(com.yahoo.jrt.Int64Value) DataValue(com.yahoo.jrt.DataValue) Request(com.yahoo.jrt.Request) Values(com.yahoo.jrt.Values) Int8Value(com.yahoo.jrt.Int8Value) Int32Value(com.yahoo.jrt.Int32Value) StringValue(com.yahoo.jrt.StringValue)

Example 2 with Int8Value

use of com.yahoo.jrt.Int8Value in project vespa by vespa-engine.

the class RPCSendV2 method encodeRequest.

@Override
protected Request encodeRequest(Version version, Route route, RPCServiceAddress address, Message msg, long timeRemaining, byte[] payload, int traceLevel) {
    Request req = new Request(METHOD_NAME);
    Values v = req.parameters();
    v.add(new Int8Value(CompressionType.NONE.getCode()));
    v.add(new Int32Value(0));
    v.add(new DataValue(new byte[0]));
    Slime slime = new Slime();
    Cursor root = slime.setObject();
    root.setString(VERSION_F, version.toString());
    root.setString(ROUTE_F, route.toString());
    root.setString(SESSION_F, address.getSessionName());
    root.setString(PROTOCOL_F, msg.getProtocol().toString());
    root.setBool(USERETRY_F, msg.getRetryEnabled());
    root.setLong(RETRY_F, msg.getRetry());
    root.setLong(TIMEREMAINING_F, msg.getTimeRemaining());
    root.setLong(TRACELEVEL_F, traceLevel);
    root.setData(BLOB_F, payload);
    byte[] serializedSlime = BinaryFormat.encode(slime);
    Compressor.Compression compressionResult = compressor.compress(serializedSlime);
    v.add(new Int8Value(compressionResult.type().getCode()));
    v.add(new Int32Value(compressionResult.uncompressedSize()));
    v.add(new DataValue(compressionResult.data()));
    return req;
}
Also used : DataValue(com.yahoo.jrt.DataValue) Request(com.yahoo.jrt.Request) Values(com.yahoo.jrt.Values) Int8Value(com.yahoo.jrt.Int8Value) Int32Value(com.yahoo.jrt.Int32Value) Compressor(com.yahoo.compress.Compressor) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Example 3 with Int8Value

use of com.yahoo.jrt.Int8Value in project vespa by vespa-engine.

the class RPCSendV2 method createResponse.

@Override
protected void createResponse(Values ret, Reply reply, Version version, byte[] payload) {
    ret.add(new Int8Value(CompressionType.NONE.getCode()));
    ret.add(new Int32Value(0));
    ret.add(new DataValue(new byte[0]));
    Slime slime = new Slime();
    Cursor root = slime.setObject();
    root.setString(VERSION_F, version.toString());
    root.setDouble(RETRYDELAY_F, reply.getRetryDelay());
    root.setString(PROTOCOL_F, reply.getProtocol().toString());
    root.setData(BLOB_F, payload);
    if (reply.getTrace().getLevel() > 0) {
        root.setString(TRACE_F, reply.getTrace().getRoot().encode());
    }
    if (reply.getNumErrors() > 0) {
        Cursor array = root.setArray(ERRORS_F);
        for (int i = 0; i < reply.getNumErrors(); i++) {
            Cursor e = array.addObject();
            Error mbusE = reply.getError(i);
            e.setLong(CODE_F, mbusE.getCode());
            e.setString(MSG_F, mbusE.getMessage());
            if (mbusE.getService() != null) {
                e.setString(SERVICE_F, mbusE.getService());
            }
        }
    }
    byte[] serializedSlime = BinaryFormat.encode(slime);
    Compressor.Compression compressionResult = compressor.compress(serializedSlime);
    ret.add(new Int8Value(compressionResult.type().getCode()));
    ret.add(new Int32Value(compressionResult.uncompressedSize()));
    ret.add(new DataValue(compressionResult.data()));
}
Also used : DataValue(com.yahoo.jrt.DataValue) Int8Value(com.yahoo.jrt.Int8Value) Int32Value(com.yahoo.jrt.Int32Value) Error(com.yahoo.messagebus.Error) Compressor(com.yahoo.compress.Compressor) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Example 4 with Int8Value

use of com.yahoo.jrt.Int8Value in project vespa by vespa-engine.

the class RpcClient method getDocsums.

@Override
public void getDocsums(List<FastHit> hits, NodeConnection node, CompressionType compression, int uncompressedLength, byte[] compressedSlime, Dispatcher.GetDocsumsResponseReceiver responseReceiver, double timeoutSeconds) {
    Request request = new Request("proton.getDocsums");
    request.parameters().add(new Int8Value(compression.getCode()));
    request.parameters().add(new Int32Value(uncompressedLength));
    request.parameters().add(new DataValue(compressedSlime));
    request.setContext(hits);
    RpcNodeConnection rpcNode = ((RpcNodeConnection) node);
    rpcNode.invokeAsync(request, timeoutSeconds, new RpcResponseWaiter(rpcNode, responseReceiver));
}
Also used : DataValue(com.yahoo.jrt.DataValue) Request(com.yahoo.jrt.Request) Int8Value(com.yahoo.jrt.Int8Value) Int32Value(com.yahoo.jrt.Int32Value)

Aggregations

DataValue (com.yahoo.jrt.DataValue)4 Int32Value (com.yahoo.jrt.Int32Value)4 Int8Value (com.yahoo.jrt.Int8Value)4 Request (com.yahoo.jrt.Request)3 Compressor (com.yahoo.compress.Compressor)2 Values (com.yahoo.jrt.Values)2 Cursor (com.yahoo.slime.Cursor)2 Slime (com.yahoo.slime.Slime)2 Int64Value (com.yahoo.jrt.Int64Value)1 StringValue (com.yahoo.jrt.StringValue)1 Error (com.yahoo.messagebus.Error)1