use of com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiEventJobExecution in project kylo by Teradata.
the class JpaBatchJobExecutionProvider method createJobExecution.
/**
* Create a new Job Execution record from a given Provenance Event
*
* @param jobInstance the job instance to relate this job execution to
* @param event the event that started this job execution
* @return the job execution
*/
private JpaBatchJobExecution createJobExecution(BatchJobInstance jobInstance, ProvenanceEventRecordDTO event, OpsManagerFeed feed) {
JpaBatchJobExecution jobExecution = new JpaBatchJobExecution();
jobExecution.setJobInstance(jobInstance);
// add in the parameters from the attributes
jobExecution.setCreateTime(DateTimeUtil.getNowUTCTime());
if (event.getStartTime() != null) {
jobExecution.setStartTime(DateTimeUtil.convertToUTC(event.getStartTime()));
} else {
jobExecution.setStartTime(DateTimeUtil.convertToUTC(event.getEventTime()));
}
jobExecution.setStatus(BatchJobExecution.JobStatus.STARTED);
jobExecution.setExitCode(ExecutionConstants.ExitCode.EXECUTING);
jobExecution.setLastUpdated(DateTimeUtil.getNowUTCTime());
// create the job params
Map<String, Object> jobParameters = new HashMap<>();
if (event.isStartOfJob() && event.getAttributeMap() != null) {
jobParameters = new HashMap<>(event.getAttributeMap());
} else {
jobParameters = new HashMap<>();
}
// save the params
JpaNifiEventJobExecution eventJobExecution = new JpaNifiEventJobExecution(jobExecution, event.getEventId(), event.getJobFlowFileId());
jobExecution.setNifiEventJobExecution(eventJobExecution);
jobExecution = (JpaBatchJobExecution) save(jobExecution);
jobExecutionChangedNotifier.notifyStarted(jobExecution, feed, null);
// bootstrap the feed parameters
jobParameters.put(FeedConstants.PARAM__FEED_NAME, event.getFeedName());
jobParameters.put(FeedConstants.PARAM__JOB_TYPE, FeedConstants.PARAM_VALUE__JOB_TYPE_FEED);
Set<JpaBatchJobExecutionParameter> jpaJobParameters = addJobParameters(jobExecution, jobParameters);
this.jobParametersRepository.save(jpaJobParameters);
return jobExecution;
}
Aggregations