/** * Parses the give program type into {@link ProgramType} object. * * @param programType the program type to parse. * * @throws BadRequestException if the given program type is not a valid {@link ProgramType}. */ private ProgramType getProgramType(String programType) throws BadRequestException { try { return ProgramType.valueOfCategoryName(programType); } catch (Exception e) { throw new BadRequestException(String.format("Invalid program type '%s'", programType), e); } } }
/** * Parses the give program type into {@link ProgramType} object. * * @param programType the program type to parse. * * @throws BadRequestException if the given program type is not a valid {@link ProgramType}. */ private ProgramType getProgramType(String programType) throws BadRequestException { try { return ProgramType.valueOfCategoryName(programType); } catch (Exception e) { throw new BadRequestException(String.format("Invalid program type '%s'", programType), e); } } }
/** * Parses the give program type into {@link ProgramType} object. * * @param programType the program type to parse. * * @throws BadRequestException if the given program type is not a valid {@link ProgramType}. */ private ProgramType getProgramType(String programType) throws BadRequestException { try { return ProgramType.valueOfCategoryName(programType); } catch (Exception e) { throw new BadRequestException(String.format("Invalid program type '%s'", programType), e); } } }
/** * Parses the give program type into {@link ProgramType} object. * * @param programType the program type to parse. * * @throws BadRequestException if the given program type is not a valid {@link ProgramType}. */ private ProgramType getProgramType(String programType) throws BadRequestException { try { return ProgramType.valueOfCategoryName(programType); } catch (Exception e) { throw new BadRequestException(String.format("Invalid program type '%s'", programType), e); } } }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs/prev") public void prev(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) { LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType)); doPrev(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, null, format, suppress); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs/next") public void next(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) { LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType)); doNext(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, null, format, suppress); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs/next") public void next(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) { LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType)); doNext(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, null, format, suppress); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs") public void getLogs(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("start") @DefaultValue("-1") long fromTimeSecsParam, @QueryParam("stop") @DefaultValue("-1") long toTimeSecsParam, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) { LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType)); doGetLogs(responder, loggingContext, fromTimeSecsParam, toTimeSecsParam, escape, filterStr, null, format, suppress); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs/prev") public void prev(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) { LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType)); doPrev(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, null, format, suppress); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs") public void getLogs(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("start") @DefaultValue("-1") long fromTimeSecsParam, @QueryParam("stop") @DefaultValue("-1") long toTimeSecsParam, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) { LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType)); doGetLogs(responder, loggingContext, fromTimeSecsParam, toTimeSecsParam, escape, filterStr, null, format, suppress); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/datasets") public void getProgramDatasetUsage(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId) { ProgramType type = ProgramType.valueOfCategoryName(programType); final ProgramId id = new ProgramId(namespaceId, appId, type, programId); Set<DatasetId> ids = registry.getDatasets(id); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(ids)); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/datasets") public void getProgramDatasetUsage(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId) { ProgramType type = ProgramType.valueOfCategoryName(programType); final ProgramId id = new ProgramId(namespaceId, appId, type, programId); Set<DatasetId> ids = registry.getDatasets(id); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(ids)); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/streams") public void getProgramStreamUsage(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId) { ProgramType type = ProgramType.valueOfCategoryName(programType); final ProgramId id = new ProgramId(namespaceId, appId, type, programId); Set<StreamId> ids = registry.getStreams(id); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(ids)); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/runs/{run-id}/logs/next") public void runIdNext(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @PathParam("run-id") String runId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) throws NotFoundException { ProgramType type = ProgramType.valueOfCategoryName(programType); ProgramRunId programRunId = new ProgramRunId(namespaceId, appId, type, programId, runId); RunRecordMeta runRecord = getRunRecordMeta(programRunId); LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(programRunId, runRecord.getSystemArgs()); doNext(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, runRecord, format, suppress); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/runs/{run-id}/logs/prev") public void runIdPrev(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @PathParam("run-id") String runId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) throws NotFoundException { ProgramType type = ProgramType.valueOfCategoryName(programType); ProgramRunId programRunId = new ProgramRunId(namespaceId, appId, type, programId, runId); RunRecordMeta runRecord = getRunRecordMeta(programRunId); LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(programRunId, runRecord.getSystemArgs()); doPrev(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, runRecord, format, suppress); }
@GET @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/runs/{run-id}/logs") public void getRunIdLogs(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @PathParam("run-id") String runId, @QueryParam("start") @DefaultValue("-1") long fromTimeSecsParam, @QueryParam("stop") @DefaultValue("-1") long toTimeSecsParam, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) throws NotFoundException { ProgramType type = ProgramType.valueOfCategoryName(programType); ProgramRunId programRunId = new ProgramRunId(namespaceId, appId, type, programId, runId); RunRecordMeta runRecord = getRunRecordMeta(programRunId); LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(programRunId, runRecord.getSystemArgs()); doGetLogs(responder, loggingContext, fromTimeSecsParam, toTimeSecsParam, escape, filterStr, runRecord, format, suppress); }
@Override public ProgramId getElement(MDSKey.Splitter splitter) { return new ProgramId(splitter.getString(), splitter.getString(), ProgramType.valueOfCategoryName(splitter.getString()), splitter.getString()); } }
@Override public ProgramId getElement(MDSKey.Splitter splitter) { return new ProgramId(splitter.getString(), splitter.getString(), ProgramType.valueOfCategoryName(splitter.getString()), splitter.getString()); } }
private NamespacedEntityId toEntityId(MDSKey.Splitter splitter, char marker) { switch (marker) { case DATASET_MARKER: return new DatasetId(splitter.getString(), splitter.getString()); case PROGRAM_MARKER: return new ProgramId(splitter.getString(), splitter.getString(), ProgramType.valueOfCategoryName(splitter.getString()), splitter.getString()); default: throw new IllegalStateException("Invalid row with marker " + marker); } }
private NamespacedEntityId toEntityId(MDSKey.Splitter splitter, char marker) { switch (marker) { case DATASET_MARKER: return new DatasetId(splitter.getString(), splitter.getString()); case STREAM_MARKER: return new StreamId(splitter.getString(), splitter.getString()); case PROGRAM_MARKER: return new ProgramId(splitter.getString(), splitter.getString(), ProgramType.valueOfCategoryName(splitter.getString()), splitter.getString()); default: throw new IllegalStateException("Invalid row with marker " + marker); } }