private void preSlurpFile() { try { if (!statusFile.exists()) { fileNotFound(); return; } if (!statusFile.canRead()) { accessDenied(); return; } } catch (SecurityException e) { internalError(); return; } this.file = statusFile; }
@Override public void render(OutputStream stream) throws IOException { if (file != null) { readAndWrite(stream); } else if (data != null) { stream.write(data); } else { throw new IllegalStateException( "Neither file nor hardcoded data. This is a bug, please notify the Vespa team."); } stream.close(); }
@Override public HttpResponse handle(HttpRequest request) { if (metric != null) metric.add(NUM_REQUESTS_METRIC, 1, null); if (vipStatus != null) updateAndLogRotationState(); return new StatusResponse(); }
/** * Behaves like a VIP status response file has been deleted. */ private void searchContainerOutOfService() { contentType = "text/plain"; data = Utf8.toBytes(NO_SEARCH_BACKENDS); setStatus(com.yahoo.jdisc.http.HttpResponse.Status.NOT_FOUND); }
private void fileNotFound() { contentType = "text/plain"; data = Utf8.toBytes(COULD_NOT_FIND_STATUS_FILE); setStatus(com.yahoo.jdisc.http.HttpResponse.Status.NOT_FOUND); }
private void internalError() { contentType = "text/plain"; data = Utf8.toBytes("Internal error while fetching status file.\n"); setStatus(com.yahoo.jdisc.http.HttpResponse.Status.NOT_FOUND); }
private StatusResponse() { super(com.yahoo.jdisc.http.HttpResponse.Status.OK); // status may be overwritten below if (vipStatus != null && ! vipStatus.isInRotation()) { searchContainerOutOfService(); } else if (accessDisk) { preSlurpFile(); } else { vipRespond(); } }
private void accessDenied() { contentType = "text/plain"; data = Utf8.toBytes("Status file inaccessible.\n"); setStatus(com.yahoo.jdisc.http.HttpResponse.Status.NOT_FOUND); }