Search in sources :

Example 16 with RunRecordMeta

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);
}
Also used : LoggingContext(co.cask.cdap.common.logging.LoggingContext) RunRecordMeta(co.cask.cdap.internal.app.store.RunRecordMeta) ProgramType(co.cask.cdap.proto.ProgramType) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 17 with RunRecordMeta

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;
}
Also used : RunRecordMeta(co.cask.cdap.internal.app.store.RunRecordMeta) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) Nullable(javax.annotation.Nullable)

Example 18 with RunRecordMeta

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);
}
Also used : HashMap(java.util.HashMap) RunRecordMeta(co.cask.cdap.internal.app.store.RunRecordMeta) Relation(co.cask.cdap.data2.metadata.lineage.Relation) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 19 with RunRecordMeta

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);
}
Also used : LoggingContext(co.cask.cdap.common.logging.LoggingContext) RunRecordMeta(co.cask.cdap.internal.app.store.RunRecordMeta) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 20 with RunRecordMeta

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);
}
Also used : LoggingContext(co.cask.cdap.common.logging.LoggingContext) RunRecordMeta(co.cask.cdap.internal.app.store.RunRecordMeta) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

RunRecordMeta (co.cask.cdap.internal.app.store.RunRecordMeta)25 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)11 ProgramId (co.cask.cdap.proto.id.ProgramId)9 GET (javax.ws.rs.GET)8 Path (javax.ws.rs.Path)8 LoggingContext (co.cask.cdap.common.logging.LoggingContext)6 RuntimeInfo (co.cask.cdap.app.runtime.ProgramRuntimeService.RuntimeInfo)4 NotFoundException (co.cask.cdap.common.NotFoundException)4 ProgramType (co.cask.cdap.proto.ProgramType)4 MDSKey (co.cask.cdap.data2.dataset2.lib.table.MDSKey)3 RunId (org.apache.twill.api.RunId)3 Test (org.junit.Test)3 NamespaceNotFoundException (co.cask.cdap.common.NamespaceNotFoundException)2 Relation (co.cask.cdap.data2.metadata.lineage.Relation)2 SimpleRuntimeInfo (co.cask.cdap.internal.app.runtime.service.SimpleRuntimeInfo)2 RunRecord (co.cask.cdap.proto.RunRecord)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Nullable (javax.annotation.Nullable)2 TwillController (org.apache.twill.api.TwillController)2