Search in sources :

Example 11 with Target

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

the class RpcServerTest method testSetNodeStateOutOfRange.

@Test
public void testSetNodeStateOutOfRange() throws Exception {
    startingTest("RpcServerTest::testSetNodeStateOutOfRange");
    FleetControllerOptions options = new FleetControllerOptions("mycluster");
    options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(2, 10)));
    setUpFleetController(true, options);
    setUpVdsNodes(true, new DummyVdsNodeOptions());
    waitForStableSystem();
    int rpcPort = fleetController.getRpcPort();
    supervisor = new Supervisor(new Transport());
    Target connection = supervisor.connect(new Spec("localhost", rpcPort));
    assertTrue(connection.isValid());
    Request req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/storage/10"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
    assertEquals(req.toString(), "Cannot set wanted state of node storage.10. Index does not correspond to a configured node.", req.errorMessage());
    req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/distributor/10"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
    assertEquals(req.toString(), "Cannot set wanted state of node distributor.10. Index does not correspond to a configured node.", req.errorMessage());
    req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/storage/9"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    waitForState("version:\\d+ distributor:10 storage:10 .9.s:m");
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) Distribution(com.yahoo.vdslib.distribution.Distribution) Request(com.yahoo.jrt.Request) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue) Test(org.junit.Test)

Example 12 with Target

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

the class NodeStateGatherer method handleError.

private NodeState handleError(GetNodeStateRequest req, NodeInfo info, long currentTime) {
    String prefix = "Failed get node state request: ";
    NodeState newState = new NodeState(info.getNode().getType(), State.DOWN);
    if (req.getReply().getReturnCode() == ErrorCode.TIMEOUT) {
        String msg = "RPC timeout";
        if (info.getReportedState().getState().oneOf("ui")) {
            eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + "RPC timeout talking to node.", NodeEvent.Type.REPORTED, currentTime), LogLevel.INFO);
        } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
            log.log(LogLevel.DEBUG, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
        }
        newState.setDescription(msg);
    } else if (req.getReply().getReturnCode() == ErrorCode.CONNECTION) {
        Target target = info.lastRequestInfoConnection;
        Exception reason = (target == null ? null : target.getConnectionLostReason());
        if (reason != null) {
            String msg = reason.getMessage();
            if (msg == null)
                msg = "(null)";
            newState.setDescription(msg);
            if (msg.equals("Connection refused")) {
                msg = "Connection error: Connection refused";
                if (info.getReportedState().getState().oneOf("ui")) {
                    eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), LogLevel.INFO);
                } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                    log.log(LogLevel.DEBUG, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
                }
                newState.setState(State.DOWN);
            } else if (msg.equals("jrt: Connection closed by peer") || msg.equals("Connection reset by peer")) {
                msg = "Connection error: Closed at other end. (Node or switch likely shut down)";
                if (info.isRpcAddressOutdated()) {
                    msg += " Node is no longer in slobrok.";
                }
                if (info.getReportedState().getState().oneOf("ui")) {
                    eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), LogLevel.INFO);
                } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                    log.log(LogLevel.DEBUG, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
                }
                newState.setState(State.DOWN).setDescription(msg);
            } else if (msg.equals("Connection timed out")) {
                if (info.getReportedState().getState().oneOf("ui")) {
                    msg = "Connection error: Timeout";
                    eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), LogLevel.INFO);
                } else {
                    log.log(LogLevel.DEBUG, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
                }
            } else {
                msg = "Connection error: " + reason;
                if (info.getReportedState().getState().oneOf("ui")) {
                    eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), LogLevel.WARNING);
                } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                    log.log(LogLevel.DEBUG, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
                }
                newState.setDescription(msg);
            }
        } else {
            String msg = "Connection error: Unexpected error with no reason set. Assuming it is a network issue: " + req.getReply().getReturnCode() + ": " + req.getReply().getReturnMessage();
            if (info.getReportedState().getState().oneOf("ui")) {
                eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), LogLevel.WARNING);
            } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                log.log(LogLevel.DEBUG, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
            }
            newState.setDescription(msg);
        }
    } else if (req.getReply().getReturnCode() == Communicator.TRANSIENT_ERROR) {
        return null;
    } else if (req.getReply().getReturnCode() == ErrorCode.NO_SUCH_METHOD) {
        String msg = "no such RPC method error";
        if (info.getReportedState().getState().oneOf("ui")) {
            eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), LogLevel.WARNING);
        } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
            log.log(LogLevel.DEBUG, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
        }
        newState.setState(State.DOWN).setDescription(msg + ": get node state");
    } else if (req.getReply().getReturnCode() == 75004) {
        String msg = "Node refused to answer RPC request and is likely stopping: " + req.getReply().getReturnMessage();
        // The node is shutting down and is not accepting requests from anyone
        if (info.getReportedState().getState().equals(State.STOPPING)) {
            log.log(LogLevel.DEBUG, "Failed to get node state from " + info + " because it is still shutting down.");
        } else {
            if (info.getReportedState().getState().oneOf("ui")) {
                eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), LogLevel.INFO);
            } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
                log.log(LogLevel.DEBUG, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
            }
        }
        newState.setState(State.STOPPING).setDescription(msg);
    } else {
        String msg = "Got unexpected error, assumed to be node issue " + req.getReply().getReturnCode() + ": " + req.getReply().getReturnMessage();
        if (info.getReportedState().getState().oneOf("ui")) {
            eventLog.addNodeOnlyEvent(NodeEvent.forBaseline(info, prefix + msg, NodeEvent.Type.REPORTED, currentTime), LogLevel.WARNING);
        } else if (!info.getReportedState().hasDescription() || !info.getReportedState().getDescription().equals(msg)) {
            log.log(LogLevel.DEBUG, "Failed to talk to node " + info + ": " + req.getReply().getReturnCode() + " " + req.getReply().getReturnMessage() + ": " + msg);
        }
        newState.setState(State.DOWN).setDescription(msg);
    }
    return newState;
}
Also used : Target(com.yahoo.jrt.Target) NodeState(com.yahoo.vdslib.state.NodeState)

Example 13 with Target

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

the class RpcConfigSourceClient method checkConfigSources.

/**
 * Checks if config sources are available
 */
private void checkConfigSources() {
    if (configSourceSet == null || configSourceSet.getSources() == null || configSourceSet.getSources().size() == 0) {
        log.log(LogLevel.WARNING, "No config sources defined, could not check connection");
    } else {
        Request req = new Request("ping");
        for (String configSource : configSourceSet.getSources()) {
            Spec spec = new Spec(configSource);
            Target target = supervisor.connect(spec);
            target.invokeSync(req, 30.0);
            if (target.isValid()) {
                log.log(LogLevel.DEBUG, () -> "Created connection to config source at " + spec.toString());
                return;
            } else {
                log.log(LogLevel.INFO, "Could not connect to config source at " + spec.toString());
            }
            target.close();
        }
        String extra = "";
        log.log(LogLevel.INFO, "Could not connect to any config source in set " + configSourceSet.toString() + ", please make sure config server(s) are running. " + extra);
    }
}
Also used : Target(com.yahoo.jrt.Target) Request(com.yahoo.jrt.Request) JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest) Spec(com.yahoo.jrt.Spec)

Example 14 with Target

use of com.yahoo.jrt.Target 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 15 with Target

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

the class RpcTester method main.

public static void main(String[] args) {
    // String fileReference = args[0];
    String fileReference = "59f93f445438c9db7ccbf1629f583c2aa004a68b";
    String filename = "com.yahoo.vespatest.ExtraHitSearcher-1.0.0-deploy.jar";
    File file = new File(String.format("/tmp/%s/%s", fileReference, filename));
    byte[] blob = null;
    try {
        blob = IOUtils.readFileBytes(file);
    } catch (IOException e) {
        e.printStackTrace();
    }
    log.log(LogLevel.INFO, "Read blob from " + file.getAbsolutePath());
    Supervisor supervisor = new Supervisor(new Transport());
    Spec spec = new Spec("tcp/localhost:19090");
    log.log(LogLevel.INFO, "Connecting to " + spec);
    Target target = supervisor.connect(spec);
    if (!target.isValid()) {
        log.log(LogLevel.INFO, "Could not connect");
        System.exit(1);
    } else {
        log.log(LogLevel.INFO, "Connected to " + spec);
    }
    new RpcTester(target).call(fileReference, filename, blob);
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) IOException(java.io.IOException) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) File(java.io.File)

Aggregations

Target (com.yahoo.jrt.Target)15 Spec (com.yahoo.jrt.Spec)14 Request (com.yahoo.jrt.Request)13 Supervisor (com.yahoo.jrt.Supervisor)11 Transport (com.yahoo.jrt.Transport)11 StringValue (com.yahoo.jrt.StringValue)7 Test (org.junit.Test)7 NodeState (com.yahoo.vdslib.state.NodeState)5 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)4 Distribution (com.yahoo.vdslib.distribution.Distribution)3 Node (com.yahoo.vdslib.state.Node)3 ClusterState (com.yahoo.vdslib.state.ClusterState)2 TreeSet (java.util.TreeSet)2 Int32Value (com.yahoo.jrt.Int32Value)1 StringArray (com.yahoo.jrt.StringArray)1 WaitCondition (com.yahoo.vespa.clustercontroller.core.testutils.WaitCondition)1 JRTServerConfigRequest (com.yahoo.vespa.config.protocol.JRTServerConfigRequest)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1