Search in sources :

Example 26 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class ClusterFixture method proposeDistributorWantedState.

public ClusterFixture proposeDistributorWantedState(final int index, State state) {
    final ClusterState stateBefore = rawGeneratedClusterState();
    final Node node = new Node(NodeType.DISTRIBUTOR, index);
    final NodeState nodeState = new NodeState(NodeType.DISTRIBUTOR, state);
    nodeState.setDescription("mockdesc");
    NodeInfo nodeInfo = cluster.getNodeInfo(node);
    nodeInfo.setWantedState(nodeState);
    nodeStateChangeHandler.proposeNewNodeState(stateBefore, nodeInfo, nodeState);
    return this;
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Node(com.yahoo.vdslib.state.Node)

Example 27 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class LegacyNodePageRequestHandler method handle.

@Override
public StatusPageResponse handle(StatusPageServer.HttpRequest request) {
    Matcher m = nodePattern.matcher(request.getPath());
    if (!m.matches()) {
        throw new IllegalStateException("Node request handler invoked but failed to match path");
    }
    TimeZone tz = TimeZone.getTimeZone("UTC");
    long currentTime = timer.getCurrentTimeInMillis();
    NodeType nodeType = NodeType.get(m.group(1));
    int index = Integer.valueOf(m.group(2));
    Node node = new Node(nodeType, index);
    StatusPageResponse response = new StatusPageResponse();
    response.setContentType("text/html");
    StringBuilder content = new StringBuilder();
    content.append("<!-- Answer to request " + request + " -->\n");
    response.writeHtmlHeader(content, "Cluster Controller Status Page - Node status for " + node);
    content.append("<p>UTC time when creating this page: ").append(RealTimer.printDateNoMilliSeconds(currentTime, tz)).append("</p>");
    content.append("[ <a href=\"..\">Back to cluster overview</a> ] <br><br>");
    eventLog.writeHtmlState(content, node);
    NodeInfo nodeInfo = cluster.getNodeInfo(node);
    content.append("<h2>Host info</h2>\n");
    if (nodeInfo.getHostInfo() != null) {
        content.append("<pre>\n").append(nodeInfo.getHostInfo().getRawCreationString()).append("\n</pre>\n");
    } else {
        content.append("Not retrieved\n");
    }
    response.writeHtmlFooter(content, "");
    response.writeContent(content.toString());
    return response;
}
Also used : TimeZone(java.util.TimeZone) Matcher(java.util.regex.Matcher) NodeType(com.yahoo.vdslib.state.NodeType) Node(com.yahoo.vdslib.state.Node) StatusPageResponse(com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse)

Example 28 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class EventDiffCalculator method emitPerNodeDiffEvents.

private static void emitPerNodeDiffEvents(final PerStateParams params, final List<Event> events) {
    final ContentCluster cluster = params.cluster;
    final ClusterState fromState = params.fromState.getClusterState();
    final ClusterState toState = params.toState.getClusterState();
    for (ConfiguredNode node : cluster.getConfiguredNodes().values()) {
        for (NodeType nodeType : NodeType.getTypes()) {
            final Node n = new Node(nodeType, node.index());
            emitSingleNodeEvents(params, events, cluster, fromState, toState, n);
        }
    }
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) NodeType(com.yahoo.vdslib.state.NodeType) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Node(com.yahoo.vdslib.state.Node)

Example 29 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class RpcServerTest method setWantedNodeState.

private void setWantedNodeState(State newState, NodeType nodeType, int nodeIndex) {
    int rpcPort = fleetController.getRpcPort();
    if (supervisor == null) {
        supervisor = new Supervisor(new Transport());
    }
    Target connection = supervisor.connect(new Spec("localhost", rpcPort));
    assertTrue(connection.isValid());
    Node node = new Node(nodeType, nodeIndex);
    NodeState newNodeState = new NodeState(nodeType, newState);
    Request req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/" + node.getType().toString() + "/" + node.getIndex()));
    req.parameters().add(new StringValue(newNodeState.serialize(true)));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("s"));
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Request(com.yahoo.jrt.Request) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue)

Example 30 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class StateVersionTrackerTest method per_node_min_bits_changes_are_not_considered_different.

// For similarity purposes, only the cluster-wide bits matter, not the individual node state
// min used bits. The former is derived from the latter, but the latter is not visible in the
// published state (but _is_ visible in the internal ClusterState structures).
@Test
public void per_node_min_bits_changes_are_not_considered_different() {
    final StateVersionTracker versionTracker = createWithMockedMetrics();
    final AnnotatedClusterState stateWithMinBits = stateWithoutAnnotations("distributor:2 storage:2");
    stateWithMinBits.getClusterState().setNodeState(new Node(NodeType.STORAGE, 0), new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(15));
    updateAndPromote(versionTracker, stateWithMinBits, 123);
    versionTracker.updateLatestCandidateStateBundle(stateBundleWithoutAnnotations("distributor:2 storage:2"));
    assertFalse(versionTracker.candidateChangedEnoughFromCurrentToWarrantPublish());
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node) Test(org.junit.Test)

Aggregations

Node (com.yahoo.vdslib.state.Node)65 Test (org.junit.Test)34 NodeState (com.yahoo.vdslib.state.NodeState)32 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)31 ClusterFixture.storageNode (com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode)15 HasStateReasonForNode.hasStateReasonForNode (com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode)15 ClusterState (com.yahoo.vdslib.state.ClusterState)9 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)6 NodeType (com.yahoo.vdslib.state.NodeType)5 PrintWriter (java.io.PrintWriter)5 StringWriter (java.io.StringWriter)5 Request (com.yahoo.jrt.Request)4 State (com.yahoo.vdslib.state.State)4 IOException (java.io.IOException)4 Spec (com.yahoo.jrt.Spec)3 StringValue (com.yahoo.jrt.StringValue)3 Supervisor (com.yahoo.jrt.Supervisor)3 Target (com.yahoo.jrt.Target)3 Transport (com.yahoo.jrt.Transport)3 TreeMap (java.util.TreeMap)3