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);
}
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);
}
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;
}
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);
}
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);
}
}
}
Aggregations