use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException 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);
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class ReportKPISubscriber method updateFailedTaskStatusLog.
private void updateFailedTaskStatusLog(List<JsonObject> failedJobs) throws InterruptedException, ExecutionException {
JsonObject statusObject = new JsonObject();
JsonArray kpiArray = new JsonArray();
JsonArray contentArray = new JsonArray();
for (JsonObject failedJob : failedJobs) {
// JsonObject payload = failedJob
if (failedJob.has("kpiArray")) {
failedJob.get("kpiArray").getAsJsonArray().forEach(id -> kpiArray.add(id));
} else if (failedJob.has(AssessmentReportAndWorkflowConstants.CONTENT_ARRAY)) {
failedJob.get(AssessmentReportAndWorkflowConstants.CONTENT_ARRAY).getAsJsonArray().forEach(id -> contentArray.add(id));
}
}
statusObject.addProperty("executionId", executionId);
statusObject.addProperty("workflowId", workflowConfig.getWorkflowId());
statusObject.add("kpiList", kpiArray);
statusObject.add(AssessmentReportAndWorkflowConstants.CONTENT_ARRAY, contentArray);
// statusLog set here which is class variable of WorkflowTaskSubscriberHandler
statusLog = new Gson().toJson(statusObject);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, workflowConfig.getWorkflowId(), "-", workflowConfig.getWorkflowType(), "-", "-", 0, "statusLog: " + statusLog);
throw new InsightsJobFailedException("some of the Kpi's or Contents failed to execute");
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class SystemNotificationDetailSubscriber method setDetailsInEmailHistory.
/**
* Method to save Email details in Email History table
*
* @param incomingTaskMessageJson
* @param mailBody
*/
private void setDetailsInEmailHistory(JsonObject incomingTaskMessageJson, String mailBody) {
try {
InsightsReportVisualizationContainer emailHistoryConfig = new InsightsReportVisualizationContainer();
emailHistoryConfig.setExecutionId(incomingTaskMessageJson.get("executionId").getAsLong());
emailHistoryConfig.setStatus(WorkflowTaskEnum.EmailStatus.NOT_STARTED.name());
emailHistoryConfig.setWorkflowConfig(incomingTaskMessageJson.get("workflowId").getAsString());
emailHistoryConfig.setMailBody(mailBody);
emailHistoryConfig.setMailAttachmentName("");
workflowDAL.saveEmailExecutionHistory(emailHistoryConfig);
} catch (Exception e) {
log.error("Worlflow Detail ==== Error setting Email details in Email History table");
throw new InsightsJobFailedException("Worlflow Detail ==== Error setting Email details in Email History table");
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class SystemNotificationDetailSubscriber method handleTaskExecution.
@Override
public void handleTaskExecution(byte[] body) throws IOException {
try {
long startTime = System.nanoTime();
String incomingTaskMessage = new String(body, StandardCharsets.UTF_8);
JsonObject incomingTaskMessageJson = JsonUtils.parseStringAsJsonObject(incomingTaskMessage);
String workflowId = incomingTaskMessageJson.get("workflowId").getAsString();
executionId = incomingTaskMessageJson.get("executionId").getAsLong();
workflowConfig = workflowDAL.getWorkflowConfigByWorkflowId(workflowId);
String htmlDataComponentResponseBuffer = componentHTML(healthUtil.getDataComponentStatus(), "Data Component");
String htmlServiceResponseBuffer = componentHTML(healthUtil.getServiceStatus(), "Services");
String htmlAgentResponseBuffer = getAgentHTML();
Map<String, String> idDataMap = new LinkedHashMap<>();
idDataMap.put("table_agent", htmlAgentResponseBuffer);
idDataMap.put("table_services", htmlServiceResponseBuffer);
idDataMap.put("table_data_components", htmlDataComponentResponseBuffer);
String mailHTML = createEmailHTML(idDataMap);
Map<String, String> valuesMap = new HashMap<>();
valuesMap.put("date", InsightsUtils.specficTimeFormat(incomingTaskMessageJson.get("executionId").getAsLong(), "yyyy-MM-dd"));
StringSubstitutor sub = new StringSubstitutor(valuesMap, "{", "}");
mailHTML = sub.replace(mailHTML);
setDetailsInEmailHistory(incomingTaskMessageJson, mailHTML);
InsightsStatusProvider.getInstance().createInsightStatusNode("SystemNotificationDetailSubscriber completed", PlatformServiceConstants.SUCCESS);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, workflowConfig.getWorkflowId(), "-", workflowConfig.getWorkflowType(), "-", "-", processingTime, "-");
} catch (InsightsJobFailedException ijfe) {
log.error("Worlflow Detail ==== SystemNotificationDetail Subscriber Completed with error ", ijfe);
InsightsStatusProvider.getInstance().createInsightStatusNode("SystemNotificationDetail Completed with error " + ijfe.getMessage(), PlatformServiceConstants.FAILURE);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, workflowConfig.getWorkflowId(), "-", workflowConfig.getWorkflowType(), "-", "-", 0, workflowConfig.getStatus() + "SystemNotificationDetail Subscriber Completed with error" + ijfe.getMessage());
statusLog = ijfe.getMessage();
throw ijfe;
} catch (Exception e) {
log.error("Worlflow Detail ==== SystemNotificationDetail Subscriber Completed with error ", e);
InsightsStatusProvider.getInstance().createInsightStatusNode("SystemNotificationDetail Completed with error " + e.getMessage(), PlatformServiceConstants.FAILURE);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, workflowConfig.getWorkflowId(), "-", workflowConfig.getWorkflowType(), "-", "-", 0, workflowConfig.getStatus() + "SystemNotificationDetail Subscriber Completed with error" + e.getMessage());
throw new InsightsJobFailedException(e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class AssessmentReportContentProcesser method executeContentData.
/**
* Used to process content based on KPI Result, It either fetch record from DB
* or from file Make a method to directly process content in case any kpi is
* successful but their any content is failed so we in such cases we need to run
* content only.
*/
public void executeContentData(ContentConfigDefinition inferenceContentConfigDefinition) {
try {
long startTime = System.nanoTime();
BaseContentCategoryImpl baseContentAction;
if (inferenceContentConfigDefinition.getCategory() == ReportEngineEnum.ContentCategory.COMPARISON || inferenceContentConfigDefinition.getCategory() == ReportEngineEnum.ContentCategory.STANDARD) {
baseContentAction = new ComparisonContentCategoryImpl(inferenceContentConfigDefinition);
} else if (inferenceContentConfigDefinition.getCategory() == ReportEngineEnum.ContentCategory.THRESHOLD) {
baseContentAction = new ThresholdContentCategoryImpl(inferenceContentConfigDefinition);
} else if (inferenceContentConfigDefinition.getCategory() == ReportEngineEnum.ContentCategory.THRESHOLD_RANGE) {
baseContentAction = new ThresholdRangeCategoryImpl(inferenceContentConfigDefinition);
} else if (inferenceContentConfigDefinition.getCategory() == ReportEngineEnum.ContentCategory.MINMAX) {
baseContentAction = new MinMaxCategoryImpl(inferenceContentConfigDefinition);
} else if (inferenceContentConfigDefinition.getCategory() == ReportEngineEnum.ContentCategory.TREND) {
baseContentAction = new TrendCategoryImpl(inferenceContentConfigDefinition);
} else {
log.error("Worlflow Detail ==== No content category executer defined for contentId {}", inferenceContentConfigDefinition.getContentId());
throw new InsightsJobFailedException("Worlflow Detail ==== No content category executer defined");
}
baseContentAction.generateContent();
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", inferenceContentConfigDefinition.getExecutionId(), inferenceContentConfigDefinition.getWorkflowId(), inferenceContentConfigDefinition.getReportId(), "-", inferenceContentConfigDefinition.getKpiId(), inferenceContentConfigDefinition.getCategory(), processingTime, " ContentId :" + inferenceContentConfigDefinition.getContentId() + " ContentName :" + inferenceContentConfigDefinition.getContentName() + " action :" + inferenceContentConfigDefinition.getAction() + " ContentResult :" + inferenceContentConfigDefinition.getNoOfResult());
} catch (InsightsJobFailedException e) {
log.error("Worlflow Detail ==== Exception while execution content Id %d KPI Id {} exception {} ", inferenceContentConfigDefinition.getContentId(), inferenceContentConfigDefinition.getKpiId(), e);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", inferenceContentConfigDefinition.getExecutionId(), inferenceContentConfigDefinition.getWorkflowId(), inferenceContentConfigDefinition.getReportId(), "-", inferenceContentConfigDefinition.getKpiId(), inferenceContentConfigDefinition.getCategory(), 0, "ContentId :" + inferenceContentConfigDefinition.getContentId() + "ContentName :" + inferenceContentConfigDefinition.getContentName() + "action :" + inferenceContentConfigDefinition.getAction() + "ContentResult :" + inferenceContentConfigDefinition.getNoOfResult() + "Exception while execution content Id " + e.getMessage());
throw new InsightsJobFailedException("Exception while execution content Id");
}
}
Aggregations