Search in sources :

Example 1 with Values

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

the class BackendStatistics method invoke.

public void invoke(Request request) {
    try {
        Collection<ClusterSearcher> searchers = clusterSearchers(request);
        List<String> backendIdentificators = new ArrayList<>();
        List<Integer> activeConnections = new ArrayList<>();
        List<Integer> totalConnections = new ArrayList<>();
        for (ClusterSearcher searcher : searchers) {
            for (Map.Entry<String, Backend.BackendStatistics> statistics : searcher.getBackendStatistics().entrySet()) {
                backendIdentificators.add(statistics.getKey());
                activeConnections.add(statistics.getValue().activeConnections);
                totalConnections.add(statistics.getValue().totalConnections());
            }
        }
        Values returnValues = request.returnValues();
        returnValues.add(new StringArray(backendIdentificators.toArray(new String[0])));
        addInt32Array(returnValues, activeConnections);
        addInt32Array(returnValues, totalConnections);
    } catch (Exception e) {
        request.setError(1000, Exceptions.toMessageString(e));
    }
}
Also used : ArrayList(java.util.ArrayList) Values(com.yahoo.jrt.Values) StringArray(com.yahoo.jrt.StringArray) ClusterSearcher(com.yahoo.prelude.cluster.ClusterSearcher) Map(java.util.Map)

Example 2 with Values

use of com.yahoo.jrt.Values 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 3 with Values

use of com.yahoo.jrt.Values 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 4 with Values

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

the class Register method handleRpcList.

private synchronized void handleRpcList(Request req) {
    Values dst = req.returnValues();
    dst.add(new StringArray(names.toArray(new String[names.size()])));
}
Also used : StringArray(com.yahoo.jrt.StringArray) Values(com.yahoo.jrt.Values)

Aggregations

Values (com.yahoo.jrt.Values)4 DataValue (com.yahoo.jrt.DataValue)2 Int32Value (com.yahoo.jrt.Int32Value)2 Int8Value (com.yahoo.jrt.Int8Value)2 Request (com.yahoo.jrt.Request)2 StringArray (com.yahoo.jrt.StringArray)2 Compressor (com.yahoo.compress.Compressor)1 Int64Value (com.yahoo.jrt.Int64Value)1 StringValue (com.yahoo.jrt.StringValue)1 ClusterSearcher (com.yahoo.prelude.cluster.ClusterSearcher)1 Cursor (com.yahoo.slime.Cursor)1 Slime (com.yahoo.slime.Slime)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1