use of com.yahoo.jrt.Request in project vespa by vespa-engine.
the class FileDistributionImpl method startDownloadingFileReferences.
// Notifies config proxy which file references it should start downloading. It's OK if the call does not succeed,
// as downloading will then start synchronously when a service requests a file reference instead
private void startDownloadingFileReferences(String hostName, int port, Set<FileReference> fileReferences) {
Target target = supervisor.connect(new Spec(hostName, port));
double timeout = 0.1;
Request request = new Request("filedistribution.setFileReferencesToDownload");
request.parameters().add(new StringArray(fileReferences.stream().map(FileReference::value).toArray(String[]::new)));
log.log(LogLevel.DEBUG, "Executing " + request.methodName() + " against " + target.toString());
target.invokeSync(request, timeout);
if (request.isError() && request.errorCode() != ErrorCode.CONNECTION) {
log.log(LogLevel.DEBUG, request.methodName() + " failed: " + request.errorCode() + " (" + request.errorMessage() + ")");
}
target.close();
}
use of com.yahoo.jrt.Request in project vespa by vespa-engine.
the class GetConfigProcessor method respond.
private void respond(JRTServerConfigRequest request) {
final Request req = request.getRequest();
if (req.isError()) {
Level logLevel = (req.errorCode() == ErrorCode.APPLICATION_NOT_LOADED) ? LogLevel.DEBUG : LogLevel.INFO;
log.log(logLevel, logPre + req.errorMessage());
}
rpcServer.respond(request);
}
use of com.yahoo.jrt.Request in project vespa by vespa-engine.
the class SuperModelControllerTest method test_unknown_config_definition.
@Test(expected = UnknownConfigDefinitionException.class)
public void test_unknown_config_definition() {
String md5 = "asdfasf";
Request request = JRTClientConfigRequestV3.createWithParams(new ConfigKey<>("foo", "id", "bar", md5, null), DefContent.fromList(Collections.emptyList()), "fromHost", md5, 1, 1, Trace.createDummy(), CompressionType.UNCOMPRESSED, Optional.empty()).getRequest();
JRTServerConfigRequestV3 v3Request = JRTServerConfigRequestV3.createFromRequest(request);
handler.resolveConfig(v3Request);
}
use of com.yahoo.jrt.Request 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));
}
use of com.yahoo.jrt.Request in project vespa by vespa-engine.
the class Register method handleUpdate.
/**
* Invoked by the update task.
*/
private void handleUpdate() {
if (reqDone) {
reqDone = false;
boolean logOnSuccess = false;
synchronized (this) {
if (req.methodName().equals(UNREGISTER_METHOD_NAME)) {
logOnSuccess = true;
// Why is this remove() here and not in unregisterName? Because at that time there may be
// an in-flight request for the registration of name, and in case handleUpdate() would
// anyway have to have special code for handling a removed name, e.g. testing for name
// being in names which is O(N).
lastRegisterSucceeded.remove(name);
} else {
final Boolean lastSucceeded = lastRegisterSucceeded.get(name);
if (lastSucceeded == null || lastSucceeded != !req.isError()) {
logOnSuccess = true;
lastRegisterSucceeded.put(name, !req.isError());
}
}
}
if (req.isError()) {
if (req.errorCode() != ErrorCode.METHOD_FAILED) {
log.log(Level.INFO, logMessagePrefix() + " failed, will disconnect: " + req.errorMessage() + " (code " + req.errorCode() + ")");
target.close();
target = null;
} else {
log.log(Level.WARNING, logMessagePrefix() + " failed: " + req.errorMessage());
}
} else {
log.log(logOnSuccess ? Level.INFO : Level.FINE, logMessagePrefix() + " completed successfully");
backOff.reset();
}
req = null;
name = null;
}
if (req != null) {
log.log(Level.FINEST, "req in progress");
// current request still in progress
return;
}
if (target != null && !slobroks.contains(currSlobrok)) {
log.log(Level.INFO, "RPC server " + mySpec + ": Slobrok server " + currSlobrok + " removed, will disconnect");
target.close();
target = null;
}
if (target == null) {
currSlobrok = slobroks.nextSlobrokSpec();
if (currSlobrok == null) {
double delay = backOff.get();
Level level = backOff.shouldWarn(delay) ? Level.WARNING : Level.FINE;
log.log(level, "RPC server " + mySpec + ": All Slobrok servers tried, will retry in " + delay + " seconds: " + slobroks);
updateTask.schedule(delay);
return;
}
lastRegisterSucceeded.clear();
target = orb.connect(new Spec(currSlobrok));
String namesString = null;
final boolean logFine = log.isLoggable(Level.FINE);
synchronized (this) {
if (logFine) {
// 'names' must only be accessed in a synchronized(this) block
namesString = names.toString();
}
pending.clear();
pending.addAll(names);
}
if (logFine) {
log.log(Level.FINE, "RPC server " + mySpec + ": Connect to Slobrok server " + currSlobrok + " and reregister all Slobrok names: " + namesString);
}
}
synchronized (this) {
if (unreg.size() > 0) {
name = unreg.remove(unreg.size() - 1);
req = new Request(UNREGISTER_METHOD_NAME);
} else if (pending.size() > 0) {
name = pending.remove(pending.size() - 1);
req = new Request(REGISTER_METHOD_NAME);
} else {
pending.addAll(names);
log.log(Level.FINE, "RPC server " + mySpec + ": Reregister all Slobrok names in 30 seconds: " + names);
updateTask.schedule(30.0);
return;
}
}
req.parameters().add(new StringValue(name));
req.parameters().add(new StringValue(mySpec));
log.log(Level.FINE, logMessagePrefix() + " now");
target.invokeAsync(req, 35.0, reqWait);
}
Aggregations