use of co.cask.cdap.internal.app.store.RunRecordMeta in project cdap by caskdata.
the class LogHandler method runIdPrev.
@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);
RunRecordMeta runRecord = getRunRecordMeta(namespaceId, appId, type, programId, runId);
LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(namespaceId, appId, programId, type, runId, runRecord.getSystemArgs());
doPrev(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, runRecord, format, suppress);
}
use of co.cask.cdap.internal.app.store.RunRecordMeta in project cdap by caskdata.
the class LineageAdmin method getWorkflowProgramRunid.
@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;
}
use of co.cask.cdap.internal.app.store.RunRecordMeta in project cdap by caskdata.
the class LineageAdmin method doComputeRollupLineage.
private Multimap<RelationKey, Relation> doComputeRollupLineage(Multimap<RelationKey, Relation> relations) throws NotFoundException {
// Make a set of all ProgramIDs in the relations
Set<ProgramRunId> programRunIdSet = new HashSet<>();
for (Relation relation : Iterables.concat(relations.values())) {
programRunIdSet.add(new ProgramRunId(relation.getProgram().getNamespace(), relation.getProgram().getApplication(), relation.getProgram().getType(), relation.getProgram().getProgram(), relation.getRun().getId()));
}
// Get RunRecordMeta for all these ProgramRunIDs
final Map<ProgramRunId, RunRecordMeta> runRecordMap = store.getRuns(programRunIdSet);
// Get workflow Run IDs for all the programs in the relations
final Set<String> workflowIDs = getWorkflowIds(relations, runRecordMap);
// Get Program IDs for workflow Run IDs
// TODO: These scans could be expensive. CDAP-7571.
Map<ProgramRunId, RunRecordMeta> workflowRunRecordMap = store.getRuns(ProgramRunStatus.ALL, new Predicate<RunRecordMeta>() {
@Override
public boolean apply(RunRecordMeta input) {
return workflowIDs.contains(input.getPid());
}
});
// Create a map from RunId to ProgramId for all workflows
Map<String, ProgramRunId> workflowIdMap = new HashMap<>();
for (Map.Entry<ProgramRunId, RunRecordMeta> entry : workflowRunRecordMap.entrySet()) {
workflowIdMap.put(entry.getValue().getPid(), entry.getKey());
}
// For all relations, replace ProgramIds with workflow ProgramIds
return getRollupRelations(relations, runRecordMap, workflowIdMap);
}
use of co.cask.cdap.internal.app.store.RunRecordMeta in project cdap by caskdata.
the class PreviewHttpHandler method getPreviewLogs.
@GET
@Path("/previews/{preview-id}/logs")
public void getPreviewLogs(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("preview-id") String previewId, @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 Exception {
ProgramRunId runId = getProgramRunId(namespaceId, previewId);
RunRecordMeta runRecord = getRunRecord(namespaceId, previewId);
LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(namespaceId, previewId, runId.getProgram(), runId.getType(), runId.getRun(), runRecord.getSystemArgs());
doGetLogs(responder, loggingContext, fromTimeSecsParam, toTimeSecsParam, escape, filterStr, runRecord, format, suppress);
}
use of co.cask.cdap.internal.app.store.RunRecordMeta in project cdap by caskdata.
the class PreviewHttpHandler method getPreviewLogsNext.
@GET
@Path("/previews/{preview-id}/logs/next")
public void getPreviewLogsNext(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("preview-id") String previewId, @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 Exception {
ProgramRunId runId = getProgramRunId(namespaceId, previewId);
RunRecordMeta runRecord = getRunRecord(namespaceId, previewId);
LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(namespaceId, previewId, runId.getProgram(), runId.getType(), runId.getRun(), runRecord.getSystemArgs());
doNext(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, runRecord, format, suppress);
}
Aggregations