Search in sources :

Example 46 with ProgramRunId

use of co.cask.cdap.proto.id.ProgramRunId 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 47 with ProgramRunId

use of co.cask.cdap.proto.id.ProgramRunId 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)

Example 48 with ProgramRunId

use of co.cask.cdap.proto.id.ProgramRunId in project cdap by caskdata.

the class WorkflowHttpHandler method getWorkflowSpecForValidRun.

/**
   * Get the {@link WorkflowSpecification} if valid application id, workflow id, and runid are provided.
   * @param namespaceId the namespace id
   * @param applicationId the application id
   * @param workflowId the workflow id
   * @param runId the runid of the workflow
   * @return the specifications for the Workflow
   * @throws NotFoundException is thrown when the application, workflow, or runid is not found
   */
private WorkflowSpecification getWorkflowSpecForValidRun(String namespaceId, String applicationId, String workflowId, String runId) throws NotFoundException {
    ApplicationId appId = new ApplicationId(namespaceId, applicationId);
    ApplicationSpecification appSpec = store.getApplication(appId);
    if (appSpec == null) {
        throw new ApplicationNotFoundException(appId);
    }
    WorkflowSpecification workflowSpec = appSpec.getWorkflows().get(workflowId);
    ProgramId programId = new ProgramId(namespaceId, applicationId, ProgramType.WORKFLOW, workflowId);
    if (workflowSpec == null) {
        throw new ProgramNotFoundException(programId);
    }
    if (store.getRun(programId, runId) == null) {
        throw new NotFoundException(new ProgramRunId(programId.getNamespace(), programId.getApplication(), programId.getType(), programId.getProgram(), runId));
    }
    return workflowSpec;
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) ApplicationNotFoundException(co.cask.cdap.common.ApplicationNotFoundException) WorkflowSpecification(co.cask.cdap.api.workflow.WorkflowSpecification) ProgramNotFoundException(co.cask.cdap.common.ProgramNotFoundException) ApplicationNotFoundException(co.cask.cdap.common.ApplicationNotFoundException) InstanceNotFoundException(co.cask.cdap.api.dataset.InstanceNotFoundException) NotFoundException(co.cask.cdap.common.NotFoundException) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) ApplicationId(co.cask.cdap.proto.id.ApplicationId) ProgramId(co.cask.cdap.proto.id.ProgramId) ProgramNotFoundException(co.cask.cdap.common.ProgramNotFoundException)

Example 49 with ProgramRunId

use of co.cask.cdap.proto.id.ProgramRunId in project cdap by caskdata.

the class LineageHandler method getAccessesForRun.

@GET
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/runs/{run-id}/metadata")
public void getAccessesForRun(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) throws Exception {
    ProgramRunId run = new ProgramRunId(namespaceId, appId, ProgramType.valueOfCategoryName(programType), programId, runId);
    responder.sendJson(HttpResponseStatus.OK, lineageAdmin.getMetadataForRun(run), SET_METADATA_RECORD_TYPE, GSON);
}
Also used : ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 50 with ProgramRunId

use of co.cask.cdap.proto.id.ProgramRunId in project cdap by caskdata.

the class LineageWriterDatasetFramework method doWriteLineage.

private void doWriteLineage(DatasetId datasetInstanceId, AccessType accessType) {
    ProgramContext programContext = this.programContext;
    if (programContext != null) {
        ProgramRunId programRunId = programContext.getProgramRunId();
        NamespacedEntityId componentId = programContext.getComponentId();
        try {
            lineageWriter.addAccess(programRunId, datasetInstanceId, accessType, componentId);
        } catch (Throwable t) {
            // Failure to write to lineage shouldn't cause dataset operation failure
            LOG.warn("Failed to write lineage information for dataset {} with access type {} from {},{}", datasetInstanceId, accessType, programRunId, componentId);
            // Log the stacktrace as debug to not polluting the log
            LOG.debug("Cause for lineage writing failure for {} {} {} {}", datasetInstanceId, accessType, programRunId, componentId, t);
        }
    }
}
Also used : NamespacedEntityId(co.cask.cdap.proto.id.NamespacedEntityId) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) ProgramContext(co.cask.cdap.data.ProgramContext)

Aggregations

ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)53 ProgramId (co.cask.cdap.proto.id.ProgramId)23 Test (org.junit.Test)22 ApplicationId (co.cask.cdap.proto.id.ApplicationId)12 RunRecordMeta (co.cask.cdap.internal.app.store.RunRecordMeta)10 Path (javax.ws.rs.Path)10 RunId (org.apache.twill.api.RunId)10 DatasetId (co.cask.cdap.proto.id.DatasetId)9 Relation (co.cask.cdap.data2.metadata.lineage.Relation)7 HashSet (java.util.HashSet)7 NotFoundException (co.cask.cdap.common.NotFoundException)6 WorkflowNodeStateDetail (co.cask.cdap.proto.WorkflowNodeStateDetail)6 HashMap (java.util.HashMap)6 GET (javax.ws.rs.GET)6 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)5 NamespacedEntityId (co.cask.cdap.proto.id.NamespacedEntityId)5 StreamId (co.cask.cdap.proto.id.StreamId)5 Map (java.util.Map)5 CommandInputError (co.cask.cdap.cli.exception.CommandInputError)4 MethodArgument (co.cask.cdap.common.internal.remote.MethodArgument)4