Search in sources :

Example 1 with StatusPageResponse

use of com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse in project vespa by vespa-engine.

the class FleetController method fetchStatusPage.

public StatusPageResponse fetchStatusPage(StatusPageServer.HttpRequest httpRequest) {
    verifyInControllerThread();
    StatusPageResponse.ResponseCode responseCode;
    String message;
    String hiddenMessage = "";
    try {
        StatusPageServer.RequestHandler handler = statusRequestRouter.resolveHandler(httpRequest);
        if (handler == null) {
            throw new FileNotFoundException("No handler found for request: " + httpRequest.getPath());
        }
        return handler.handle(httpRequest);
    } catch (FileNotFoundException e) {
        responseCode = StatusPageResponse.ResponseCode.NOT_FOUND;
        message = e.getMessage();
    } catch (Exception e) {
        responseCode = StatusPageResponse.ResponseCode.INTERNAL_SERVER_ERROR;
        message = "Internal Server Error";
        hiddenMessage = ExceptionUtils.getStackTrace(e);
        log.log(LogLevel.DEBUG, "Unknown exception thrown for request " + httpRequest.getRequest() + ": " + hiddenMessage);
    }
    TimeZone tz = TimeZone.getTimeZone("UTC");
    long currentTime = timer.getCurrentTimeInMillis();
    StatusPageResponse response = new StatusPageResponse();
    StringBuilder content = new StringBuilder();
    response.setContentType("text/html");
    response.setResponseCode(responseCode);
    content.append("<!-- Answer to request " + httpRequest.getRequest() + " -->\n");
    content.append("<p>UTC time when creating this page: ").append(RealTimer.printDateNoMilliSeconds(currentTime, tz)).append("</p>");
    response.writeHtmlHeader(content, message);
    response.writeHtmlFooter(content, hiddenMessage);
    response.writeContent(content.toString());
    return response;
}
Also used : StatusPageServer(com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageServer) FileNotFoundException(java.io.FileNotFoundException) StatusPageResponse(com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse) ListenFailedException(com.yahoo.jrt.ListenFailedException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with StatusPageResponse

use of com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse in project vespa by vespa-engine.

the class StatusHandler method handleClusterRequest.

private HttpResult handleClusterRequest(String clusterName, String fleetControllerPath) throws InterruptedException {
    ContainerStatusPageServer statusServer = statusClusters.get(clusterName);
    if (statusServer == null) {
        return new HttpResult().setHttpCode(404, "No controller exists for cluster '" + clusterName + "'.");
    }
    if (fleetControllerPath == null || fleetControllerPath.isEmpty()) {
        fleetControllerPath = "/";
    }
    StatusPageServer.HttpRequest req = new StatusPageServer.HttpRequest(fleetControllerPath);
    req.setPathPrefix("/clustercontroller-status/v1");
    StatusPageResponse response = statusServer.getStatus(req);
    HttpResult result = new HttpResult();
    if (response.getResponseCode() != null) {
        result.setHttpCode(response.getResponseCode().getCode(), response.getResponseCode().getMessage());
    }
    if (response.getContentType() != null) {
        result.addHeader("Content-Type", response.getContentType());
    }
    result.setContent(new String(response.getOutputStream().toByteArray()));
    return result;
}
Also used : HttpRequest(com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest) StatusPageServer(com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageServer) HttpResult(com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult) StatusPageResponse(com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse)

Example 3 with StatusPageResponse

use of com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse in project vespa by vespa-engine.

the class NodeHealthRequestHandler method handle.

@Override
public StatusPageResponse handle(StatusPageServer.HttpRequest request) {
    StatusPageResponse response = new StatusPageResponse();
    StringBuilder content = new StringBuilder();
    response.setContentType("application/json");
    content.append("{\n" + "  \"status\" : {\n" + "    \"code\" : \"up\"\n" + "  },\n" + "  \"config\" : {\n" + "    \"component\" : {\n" + "      \"generation\" : " + data.getConfigGeneration() + "\n" + "    }\n" + "  }\n" + "}");
    response.writeContent(content.toString());
    return response;
}
Also used : StatusPageResponse(com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse)

Example 4 with StatusPageResponse

use of com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse 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 5 with StatusPageResponse

use of com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse in project vespa by vespa-engine.

the class LegacyIndexPageRequestHandler method handle.

@Override
public StatusPageResponse handle(StatusPageServer.HttpRequest request) {
    TimeZone tz = TimeZone.getTimeZone("UTC");
    long currentTime = timer.getCurrentTimeInMillis();
    StatusPageResponse response = new StatusPageResponse();
    response.setContentType("text/html");
    StringBuilder content = new StringBuilder();
    content.append("<!-- Answer to request " + request + " -->\n");
    response.writeHtmlHeader(content, cluster.getName() + " Cluster Controller " + data.getOptions().fleetControllerIndex + " Status Page");
    content.append("<p><font size=\"-1\">").append(" [ <a href=\"#config\">Current config</a>").append(" | <a href=\"#clusterstates\">Cluster states</a>").append(" | <a href=\"#eventlog\">Event log</a>").append(" ]</font></p>\n");
    content.append("<table><tr><td>UTC time when creating this page:</td><td align=\"right\">").append(RealTimer.printDateNoMilliSeconds(currentTime, tz)).append("</td></tr>");
    // content.append("<tr><td>Fleetcontroller version:</td><td align=\"right\">" + Vtag.V_TAG_PKG + "</td></tr/>");
    content.append("<tr><td>Cluster controller uptime:</td><td align=\"right\">" + RealTimer.printDuration(currentTime - startedTime) + "</td></tr></table>");
    // State of master election
    masterElectionHandler.writeHtmlState(content, data.getOptions().stateGatherCount);
    if (masterElectionHandler.isAmongNthFirst(data.getOptions().stateGatherCount)) {
        // Table overview of all the nodes
        cluster.writeHtmlState(new VdsClusterHtmlRendrer(), content, timer, stateVersionTracker.getVersionedClusterState(), stateVersionTracker.getAggregatedClusterStats(), data.getOptions().storageDistribution, data.getOptions(), eventLog);
        // Overview of current config
        data.getOptions().writeHtmlState(content, request);
        // Current cluster state and cluster state history
        writeHtmlState(stateVersionTracker, content, request);
    } else {
        // Overview of current config
        data.getOptions().writeHtmlState(content, request);
    }
    // Event log
    eventLog.writeHtmlState(content, null);
    response.writeHtmlFooter(content, "");
    response.writeContent(content.toString());
    return response;
}
Also used : VdsClusterHtmlRendrer(com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRendrer) StatusPageResponse(com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse)

Aggregations

StatusPageResponse (com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse)6 StatusPageServer (com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageServer)2 ListenFailedException (com.yahoo.jrt.ListenFailedException)1 ClusterState (com.yahoo.vdslib.state.ClusterState)1 Node (com.yahoo.vdslib.state.Node)1 NodeType (com.yahoo.vdslib.state.NodeType)1 VdsClusterHtmlRendrer (com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRendrer)1 HttpRequest (com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest)1 HttpResult (com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult)1 FileNotFoundException (java.io.FileNotFoundException)1 TimeZone (java.util.TimeZone)1 Matcher (java.util.regex.Matcher)1