@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/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); }
@Override public ProgramRunId toEntityId() { return new ProgramRunId(program.getNamespaceId(), program.getApplicationId(), program.getType(), program.getId(), id); }
@Override public ProgramRunId toEntityId() { return new ProgramRunId(program.getNamespaceId(), program.getApplicationId(), program.getType(), program.getId(), id); }
private Set<String> getWorkflowIds (Multimap<RelationKey, Relation> relations, Map<ProgramRunId, RunRecordMeta> runRecordMap) throws NotFoundException { final Set<String> workflowIDs = new HashSet<>(); for (Relation relation : Iterables.concat(relations.values())) { RunRecordMeta runRecord = runRecordMap.get( new ProgramRunId(relation.getProgram().getNamespace(), relation.getProgram().getApplication(), relation.getProgram().getType(), relation.getProgram().getProgram(), relation.getRun().getId())); if (runRecord != null && runRecord.getProperties().containsKey("workflowrunid")) { String workflowRunId = runRecord.getProperties().get("workflowrunid"); workflowIDs.add(workflowRunId); } } return workflowIDs; }
private Set<String> getWorkflowIds (Multimap<RelationKey, Relation> relations, Map<ProgramRunId, RunRecordMeta> runRecordMap) throws NotFoundException { final Set<String> workflowIDs = new HashSet<>(); for (Relation relation : Iterables.concat(relations.values())) { RunRecordMeta runRecord = runRecordMap.get( new ProgramRunId(relation.getProgram().getNamespace(), relation.getProgram().getApplication(), relation.getProgram().getType(), relation.getProgram().getProgram(), relation.getRun().getId())); if (runRecord != null && runRecord.getProperties().containsKey("workflowrunid")) { String workflowRunId = runRecord.getProperties().get("workflowrunid"); workflowIDs.add(workflowRunId); } } return workflowIDs; }
@Nullable private ProgramRunId getWorkflowProgramRunid (Relation relation, Map<ProgramRunId, RunRecordMeta> runRecordMap, Map<String, ProgramRunId> workflowIdMap) { ProgramRunId workflowProgramRunId = null; RunRecordMeta runRecord = runRecordMap.get( new ProgramRunId(relation.getProgram().getNamespace(), relation.getProgram().getApplication(), relation.getProgram().getType(), relation.getProgram().getProgram(), relation.getRun().getId())); if (runRecord != null && runRecord.getProperties().containsKey("workflowrunid")) { String workflowRunId = runRecord.getProperties().get("workflowrunid"); workflowProgramRunId = workflowIdMap.get(workflowRunId); } return workflowProgramRunId; }
@Override public void perform(Arguments arguments, PrintStream printStream) throws Exception { String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\."); if (programIdParts.length < 2) { throw new CommandInputError(this); } ProgramRunId programRunId = new ProgramRunId(cliConfig.getCurrentNamespace().getNamespace(), programIdParts[0], ProgramType.WORKFLOW, programIdParts[1], arguments.get(ArgumentName.RUN_ID.toString())); workflowClient.deleteWorkflowLocalDatasets(programRunId); printStream.printf("Successfully deleted local datasets associated with the workflow run."); }
@Override public void perform(Arguments arguments, PrintStream printStream) throws Exception { String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\."); if (programIdParts.length < 2) { throw new CommandInputError(this); } ProgramRunId programRunId = new ProgramRunId(cliConfig.getCurrentNamespace().getNamespace(), programIdParts[0], ProgramType.WORKFLOW, programIdParts[1], arguments.get(ArgumentName.RUN_ID.toString())); workflowClient.deleteWorkflowLocalDatasets(programRunId); printStream.printf("Successfully deleted local datasets associated with the workflow run."); }
/** * Creates a {@link ProgramRunId} of this program id with the given run id. */ public ProgramRunId run(String run) { return new ProgramRunId(new ApplicationId(getNamespace(), getApplication(), getVersion()), type, program, run); }
@Nullable private ProgramRunId getWorkflowProgramRunid (Relation relation, Map<ProgramRunId, RunRecordMeta> runRecordMap, Map<String, ProgramRunId> workflowIdMap) { ProgramRunId workflowProgramRunId = null; RunRecordMeta runRecord = runRecordMap.get( new ProgramRunId(relation.getProgram().getNamespace(), relation.getProgram().getApplication(), relation.getProgram().getType(), relation.getProgram().getProgram(), relation.getRun().getId())); if (runRecord != null && runRecord.getProperties().containsKey("workflowrunid")) { String workflowRunId = runRecord.getProperties().get("workflowrunid"); workflowProgramRunId = workflowIdMap.get(workflowRunId); } return workflowProgramRunId; }
@Override public Map<String, WorkflowNodeStateDetail> getWorkflowNodeStates(String workflowRunId) throws NotFoundException { return appFabricClient.getWorkflowNodeStates( new ProgramRunId(programId.getNamespaceId(), programId.getApplicationId(), programId.getType(), programId.getId(), workflowRunId)); }
@Override public Map<String, WorkflowNodeStateDetail> getWorkflowNodeStates(String workflowRunId) throws NotFoundException { return appFabricClient.getWorkflowNodeStates( new ProgramRunId(programId.getNamespaceId(), programId.getApplicationId(), programId.getType(), programId.getId(), workflowRunId)); }
/** * Creates a {@link ProgramRunId} of this program id with the given run id. */ public ProgramRunId run(String run) { return new ProgramRunId(new ApplicationId(getNamespace(), getApplication(), getVersion()), type, program, run); }
@SuppressWarnings("unused") public static ProgramRunId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ProgramRunId( new ApplicationId(next(iterator, "namespace"), next(iterator, "application"), next(iterator, "version")), ProgramType.valueOfPrettyName(next(iterator, "type")), next(iterator, "program"), nextAndEnd(iterator, "run")); }
@SuppressWarnings("unused") public static ProgramRunId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ProgramRunId( new ApplicationId(next(iterator, "namespace"), next(iterator, "application"), next(iterator, "version")), ProgramType.valueOfPrettyName(next(iterator, "type")), next(iterator, "program"), nextAndEnd(iterator, "run")); }
/** * Deserialize and return {@link ProgramRunId} from rowKey */ private ProgramRunId getProgramRunIdFromRowKey(byte[] rowKey) { MDSKey.Splitter splitter = new MDSKey(rowKey).split(); // get namespace String namespace = splitter.getString(); // skip timestamp splitter.skipLong(); // now read the programRunId fields, create and return ProgramRunId return new ProgramRunId(namespace, splitter.getString(), ProgramType.valueOf(splitter.getString()), splitter.getString(), splitter.getString()); } }
/** * Deserialize and return {@link ProgramRunId} from rowKey */ private ProgramRunId getProgramRunIdFromRowKey(byte[] rowKey) { MDSKey.Splitter splitter = new MDSKey(rowKey).split(); // get namespace String namespace = splitter.getString(); // skip timestamp splitter.skipLong(); // now read the programRunId fields, create and return ProgramRunId return new ProgramRunId(namespace, splitter.getString(), ProgramType.valueOf(splitter.getString()), splitter.getString(), splitter.getString()); } }
/** * Parses the {@link ProgramRunId} from the {@link MDSKey}. */ private ProgramRunId getProgramRunId(MDSKey key) { MDSKey.Splitter st = key.split(); st.skipString(); // Skip prefix return new ProgramRunId(new ApplicationId(st.getString(), st.getString(), st.getString()), ProgramType.valueOf(st.getString()), st.getString(), st.getString()); } }
/** * Parses the {@link ProgramRunId} from the {@link MDSKey}. */ private ProgramRunId getProgramRunId(MDSKey key) { MDSKey.Splitter st = key.split(); st.skipString(); // Skip prefix return new ProgramRunId(new ApplicationId(st.getString(), st.getString(), st.getString()), ProgramType.valueOf(st.getString()), st.getString(), st.getString()); } }