Search in sources :

Example 1 with NodeType

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

the class SlobrokClient method getSlobrokData.

private Map<Node, SlobrokData> getSlobrokData(String pattern) {
    Map<Node, SlobrokData> result = new TreeMap<>();
    Mirror.Entry[] entries = mirror.lookup(pattern);
    log.log(LogLevel.SPAM, "Looking for slobrok entries with pattern '" + pattern + "'. Found " + entries.length + " entries.");
    for (Mirror.Entry entry : entries) {
        StringTokenizer st = new StringTokenizer(entry.getName(), "/");
        String addressType = st.nextToken();
        // skip
        String cluster = st.nextToken();
        NodeType nodeType = NodeType.get(st.nextToken());
        Integer nodeIndex = Integer.valueOf(st.nextToken());
        // skip
        String service = (st.hasMoreTokens() ? st.nextToken() : "");
        assert (addressType.equals("storage"));
        Node n = new Node(nodeType, nodeIndex);
        result.put(n, new SlobrokData(n, entry.getSpec()));
    }
    return result;
}
Also used : Node(com.yahoo.vdslib.state.Node) NodeType(com.yahoo.vdslib.state.NodeType) Mirror(com.yahoo.jrt.slobrok.api.Mirror)

Example 2 with NodeType

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

the class ClusterStateRequest method calculateResult.

@Override
public Response.ClusterResponse calculateResult(RemoteClusterControllerTask.Context context) throws StateRestApiException {
    Response.ClusterResponse result = new Response.ClusterResponse();
    result.addState("generated", new Response.UnitStateImpl(context.currentConsolidatedState.getClusterState()));
    for (NodeType type : NodeType.getTypes()) {
        Id.Service serviceId = new Id.Service(id, type);
        if (recursive > 0) {
            ServiceStateRequest ssr = new ServiceStateRequest(serviceId, recursive - 1);
            result.addEntry("service", type.toString(), ssr.calculateResult(context));
        } else {
            result.addLink("service", type.toString(), serviceId.toString());
        }
    }
    result.setPublishedState(bundleToDistributionState(context.publishedClusterStateBundle));
    return result;
}
Also used : Response(com.yahoo.vespa.clustercontroller.core.restapiv2.Response) NodeType(com.yahoo.vdslib.state.NodeType) Id(com.yahoo.vespa.clustercontroller.core.restapiv2.Id)

Example 3 with NodeType

use of com.yahoo.vdslib.state.NodeType 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 4 with NodeType

use of com.yahoo.vdslib.state.NodeType 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 5 with NodeType

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

the class StateChangeHandlerTest method startWithStableStateClusterWithNodesUp.

private void startWithStableStateClusterWithNodesUp() {
    for (NodeType type : NodeType.getTypes()) {
        for (ConfiguredNode i : configuredNodes) {
            NodeInfo nodeInfo = cluster.clusterInfo().setRpcAddress(new Node(type, i.index()), null);
            nodeInfo.markRpcAddressLive();
            nodeStateChangeHandler.handleNewReportedNodeState(currentClusterState(), nodeInfo, new NodeState(type, State.UP), null);
            nodeInfo.setReportedState(new NodeState(type, State.UP), clock.getCurrentTimeInMillis());
        }
    }
    for (NodeType type : NodeType.getTypes()) {
        for (ConfiguredNode i : configuredNodes) {
            Node n = new Node(type, i.index());
            assertEquals(State.UP, currentClusterState().getNodeState(n).getState());
        }
    }
    clock.advanceTime(config.stableStateTime);
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) NodeType(com.yahoo.vdslib.state.NodeType) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Node(com.yahoo.vdslib.state.Node)

Aggregations

NodeType (com.yahoo.vdslib.state.NodeType)6 Node (com.yahoo.vdslib.state.Node)5 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)2 NodeState (com.yahoo.vdslib.state.NodeState)2 Int32Value (com.yahoo.jrt.Int32Value)1 ListenFailedException (com.yahoo.jrt.ListenFailedException)1 Request (com.yahoo.jrt.Request)1 StringArray (com.yahoo.jrt.StringArray)1 StringValue (com.yahoo.jrt.StringValue)1 Mirror (com.yahoo.jrt.slobrok.api.Mirror)1 ClusterState (com.yahoo.vdslib.state.ClusterState)1 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)1 Id (com.yahoo.vespa.clustercontroller.core.restapiv2.Id)1 Response (com.yahoo.vespa.clustercontroller.core.restapiv2.Response)1 StatusPageResponse (com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 TimeZone (java.util.TimeZone)1