use of com.yahoo.jrt.Request in project vespa by vespa-engine.
the class TestWithRpc method pingServer.
private void pingServer() {
long endTime = System.currentTimeMillis() + 60_000;
Request req = new Request("ping");
while (System.currentTimeMillis() < endTime) {
performRequest(req);
if (!req.isError() && req.returnValues().size() > 0 && req.returnValues().get(0).asInt32() == 0) {
break;
}
req = new Request("ping");
}
assertFalse(req.isError());
assertTrue(req.returnValues().size() > 0);
assertThat(req.returnValues().get(0).asInt32(), is(0));
}
use of com.yahoo.jrt.Request 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.Request 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.Request in project vespa by vespa-engine.
the class FileReferenceDownloader method startDownloadRpc.
private boolean startDownloadRpc(FileReferenceDownload fileReferenceDownload) {
Connection connection = connectionPool.getCurrent();
Request request = new Request("filedistribution.serveFile");
String fileReference = fileReferenceDownload.fileReference().value();
request.parameters().add(new StringValue(fileReference));
request.parameters().add(new Int32Value(fileReferenceDownload.downloadFromOtherSourceIfNotFound() ? 0 : 1));
execute(request, connection);
if (validateResponse(request)) {
log.log(LogLevel.DEBUG, () -> "Request callback, OK. Req: " + request + "\nSpec: " + connection);
if (request.returnValues().get(0).asInt32() == 0) {
log.log(LogLevel.DEBUG, () -> "Found file reference '" + fileReference + "' available at " + connection.getAddress());
return true;
} else {
log.log(LogLevel.DEBUG, "File reference '" + fileReference + "' not found for " + connection.getAddress());
connectionPool.setNewCurrentConnection();
return false;
}
} else {
log.log(LogLevel.DEBUG, "Request failed. Req: " + request + "\nSpec: " + connection.getAddress() + ", error code: " + request.errorCode() + ", set error for connection and use another for next request");
connectionPool.setError(connection, request.errorCode());
return false;
}
}
use of com.yahoo.jrt.Request in project vespa by vespa-engine.
the class RpcInvokerTest method assertCorrectArguments.
protected void assertCorrectArguments(String argString) {
RpcInvoker invoker = new RpcInvoker();
List<String> args = toList(argString);
Request request = invoker.createRequest("testmethod", args);
for (int i = 0; i < args.size(); i++) {
// Strip type here if present
String arg = args.get(i);
if (arg.length() >= 1 && arg.charAt(1) == ':')
arg = arg.substring(2);
assertEquals(arg, request.parameters().get(i).toString());
}
}
Aggregations