use of co.cask.cdap.internal.app.store.RunRecordMeta in project cdap by caskdata.
the class ProgramLifecycleService method shouldCorrectForWorkflowChildren.
/**
* Helper method to check if the run record is a child program of a Workflow
*
* @param runRecordMeta The target {@link RunRecordMeta} to check
* @param processedInvalidRunRecordIds the {@link Set} of processed invalid run record ids.
* @return {@code true} of we should check and {@code false} otherwise
*/
private boolean shouldCorrectForWorkflowChildren(RunRecordMeta runRecordMeta, Set<String> processedInvalidRunRecordIds) {
// check if it is part of workflow because it may not have actual runtime info
if (runRecordMeta.getProperties() != null && runRecordMeta.getProperties().get("workflowrunid") != null) {
// Get the parent Workflow info
String workflowRunId = runRecordMeta.getProperties().get("workflowrunid");
if (!processedInvalidRunRecordIds.contains(workflowRunId)) {
// If the parent workflow has not been processed, then check if it still valid
ProgramId workflowProgramId = retrieveProgramIdForRunRecord(ProgramType.WORKFLOW, workflowRunId);
if (workflowProgramId != null) {
// lets see if the parent workflow run records state is still running
RunRecordMeta wfRunRecord = store.getRun(workflowProgramId, workflowRunId);
RuntimeInfo wfRuntimeInfo = runtimeService.lookup(workflowProgramId, RunIds.fromString(workflowRunId));
// then do not update it
if (wfRunRecord != null && wfRunRecord.getStatus() == ProgramRunStatus.RUNNING && wfRuntimeInfo != null) {
return false;
}
}
}
}
return true;
}
use of co.cask.cdap.internal.app.store.RunRecordMeta in project cdap by caskdata.
the class ProgramLifecycleService method validateProgramForRunRecord.
/**
* Helper method to get program id for a run record if it exists in the store.
*
* @return instance of {@link ProgramId} if exist for the runId or null if does not
*/
@Nullable
private ProgramId validateProgramForRunRecord(String namespaceName, String appName, String appVersion, ProgramType programType, String programName, String runId) {
ProgramId programId = Ids.namespace(namespaceName).app(appName, appVersion).program(programType, programName);
RunRecordMeta runRecord = store.getRun(programId, runId);
if (runRecord == null) {
return null;
}
return programId;
}
use of co.cask.cdap.internal.app.store.RunRecordMeta in project cdap by caskdata.
the class LogHandler method getRunRecordMeta.
private RunRecordMeta getRunRecordMeta(String namespace, String app, ProgramType programType, String programName, String run) throws NotFoundException {
ProgramRunId programRunId = new ProgramRunId(namespace, app, programType, programName, run);
RunRecordMeta runRecord = programStore.getRun(programRunId.getParent(), programRunId.getRun());
if (runRecord == null) {
throw new NotFoundException(programRunId);
}
return runRecord;
}
use of co.cask.cdap.internal.app.store.RunRecordMeta in project cdap by caskdata.
the class LogHandler method getRunIdLogs.
@GET
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/runs/{run-id}/logs")
public void getRunIdLogs(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("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 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());
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 AppMetadataStore method getRun.
// TODO: getRun is duplicated from cdap-app-fabric AppMetadataStore class.
// Any changes made here will have to be made over there too.
// JIRA https://issues.cask.co/browse/CDAP-2172
public RunRecordMeta getRun(ProgramId program, final String runid) {
// Query active run record first
RunRecordMeta running = getUnfinishedRun(program, TYPE_RUN_RECORD_STARTED, runid);
// If program is running, this will be non-null
if (running != null) {
return running;
}
// If program is not running, query completed run records
RunRecordMeta complete = getCompletedRun(program, runid);
if (complete != null) {
return complete;
}
// Else query suspended run records
return getUnfinishedRun(program, TYPE_RUN_RECORD_SUSPENDED, runid);
}
Aggregations