public static IHttpCredentialsPlugin getHttpCredentialsPlugin(Map<String, Object> conf, String klassName) { try { IHttpCredentialsPlugin plugin = null; if (StringUtils.isNotBlank(klassName)) { plugin = ReflectionUtils.newInstance(klassName); plugin.prepare(conf); } return plugin; } catch (Exception e) { throw new RuntimeException(e); } }
/** * Handles '/searchLogs' request. */ @GET @Path("/searchLogs") public Response searchLogs(@Context HttpServletRequest request) throws IOException { String user = httpCredsHandler.getUserName(request); String topologyId = request.getParameter("topoId"); String portStr = request.getParameter("port"); String callback = request.getParameter("callbackParameterName"); String origin = request.getHeader("Origin"); return logviewer.listLogFiles(user, portStr != null ? Integer.parseInt(portStr) : null, topologyId, callback, origin); }
/** * Populate the Storm RequestContext from an servlet request. This should be called in each handler * @param request the request to populate */ public void populateContext(HttpServletRequest request) { if (httpCredsHandler != null) { httpCredsHandler.populateContext(ReqContext.context(), request); } }
/** * Handles '/dumps' (listing dump files) request. */ @GET @Path("/dumps/{topo-id}/{host-port}") public Response listDumpFiles(@PathParam("topo-id") String topologyId, @PathParam("host-port") String hostPort, @Context HttpServletRequest request) throws IOException { String user = httpCredsHandler.getUserName(request); try { return profileHandler.listDumpFiles(topologyId, hostPort, user); } catch (IOException e) { numListDumpExceptions.mark(); throw e; } }
private static IHttpCredentialsPlugin GetHttpCredentialsPlugin(Map conf, String klassName) { IHttpCredentialsPlugin plugin; try { Class klass = Class.forName(klassName); plugin = (IHttpCredentialsPlugin)klass.newInstance(); plugin.prepare(conf); } catch(Exception e) { throw new RuntimeException(e); } return plugin; }
/** * Handles '/dumps' (downloading specific dump file) request. */ @GET @Path("/dumps/{topo-id}/{host-port}/{filename}") public Response downloadDumpFile(@PathParam("topo-id") String topologyId, @PathParam("host-port") String hostPort, @PathParam("filename") String fileName, @Context HttpServletRequest request) throws IOException { String user = httpCredsHandler.getUserName(request); try { return profileHandler.downloadDumpFile(topologyId, hostPort, fileName, user); } catch (IOException e) { numDownloadDumpExceptions.mark(); throw e; } }
/** * Handles '/download' (downloading specific log file) request. */ @GET @Path("/download") public Response downloadLogFile(@Context HttpServletRequest request) throws IOException { meterDownloadLogFileHttpRequests.mark(); String user = httpCredsHandler.getUserName(request); String file = request.getParameter("file"); String decodedFileName = URLDecoder.decode(file); try { return logDownloadHandler.downloadLogFile(decodedFileName, user); } catch (IOException e) { numDownloadLogExceptions.mark(); throw e; } }
/** * Handles '/daemondownload' (downloading specific daemon log file) request. */ @GET @Path("/daemondownload") public Response downloadDaemonLogFile(@Context HttpServletRequest request) throws IOException { meterDownloadLogDaemonFileHttpRequests.mark(); String user = httpCredsHandler.getUserName(request); String file = request.getParameter("file"); String decodedFileName = URLDecoder.decode(file); try { return logDownloadHandler.downloadDaemonLogFile(decodedFileName, user); } catch (IOException e) { numDownloadDaemonLogExceptions.mark(); throw e; } }
/** * Handles '/listLogs' request. */ @GET @Path("/listLogs") public Response listLogs(@Context HttpServletRequest request) throws IOException { meterListLogsHttpRequests.mark(); String user = httpCredsHandler.getUserName(request); String topologyId = request.getParameter("topoId"); String portStr = request.getParameter("port"); String callback = request.getParameter(StormApiResource.callbackParameterName); String origin = request.getHeader("Origin"); try { return logviewer.listLogFiles(user, portStr != null ? Integer.parseInt(portStr) : null, topologyId, callback, origin); } catch (IOException e) { numListLogExceptions.mark(); throw e; } }
/** * Handles '/deepSearch' request. */ @GET @Path("/deepSearch/{topoId}") public Response deepSearch(@PathParam("topoId") String topologyId, @Context HttpServletRequest request) { String user = httpCredsHandler.getUserName(request); String searchString = request.getParameter("search-string"); String numMatchesStr = request.getParameter("num-matches"); String portStr = request.getParameter("port"); String startFileOffset = request.getParameter("start-file-offset"); String startByteOffset = request.getParameter("start-byte-offset"); String searchArchived = request.getParameter("search-archived"); String callback = request.getParameter(StormApiResource.callbackParameterName); String origin = request.getHeader("Origin"); Boolean alsoSearchArchived = BooleanUtils.toBooleanObject(searchArchived); if (BooleanUtils.isTrue(alsoSearchArchived)) { numDeepSearchArchived.mark(); } else { numDeepSearchNonArchived.mark(); } try (Timer.Context t = deepSearchRequestDuration.time()) { return logSearchHandler.deepSearchLogsForTopology(topologyId, user, searchString, numMatchesStr, portStr, startFileOffset, startByteOffset, alsoSearchArchived, callback, origin); } }
/** * Handles '/daemonlog' request. */ @GET @Path("/daemonlog") public Response daemonLog(@Context HttpServletRequest request) throws IOException { meterDaemonLogPageHttpRequests.mark(); try { String user = httpCredsHandler.getUserName(request); Integer start = request.getParameter("start") != null ? parseIntegerFromMap(request.getParameterMap(), "start") : null; Integer length = request.getParameter("length") != null ? parseIntegerFromMap(request.getParameterMap(), "length") : null; String decodedFileName = URLDecoder.decode(request.getParameter("file")); String grep = request.getParameter("grep"); return logviewer.daemonLogPage(decodedFileName, start, length, grep, user); } catch (InvalidRequestException e) { LOG.error(e.getMessage(), e); return Response.status(400).entity(e.getMessage()).build(); } catch (IOException e) { numReadDaemonLogExceptions.mark(); throw e; } }
/** * Handles '/log' request. */ @GET @Path("/log") public Response log(@Context HttpServletRequest request) throws IOException { meterLogPageHttpRequests.mark(); try { String user = httpCredsHandler.getUserName(request); Integer start = request.getParameter("start") != null ? parseIntegerFromMap(request.getParameterMap(), "start") : null; Integer length = request.getParameter("length") != null ? parseIntegerFromMap(request.getParameterMap(), "length") : null; String decodedFileName = URLDecoder.decode(request.getParameter("file")); String grep = request.getParameter("grep"); return logviewer.logPage(decodedFileName, start, length, grep, user); } catch (InvalidRequestException e) { LOG.error(e.getMessage(), e); return Response.status(400).entity(e.getMessage()).build(); } catch (IOException e) { numReadLogExceptions.mark(); throw e; } }
/** * Handles '/search' (searching from specific worker or daemon log file) request. */ @GET @Path("/search") public Response search(@Context HttpServletRequest request) throws IOException { numSearchLogRequests.mark(); String user = httpCredsHandler.getUserName(request); boolean isDaemon = StringUtils.equals(request.getParameter("is-daemon"), "yes"); String file = request.getParameter("file"); String decodedFileName = URLDecoder.decode(file); String searchString = request.getParameter("search-string"); String numMatchesStr = request.getParameter("num-matches"); String startByteOffset = request.getParameter("start-byte-offset"); String callback = request.getParameter(StormApiResource.callbackParameterName); String origin = request.getHeader("Origin"); try (Timer.Context t = searchLogRequestDuration.time()) { return logSearchHandler.searchLogFile(decodedFileName, user, isDaemon, searchString, numMatchesStr, startByteOffset, callback, origin); } catch (InvalidRequestException e) { LOG.error(e.getMessage(), e); int statusCode = 400; return new JsonResponseBuilder().setData(UIHelpers.exceptionToJson(e, statusCode)).setCallback(callback) .setStatus(statusCode).build(); } catch (IOException e) { numSearchExceptions.mark(); throw e; } }