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));
}
}
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;
}
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;
}
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()])));
}
Aggregations