Search in sources :

Example 1 with ContentExecutor

use of com.cognizant.devops.platformreports.assessment.content.ContentExecutor in project Insights by CognizantOneDevOps.

the class ReportKPISubscriber method executeContent.

private void executeContent(List<Integer> contentList, List<JsonObject> failedJobs) throws InterruptedException, ExecutionException {
    List<Callable<Integer>> contentListToExecute = new ArrayList<>();
    ReportPostgresDataHandler contentProcessing = new ReportPostgresDataHandler();
    int assessmentId = workflowConfig.getAssessmentConfig().getId();
    String assessmentReportName = workflowConfig.getAssessmentConfig().getAsseementreportname();
    int reportTemplateId = workflowConfig.getAssessmentConfig().getReportTemplateEntity().getReportId();
    for (int contentId : contentList) {
        InsightsContentConfig contentConfig = contentProcessing.getContentConfig(contentId);
        ContentConfigDefinition contentConfigDefinition = contentProcessing.convertJsonToContentConfig(contentConfig);
        log.debug("Type=TaskExecution  executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", contentConfigDefinition.getExecutionId(), contentConfigDefinition.getWorkflowId(), contentConfigDefinition.getReportId(), "", contentConfigDefinition.getKpiId(), contentConfigDefinition.getCategory(), 0, "ContentId :" + contentConfigDefinition.getContentId() + "ContentName :" + contentConfigDefinition.getContentName() + "action :" + contentConfigDefinition.getAction() + "ContentResult :" + contentConfigDefinition.getNoOfResult());
        if (contentConfigDefinition != null) {
            contentConfigDefinition.setExecutionId(executionId);
            contentConfigDefinition.setSchedule(WorkflowTaskEnum.WorkflowSchedule.valueOf(workflowConfig.getScheduleType()));
            contentConfigDefinition.setWorkflowId(workflowConfig.getWorkflowId());
            contentConfigDefinition.setReportId(reportTemplateId);
            contentConfigDefinition.setAssessmentId(assessmentId);
            contentConfigDefinition.setAssessmentReportName(assessmentReportName);
            contentListToExecute.add(new ContentExecutor(contentConfigDefinition));
        } else {
            log.error("Type=TaskExecution  executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", contentConfigDefinition.getExecutionId(), contentConfigDefinition.getWorkflowId(), contentConfigDefinition.getReportId(), "-", contentConfigDefinition.getKpiId(), contentConfigDefinition.getCategory(), 0, "ContentId :" + contentConfigDefinition.getContentId() + "ContentName :" + contentConfigDefinition.getContentName() + "action :" + contentConfigDefinition.getAction() + "ContentResult :" + contentConfigDefinition.getNoOfResult() + " Content execution failed");
            throw new InsightsJobFailedException("Content execution failed");
        }
    }
    /* segregate entire content execution list into defined chunks */
    List<List<Callable<Integer>>> contentChunkList = WorkflowThreadPool.getChunk(contentListToExecute, 3);
    /* submit each chunk to threadpool in a loop */
    executeContentChunks(contentChunkList, failedJobs);
}
Also used : ContentExecutor(com.cognizant.devops.platformreports.assessment.content.ContentExecutor) InsightsContentConfig(com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig) ReportPostgresDataHandler(com.cognizant.devops.platformreports.assessment.dal.ReportPostgresDataHandler) ArrayList(java.util.ArrayList) Callable(java.util.concurrent.Callable) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) ArrayList(java.util.ArrayList) List(java.util.List) ContentConfigDefinition(com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition)

Aggregations

InsightsContentConfig (com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig)1 ContentExecutor (com.cognizant.devops.platformreports.assessment.content.ContentExecutor)1 ReportPostgresDataHandler (com.cognizant.devops.platformreports.assessment.dal.ReportPostgresDataHandler)1 ContentConfigDefinition (com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition)1 InsightsJobFailedException (com.cognizant.devops.platformreports.exception.InsightsJobFailedException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1