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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations