Search in sources :

Example 1 with BatchRelatedFlowFile

use of com.thinkbiganalytics.metadata.api.jobrepo.job.BatchRelatedFlowFile in project kylo by Teradata.

the class JpaBatchJobExecutionProvider method isProcessBatchEvent.

private boolean isProcessBatchEvent(ProvenanceEventRecordDTO event, OpsManagerFeed feed) {
    // if we have a job already for this event then let it pass
    JpaBatchJobExecution jobExecution = jobExecutionRepository.findByFlowFile(event.getJobFlowFileId());
    if (jobExecution != null) {
        return true;
    } else {
        jobExecution = (JpaBatchJobExecution) findLatestJobForFeed(event.getFeedName());
        if (jobExecution != null) {
            String jobFlowFile = jobExecution.getNifiEventJobExecution().getFlowFileId();
            if (jobFlowFile.equals(event.getJobFlowFileId())) {
                return true;
            } else {
                boolean isSkipped = getOtherBatchJobFlowFile(event) != null;
                Long diff = event.getEventTime() - jobExecution.getStartTime().getMillis();
                Long threshold = timeBetweenStartingJobs(feed);
                if (!isSkipped && threshold != -1 && jobExecution != null && diff >= 0 && diff < threshold) {
                    // relate this to that and return
                    BatchRelatedFlowFile related = getOtherBatchJobFlowFile(event);
                    if (related == null) {
                        relateFlowFiles(event.getJobFlowFileId(), jobFlowFile, jobExecution.getJobExecutionId());
                        event.setJobFlowFileId(jobFlowFile);
                        log.debug("Relating {} to {}, {} ", event.getJobFlowFileId(), jobFlowFile, jobExecution.getJobExecutionId());
                    }
                    return false;
                } else {
                    return !isSkipped;
                }
            }
        }
    }
    return true;
}
Also used : BatchRelatedFlowFile(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchRelatedFlowFile)

Aggregations

BatchRelatedFlowFile (com.thinkbiganalytics.metadata.api.jobrepo.job.BatchRelatedFlowFile)1