Search in sources :

Example 31 with Request

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();
}
Also used : Target(com.yahoo.jrt.Target) StringArray(com.yahoo.jrt.StringArray) Request(com.yahoo.jrt.Request) Spec(com.yahoo.jrt.Spec)

Example 32 with Request

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);
}
Also used : Request(com.yahoo.jrt.Request) Level(java.util.logging.Level) LogLevel(com.yahoo.log.LogLevel)

Example 33 with 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);
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) Request(com.yahoo.jrt.Request) JRTServerConfigRequestV3(com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3) Test(org.junit.Test)

Example 34 with Request

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));
}
Also used : DataValue(com.yahoo.jrt.DataValue) Request(com.yahoo.jrt.Request) Int8Value(com.yahoo.jrt.Int8Value) Int32Value(com.yahoo.jrt.Int32Value)

Example 35 with Request

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);
}
Also used : Request(com.yahoo.jrt.Request) Level(java.util.logging.Level) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue)

Aggregations

Request (com.yahoo.jrt.Request)36 Test (org.junit.Test)18 Spec (com.yahoo.jrt.Spec)14 StringValue (com.yahoo.jrt.StringValue)14 Target (com.yahoo.jrt.Target)13 Supervisor (com.yahoo.jrt.Supervisor)10 Transport (com.yahoo.jrt.Transport)10 Int32Value (com.yahoo.jrt.Int32Value)6 NodeState (com.yahoo.vdslib.state.NodeState)5 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)4 Node (com.yahoo.vdslib.state.Node)4 DataValue (com.yahoo.jrt.DataValue)3 Int8Value (com.yahoo.jrt.Int8Value)3 Distribution (com.yahoo.vdslib.distribution.Distribution)3 StringArray (com.yahoo.jrt.StringArray)2 Values (com.yahoo.jrt.Values)2 ClusterState (com.yahoo.vdslib.state.ClusterState)2 RawConfig (com.yahoo.vespa.config.RawConfig)2 JRTServerConfigRequestV3 (com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3)2 ArrayList (java.util.ArrayList)2