use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class ThresholdContentCategoryImpl method averageInferenceResult.
/**
* Process KPI result to create content text using average method
*
* @param inferenceResults
* @return
*/
private InsightsContentDetail averageInferenceResult(List<InsightsKPIResultDetails> inferenceResults) {
long startTime = System.nanoTime();
Map<String, Object> resultValuesMap = new HashMap<>();
InsightsContentDetail inferenceContentResult = null;
String comparisonField = getResultFieldFromContentDefination();
InsightsKPIResultDetails resultDetailObj = inferenceResults.get(0);
try {
ReportEngineEnum.KPISentiment sentiment = ReportEngineEnum.KPISentiment.NEUTRAL;
String actaulDirection = "Neutral";
Double avgValue = inferenceResults.stream().mapToDouble((result -> (Double) result.getResults().get(comparisonField))).average().getAsDouble();
if (getContentConfig().getDirectionOfThreshold() == ReportEngineEnum.DirectionOfThreshold.BELOW) {
actaulDirection = (avgValue < getContentConfig().getThreshold()) ? AssessmentReportAndWorkflowConstants.BELOW : AssessmentReportAndWorkflowConstants.ABOVE;
} else {
actaulDirection = (avgValue > getContentConfig().getThreshold()) ? AssessmentReportAndWorkflowConstants.ABOVE : AssessmentReportAndWorkflowConstants.BELOW;
}
sentiment = getContentConfig().getDirectionOfThreshold().name().equalsIgnoreCase(actaulDirection) ? ReportEngineEnum.KPISentiment.POSITIVE : ReportEngineEnum.KPISentiment.NEGATIVE;
resultValuesMap.put(AssessmentReportAndWorkflowConstants.ACTUALDIRECTION, actaulDirection);
resultValuesMap.put("result", avgValue);
addTimeValueinResult(resultValuesMap, contentConfigDefinition.getSchedule());
String inferenceText = null;
if (avgValue == 0.0) {
inferenceText = getContentText(ReportEngineUtils.NEUTRAL_MESSAGE_KEY, resultValuesMap);
} else {
inferenceText = getContentText(ReportEngineUtils.STANDARD_MESSAGE_KEY, resultValuesMap);
}
if (inferenceText != null) {
inferenceContentResult = setContentDetail(resultDetailObj, resultValuesMap, sentiment, "", inferenceText);
} else {
log.debug("Worlflow Detail ==== inference text is null for average threshold KPIId {} contentId {} result {} ", getContentConfig().getKpiId(), getContentConfig().getContentId(), resultDetailObj);
}
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", contentConfigDefinition.getExecutionId(), contentConfigDefinition.getWorkflowId(), contentConfigDefinition.getReportId(), "-", contentConfigDefinition.getKpiId(), contentConfigDefinition.getCategory(), processingTime, "ContentId :" + contentConfigDefinition.getContentId() + "ContentName :" + contentConfigDefinition.getContentName() + "action :" + contentConfigDefinition.getAction() + "ContentResult :" + contentConfigDefinition.getNoOfResult());
} catch (Exception e) {
log.error(e);
log.error(" Error while content processing for average threshold KPIId {} contentId {} ", getContentConfig().getKpiId(), getContentConfig().getContentId());
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() + "Exception while running neo4j operation" + e.getMessage());
throw new InsightsJobFailedException("Exception while running neo4j operation {} " + e.getMessage());
}
return inferenceContentResult;
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class AutoMLSubscriber method updateFailedTaskStatusLog.
private void updateFailedTaskStatusLog(List<JsonObject> failedJobs) {
long startTime = System.nanoTime();
JsonObject statusObject = new JsonObject();
JsonArray errorLog = new JsonArray();
failedJobs.forEach(failedJob -> errorLog.add(failedJob.get("errorLog").getAsString()));
statusObject.addProperty("executionId", executionId);
statusObject.addProperty("workflowId", workflowConfig.getWorkflowId());
statusObject.add("errorLog", errorLog);
autoMlConfig.setStatus(AutoMLEnum.Status.ERROR.name());
autoMlDAL.updateMLConfig(autoMlConfig);
// statusLog set here which is class variable of WorkflowTaskSubscriberHandler
statusLog = new Gson().toJson(statusObject);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, autoMlConfig.getWorkflowConfig().getWorkflowId(), "-", autoMlConfig.getWorkflowConfig().getWorkflowType(), "-", "-", processingTime, "ModelId :" + autoMlConfig.getModelId() + "UsecaseName :" + autoMlConfig.getUseCaseName() + "PredictionColumn : " + autoMlConfig.getPredictionColumn() + "predictionType :" + autoMlConfig.getPredictionType() + "trainingPercentage : " + autoMlConfig.getTrainingPerc() + "status : " + autoMlConfig.getStatus() + "AutoML task failed to execute ");
throw new InsightsJobFailedException("AutoML task failed to execute " + statusLog);
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class SystemNotificationDetailSubscriber method createEmailHTML.
/**
* Method to create Email HTML
*
* @param idDataMap
* @return String
*/
private String createEmailHTML(Map<String, String> idDataMap) {
try {
File mailTemplate = new File(getClass().getClassLoader().getResource("mailTemplate.html").getFile());
String template = new String(Files.readAllBytes(mailTemplate.toPath()));
String validTemplate = ValidationUtils.cleanXSS(template);
Document document = Jsoup.parse(validTemplate, StandardCharsets.UTF_8.name());
return createComponentTable(idDataMap, document);
} catch (Exception e) {
log.error("Worlflow Detail ==== Error creating HTML body for email");
throw new InsightsJobFailedException("Worlflow Detail ==== Error creating HTML body for email");
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class ReportElasticSearchDataHandler method saveContentResult.
@Override
public void saveContentResult(JsonObject contentResult) {
try {
log.debug("Worlflow Detail ==== In ES, saveContentResult started ");
List<JsonObject> rows = new ArrayList<>();
rows.add(contentResult);
String indexName = ReportEngineUtils.ES_CONTENT_RESULT_INDEX;
deoES.saveESResult(indexName.toLowerCase(), rows);
log.debug("Worlflow Detail ==== In ES, saveContentResult completed ");
} catch (Exception e) {
log.error("Error while saving Content Result record {}", e.getMessage());
throw new InsightsJobFailedException("Error while saving neo4j record {} " + e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class ReportElasticSearchDataHandler method saveData.
@Override
public void saveData(List<JsonObject> resultList) {
try {
String indexName = ReportEngineUtils.ES_KPI_RESULT_INDEX;
deoES.saveESResult(indexName.toLowerCase(), resultList);
} catch (Exception e) {
log.error("Error while saving saving KPI record {}", e.getMessage());
throw new InsightsJobFailedException("Error while saving neo4j record " + e.getMessage());
}
}
Aggregations