use of co.cask.cdap.proto.ProgramRunCluster in project cdap by caskdata.
the class AppMetadataStore method recordProgramProvisioning.
/**
* Record that the program run is provisioning compute resources for the run. If the current status has
* a higher source id, this call will be ignored.
*
* @param programRunId program run
* @param startTs start time of the run
* @param runtimeArgs runtime arguments
* @param systemArgs system arguments
* @param sourceId unique id representing the source of program run status, such as the message id of the program
* run status notification in TMS. The source id must increase as the recording time of the program
* run status increases, so that the attempt to persist program run status older than the existing
* program run status will be ignored
* @return {@link ProgramRunClusterStatus#PROVISIONING} if it is successfully persisted, {@code null} otherwise.
*/
@Nullable
public ProgramRunClusterStatus recordProgramProvisioning(ProgramRunId programRunId, long startTs, Map<String, String> runtimeArgs, Map<String, String> systemArgs, byte[] sourceId) {
MDSKey key = getProgramKeyBuilder(TYPE_RUN_RECORD_STARTING, programRunId).build();
RunRecordMeta existing = getRun(programRunId);
// for some reason, there is an existing run record.
if (existing != null) {
// runtime args, and system args of the existing run record.
if (!isValid(existing, sourceId, "provisioning")) {
return null;
}
return null;
}
String workflowRunId = null;
if (systemArgs != null && systemArgs.containsKey(ProgramOptionConstants.WORKFLOW_NAME)) {
workflowRunId = systemArgs.get(ProgramOptionConstants.WORKFLOW_RUN_ID);
}
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("runtimeArgs", GSON.toJson(runtimeArgs, MAP_STRING_STRING_TYPE));
if (workflowRunId != null) {
builder.put("workflowrunid", workflowRunId);
}
ProgramRunCluster cluster = new ProgramRunCluster(ProgramRunClusterStatus.PROVISIONING, null, null);
RunRecordMeta meta = RunRecordMeta.builder().setProgramRunId(programRunId).setStartTime(startTs).setStatus(ProgramRunStatus.STARTING).setProperties(builder.build()).setSystemArgs(systemArgs).setCluster(cluster).setSourceId(sourceId).build();
write(key, meta);
return ProgramRunClusterStatus.PROVISIONING;
}
Aggregations