use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class ComparisonContentCategoryImpl method getContentFromResult.
/**
* process KPI result based on comparison category to generate content object
*
* @param kpiResultDetailsList
* @return
*/
public InsightsContentDetail getContentFromResult(List<InsightsKPIResultDetails> kpiResultDetailsList) {
InsightsContentDetail inferenceContentResult = null;
try {
long startTime = System.nanoTime();
InsightsKPIResultDetails resultFirstData = kpiResultDetailsList.get(0);
String actualTrend = ReportEngineEnum.KPITrends.NOCHANGE.getValue();
ReportEngineEnum.KPISentiment sentiment = ReportEngineEnum.KPISentiment.NEUTRAL;
Map<String, Object> resultValuesMap = resultFirstData.getResults();
String contentText = "";
String comparisonField = getResultFieldFromContentDefination();
Object currentValue = resultFirstData.getResults().get(comparisonField);
// This condition will be executed if KPI comparison is FALSE
if (getContentConfig().getCategory() == ReportEngineEnum.ContentCategory.COMPARISON) {
if (kpiResultDetailsList.size() < 2) {
return setNeutralContentDetail();
}
InsightsKPIResultDetails previousDateData = kpiResultDetailsList.get(1);
Object previousValue = previousDateData.getResults().get(comparisonField);
sentiment = getSentiment(previousValue, currentValue, getContentConfig().getExpectedTrend());
actualTrend = String.valueOf(getActualTrend(getContentConfig().getExpectedTrend(), sentiment));
resultValuesMap.put("current:" + comparisonField, getResultValueForDisplay(currentValue));
resultValuesMap.put("previous:" + comparisonField, getResultValueForDisplay(previousValue));
contentText = getContentText(sentiment.getValue(), resultValuesMap);
} else if (getContentConfig().getCategory() == ReportEngineEnum.ContentCategory.STANDARD) {
log.debug("Worlflow Detail ==== record {} value for STANDARD category is {} ", comparisonField, currentValue);
if (currentValue != null && (String.valueOf(currentValue).equalsIgnoreCase("0.0") || String.valueOf(currentValue).equalsIgnoreCase("0") || String.valueOf(currentValue).equalsIgnoreCase(""))) {
contentText = getContentText(ReportEngineUtils.NEUTRAL_MESSAGE_KEY, resultValuesMap);
} else {
contentText = getContentText(ReportEngineUtils.STANDARD_MESSAGE_KEY, resultValuesMap);
}
}
if (contentText != null) {
inferenceContentResult = setContentDetail(resultFirstData, resultValuesMap, sentiment, actualTrend, contentText);
} else {
log.debug("Worlflow Detail ==== content text is null in comparison KPI KPIId {} contentId {} result {} ", contentConfigDefinition.getKpiId(), contentConfigDefinition.getContentId(), resultFirstData);
}
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("Worlflow Detail ==== Error while content processing comparison KPIId {} contentId {} ", contentConfigDefinition.getKpiId(), contentConfigDefinition.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() + " Error while content processing comparison " + e.getMessage());
throw new InsightsJobFailedException("Error while content processing comparison KPIId {} contentId {} " + e.getMessage());
}
return inferenceContentResult;
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class MilestoneCommunicationSubscriber method handleTaskExecution.
@Override
public void handleTaskExecution(byte[] body) throws IOException {
String incomingTaskMessage = new String(body, StandardCharsets.UTF_8);
log.debug("Worlflow Detail ==== MilestoneCommunicationSubscriber started ... " + "routing key message handleDelivery ===== {} ", incomingTaskMessage);
JsonObject incomingTaskMessageJson = JsonUtils.parseStringAsJsonObject(incomingTaskMessage);
String workflowId = incomingTaskMessageJson.get("workflowId").getAsString();
String routingKey = MQMessageConstants.MILESTONE_STATUS_QUEUE.replace("_", ".");
Channel channel;
try {
channel = RabbitMQConnectionProvider.getChannel(routingKey, MQMessageConstants.MILESTONE_STATUS_QUEUE, MQMessageConstants.EXCHANGE_NAME, MQMessageConstants.EXCHANGE_TYPE);
setChannel(channel);
log.debug("prefetchCount {} for routingKey {} ", ApplicationConfigProvider.getInstance().getMessageQueue().getPrefetchCount(), routingKey);
Consumer consumer = new DefaultConsumer(channel) {
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] statusbody) throws IOException {
try {
String incomingStatusMessage = new String(statusbody, StandardCharsets.UTF_8);
log.debug(" ROI execution incomingStatusMessage : {}", incomingStatusMessage);
JsonObject incomingStatusMessageJson = JsonUtils.parseStringAsJsonObject(incomingStatusMessage);
int milestoneId = incomingStatusMessageJson.get("milestoneId").getAsInt();
int outcomeId = incomingStatusMessageJson.get("outcomeId").getAsInt();
String status = incomingStatusMessageJson.get("status").getAsString();
String message = incomingStatusMessageJson.get("message").getAsString();
mileStoneConfigDAL.updateMilestoneOutcomeStatus(milestoneId, outcomeId, status, message);
MileStoneConfig mileStoneConfig = mileStoneConfigDAL.getMileStoneConfigById(milestoneId);
boolean updateFlag = mileStoneConfig.getListOfOutcomes().stream().allMatch(outcome -> outcome.getStatus().equalsIgnoreCase("SUCCESS"));
boolean updateErrorFlag = mileStoneConfig.getListOfOutcomes().stream().anyMatch(outcome -> outcome.getStatus().equalsIgnoreCase("ERROR"));
if (updateFlag) {
mileStoneConfigDAL.updateMilestoneStatus(milestoneId, MilestoneEnum.MilestoneStatus.COMPLETED.name());
} else if (updateErrorFlag) {
mileStoneConfigDAL.updateMilestoneStatus(milestoneId, MilestoneEnum.MilestoneStatus.ERROR.name());
} else {
mileStoneConfigDAL.updateMilestoneStatus(milestoneId, MilestoneEnum.MilestoneStatus.IN_PROGRESS.name());
}
getChannel().basicAck(envelope.getDeliveryTag(), false);
} catch (Exception e) {
log.error("Error : ", e);
}
}
};
channel.basicConsume(MQMessageConstants.MILESTONE_STATUS_QUEUE, false, routingKey, consumer);
} catch (Exception e) {
log.error("Worlflow Detail ==== MilestoneCommunicationSubscriber Completed with error ", e);
throw new InsightsJobFailedException(e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class PDFExecutionSubscriber method handleTaskExecution.
@Override
public void handleTaskExecution(byte[] body) throws IOException {
try {
long startTime = System.nanoTime();
String incomingTaskMessage = new String(body, MQMessageConstants.MESSAGE_ENCODING);
log.debug("Worlflow Detail ==== PDFExecutionSubscriber started ... routing key message handleDelivery ===== {} ", incomingTaskMessage);
assessmentReportDTO = new InsightsAssessmentConfigurationDTO();
JsonObject incomingTaskMessageJson = JsonUtils.parseStringAsJsonObject(incomingTaskMessage);
prepareVisualizationJsonBasedOnKPIResult(incomingTaskMessageJson);
processVisualizationJson();
setPDFDetailsInEmailHistory(incomingTaskMessageJson);
log.debug("Worlflow Detail ==== PDFExecutionSubscriber Completed {} ", incomingTaskMessage);
InsightsStatusProvider.getInstance().createInsightStatusNode("PDFExecutionSubscriber completed", PlatformServiceConstants.SUCCESS);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), "-", "-", "-", processingTime, "reportId: " + assessmentReportDTO.getReportId() + "reportName: " + assessmentReportDTO.getReportName() + "VisualizationUtil" + assessmentReportDTO.getVisualizationutil() + "PDFExecutionSubscriber Completed ");
} catch (InsightsJobFailedException ijfe) {
log.error("Worlflow Detail ==== PDFExecutionSubscriber Completed with error ", ijfe);
InsightsStatusProvider.getInstance().createInsightStatusNode("PDFExecutionSubscriber Completed with error " + ijfe.getMessage(), PlatformServiceConstants.FAILURE);
statusLog = ijfe.getMessage();
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), "-", "-", "-", 0, "reportId: " + assessmentReportDTO.getReportId() + "reportName: " + assessmentReportDTO.getReportName() + "VisualizationUtil" + assessmentReportDTO.getVisualizationutil() + "PDFExecutionSubscriber Completed with error " + ijfe.getMessage());
throw ijfe;
} catch (Exception e) {
log.error("Worlflow Detail ==== PDFExecutionSubscriber Completed with error ", e);
InsightsStatusProvider.getInstance().createInsightStatusNode("PDFExecutionSubscriber Completed with error " + e.getMessage(), PlatformServiceConstants.FAILURE);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), "-", "-", "-", 0, "reportId: " + assessmentReportDTO.getReportId() + "reportName: " + assessmentReportDTO.getReportName() + "VisualizationUtil" + assessmentReportDTO.getVisualizationutil() + "PDFExecutionSubscriber 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 UpshiftAssessmentExecutionSubscriber method handleTaskExecution.
@Override
public void handleTaskExecution(byte[] body) throws IOException {
try {
long startTime = System.nanoTime();
String incomingTaskMessage = new String(body, StandardCharsets.UTF_8);
log.debug("Worlflow Detail ==== UpshiftAssessmentExecutionSubscriber started ... " + "routing key message handleDelivery ===== {} ", incomingTaskMessage);
JsonObject incomingTaskMessageJson = JsonUtils.parseStringAsJsonObject(incomingTaskMessage);
String workflowId = incomingTaskMessageJson.get("workflowId").getAsString();
long executionId = incomingTaskMessageJson.get("executionId").getAsLong();
workflowConfig = workflowDAL.getWorkflowConfigByWorkflowId(workflowId);
log.debug("Worlflow Detail ==== scheduleType {} ", workflowConfig.getScheduleType());
assessmentReportDTO = new InsightsAssessmentConfigurationDTO();
assessmentReportDTO.setIncomingTaskMessageJson(incomingTaskMessage);
assessmentReportDTO.setAsseementreportname(WorkflowTaskEnum.WorkflowType.UPSHIFTASSESSMENT.getValue());
assessmentReportDTO.setExecutionId(executionId);
assessmentReportDTO.setWorkflowId(workflowId);
BaseDataProcessor chartHandler = ReportDataProcessHandlerFactory.getDataHandler("UPSHIFTASSESSMENT");
chartHandler.processJson(assessmentReportDTO);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, workflowId, assessmentReportDTO.getReportId(), workflowConfig.getWorkflowType(), "-", "-", processingTime, "Schedule :" + workflowConfig.getScheduleType() + "ReportName :" + assessmentReportDTO.getReportName() + "UpshiftAssessmentExecutionSubscriber Block");
} catch (Exception e) {
log.error("Worlflow Detail ==== GrafanaPDFExecutionSubscriber Completed with error ", e);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getReportId(), workflowConfig.getWorkflowType(), "-", "-", 0, "Schedule :" + workflowConfig.getScheduleType() + "ReportName :" + assessmentReportDTO.getReportName() + "GrafanaPDFExecutionSubscriber 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 UpshiftAssessmentHandler method processJson.
/**
* Process the stored json based on the type of data
* @param assessmentReportDTO
*/
@Override
public void processJson(InsightsAssessmentConfigurationDTO assessmentReportDTO) {
JsonElement element = null;
UpshiftAssessmentConfig upshiftAssessmentConfig = upshiftAssessmentConfigDAL.fetchUpshiftAssessmentDetailsByWorkflowId(assessmentReportDTO.getWorkflowId());
try {
long startTime = System.nanoTime();
byte[] upshiftFileBytes = upshiftAssessmentConfig.getFile();
String uuid = upshiftAssessmentConfig.getUpshiftUuid();
String fileString = new String(upshiftFileBytes, StandardCharsets.ISO_8859_1);
Map<?, ?> map = gson.fromJson(fileString, Map.class);
List<JsonObject> dataList = new ArrayList<>();
JsonObject primaryKey = new JsonObject();
String primKey = String.valueOf(System.currentTimeMillis());
primaryKey.addProperty("insightsTime", primKey);
primaryKey.addProperty("toolName", "UPSHIFT");
primaryKey.addProperty("categoryName", "INSIGHTSUPSHIFT");
primaryKey.addProperty("jenkinsExecutionId", upshiftAssessmentConfig.getJenkinsExecId());
dataList.add(primaryKey);
if (createNode("DATA", dataList)) {
flag = Boolean.FALSE;
}
for (Map.Entry<?, ?> entry : map.entrySet()) {
element = JsonUtils.parseString(gson.toJson(entry.getValue()));
if (element.isJsonPrimitive() && updateNode(primKey, entry.getKey().toString(), element.getAsString())) {
flag = Boolean.FALSE;
} else if (element.isJsonObject()) {
createObjectNode(uuid, primKey, entry.getKey().toString(), element.getAsJsonObject());
} else if (element.isJsonArray()) {
parseJsonArray(uuid, primKey, entry.getKey().toString(), element.getAsJsonArray());
}
}
log.debug("Completed processing of upshift report: {}", upshiftAssessmentConfig.getFileName());
log.debug("Total nodes created: {}", numOfNodes);
updateReportStatus(upshiftAssessmentConfig);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getReportId(), upshiftAssessmentConfig.getWorkflowConfig().getWorkflowType(), "-", "-", processingTime, "UpshiftUuid :" + upshiftAssessmentConfig.getUpshiftUuid() + "CreatedDate :" + upshiftAssessmentConfig.getCreatedDate() + "UpdatedDate :" + upshiftAssessmentConfig.getUpdatedDate() + "fileName :" + upshiftAssessmentConfig.getFileName() + "status :" + upshiftAssessmentConfig.getStatus() + "Completed processing of upshift report");
} catch (Exception e) {
log.error(e.getStackTrace());
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getReportId(), upshiftAssessmentConfig.getWorkflowConfig().getWorkflowType(), "-", "-", 0, "UpshiftUuid :" + upshiftAssessmentConfig.getUpshiftUuid() + "CreatedDate :" + upshiftAssessmentConfig.getCreatedDate() + "UpdatedDate :" + upshiftAssessmentConfig.getUpdatedDate() + "fileName :" + upshiftAssessmentConfig.getFileName() + "status :" + upshiftAssessmentConfig.getStatus() + element.getAsString() + e.getMessage());
throw new InsightsJobFailedException(e.getMessage());
}
}
Aggregations