Search in sources :

Example 11 with InsightsJobFailedException

use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.

the class BaseContentCategoryImpl method saveContentResult.

/**
 * Merge content json and result JSON. Prepare content json object and store it
 * in Graph or ES DB
 *
 * @param contentResult
 */
public void saveContentResult(InsightsContentDetail contentResult) {
    try {
        long startTime = System.nanoTime();
        String json = oMapper.writeValueAsString(contentResult);
        JsonObject contentDataJson = JsonUtils.parseStringAsJsonObject(json);
        if (!contentResult.getResultValuesMap().isEmpty() && contentDataJson != null) {
            JsonObject resultValueJson = JsonUtils.parseStringAsJsonObject(oMapper.writeValueAsString(contentResult.getResultValuesMap()));
            contentDataJson = ReportEngineUtils.mergeTwoJson(contentDataJson, resultValueJson);
        } else {
            log.debug("Worlflow Detail {}==== In Content, no result foundg and data json is null {} ", contentResult.getResultValuesMap(), contentDataJson);
            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() + "In Content, no result foundg and data json is null");
        }
        datasourceDataHandler.saveContentResult(contentDataJson);
        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(" Error while saveContentResult ", e);
        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 saveContentResult " + e.getMessage());
        throw new InsightsJobFailedException(" Error while saveContentResult for content Id " + contentResult.getContentId());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) JsonObject(com.google.gson.JsonObject) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Example 12 with InsightsJobFailedException

use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.

the class GrafanaPDFExecutionSubscriber 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 ==== GrafanaPDFExecutionSubscriber 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.setExecutionId(executionId);
        assessmentReportDTO.setWorkflowId(workflowId);
        BasePDFProcessor chartHandler = ReportPDFVisualizationHandlerFactory.getChartHandler("GrafanaPDF");
        chartHandler.generatePDF(assessmentReportDTO);
        long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
        log.debug("Type = Grafana PDF ");
        log.debug("Type=TaskExecution  executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), workflowConfig.getWorkflowType(), "-", "-", processingTime, " ReportName :" + assessmentReportDTO.getReportName() + " Visualizationutil :" + assessmentReportDTO.getVisualizationutil());
    } catch (InsightsJobFailedException ie) {
        log.error("Worlflow Detail ==== GrafanaPDFExecutionSubscriber Completed with error ", ie);
        log.error("Type = Grafana PDF");
        log.error("Type=TaskExecution  executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), workflowConfig.getWorkflowType(), "-", "-", 0, " ReportName :" + assessmentReportDTO.getReportName() + " Visualizationutil :" + assessmentReportDTO.getVisualizationutil() + "GrafanaPDFExecutionSubscriber Completed with error" + ie.getMessage());
        statusLog = ie.getMessage();
        throw ie;
    } catch (Exception e) {
        log.error("Worlflow Detail ==== GrafanaPDFExecutionSubscriber Completed with error ", e);
        log.error("Type = Grafana PDF");
        log.error("Type=TaskExecution  executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), workflowConfig.getWorkflowType(), "-", "-", 0, " ReportName :" + assessmentReportDTO.getReportName() + " Visualizationutil :" + assessmentReportDTO.getVisualizationutil() + "GrafanaPDFExecutionSubscriber Completed with error" + e.getMessage());
        throw new InsightsJobFailedException(e.getMessage());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) JsonObject(com.google.gson.JsonObject) InsightsAssessmentConfigurationDTO(com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO) BasePDFProcessor(com.cognizant.devops.platformreports.assessment.pdf.BasePDFProcessor) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Example 13 with InsightsJobFailedException

use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.

the class HyperLedgerExecutionSubscriber method handleTaskExecution.

@Override
public void handleTaskExecution(byte[] body) throws IOException {
    try {
        String incomingTaskMessage = new String(body, MQMessageConstants.MESSAGE_ENCODING);
        log.debug("Worlflow Detail ==== HyperLedgerExecutionSubscriber started ... " + "routing key  message handleDelivery ===== {} ", incomingTaskMessage);
        assessmentReportDTO = new InsightsAssessmentConfigurationDTO();
        assessmentReportDTO.setIncomingTaskMessageJson(incomingTaskMessage);
        JsonObject incomingTaskMessageJson = JsonUtils.parseStringAsJsonObject(incomingTaskMessage);
        String workflowId = incomingTaskMessageJson.get("workflowId").getAsString();
        workflowConfig = workflowDAL.getWorkflowConfigByWorkflowId(workflowId);
        log.debug("Worlflow Detail ==== scheduleType {} ", workflowConfig.getScheduleType());
        long startDate = 0;
        long endDate = 0;
        long startDateEpoch = 0;
        if (workflowConfig.getScheduleType().equals(WorkflowTaskEnum.WorkflowSchedule.ONETIME.name())) {
            startDate = workflowConfig.getAssessmentConfig().getStartDate();
            endDate = workflowConfig.getAssessmentConfig().getEndDate();
        } else {
            startDateEpoch = workflowConfig.getNextRun();
            startDate = InsightsUtils.getStartFromTime(startDateEpoch, workflowConfig.getScheduleType()) - 1;
            endDate = startDateEpoch;
        }
        log.debug("Worlflow Detail ==== startDate & endDate in Epoch {} {}", startDate, endDate);
        String ledgerStartDate = InsightsUtils.epochToDateFormat(startDate, "yyyy-MM-dd");
        String ledgerEndDate = InsightsUtils.epochToDateFormat(endDate, "yyyy-MM-dd");
        log.debug("Worlflow Detail ==== ledgerStartDate & ledgerEndDate {} {}", ledgerStartDate, ledgerEndDate);
        prepareAssestmentDTO(incomingTaskMessageJson);
        List<JsonObject> ledgerList = fetchLedgerRecords(ledgerStartDate, ledgerEndDate);
        assessmentReportDTO.setLedgerRecords(ledgerList);
        BasePDFProcessor chartHandler = ReportPDFVisualizationHandlerFactory.getChartHandler(assessmentReportDTO.getVisualizationutil());
        chartHandler.generatePDF(assessmentReportDTO);
        log.debug("Worlflow Detail ==== HyperLedgerExecutionSubscriber Completed  {} ", incomingTaskMessageJson);
    } catch (InsightsJobFailedException ijfe) {
        log.error("Worlflow Detail ==== HyperLedgerExecutionSubscriber Completed with error ", ijfe);
        statusLog = ijfe.getMessage();
        throw ijfe;
    } catch (Exception e) {
        log.error("Worlflow Detail ==== HyperLedgerExecutionSubscriber Completed with error ", e);
        throw new InsightsJobFailedException(e.getMessage());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) JsonObject(com.google.gson.JsonObject) InsightsAssessmentConfigurationDTO(com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO) BasePDFProcessor(com.cognizant.devops.platformreports.assessment.pdf.BasePDFProcessor) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Example 14 with InsightsJobFailedException

use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.

the class MileStoneExecutionSubscriber method handleTaskExecution.

@Override
public void handleTaskExecution(byte[] body) throws IOException {
    try {
        String incomingTaskMessage = new String(body, StandardCharsets.UTF_8);
        log.debug("Worlflow Detail ==== MileStoneExecutionSubscriber 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.setExecutionId(executionId);
        assessmentReportDTO.setWorkflowId(workflowId);
        MileStoneConfig mileStoneConfig = mileStoneConfigDAL.fetchMileStoneByWorkflowId(assessmentReportDTO.getWorkflowId());
        Long startDate = mileStoneConfig.getStartDate();
        if (startDate < Instant.now().getEpochSecond()) {
            mileStoneConfig.setStatus("IN_PROGRESS");
            mileStoneConfigDAL.updateMileStoneConfig(mileStoneConfig);
            List<JsonObject> listOfMilestoneJson = createToolBasedJson(mileStoneConfig);
            for (JsonObject milestone : listOfMilestoneJson) {
                publishMessageInMQ(milestone.get("queueName").getAsString(), milestone.toString());
            }
        }
    } catch (Exception e) {
        log.error("Worlflow Detail ==== MileStoneExecutionSubscriber Completed with error ", e);
        throw new InsightsJobFailedException(e.getMessage());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) JsonObject(com.google.gson.JsonObject) InsightsAssessmentConfigurationDTO(com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO) MileStoneConfig(com.cognizant.devops.platformdal.milestone.MileStoneConfig) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Example 15 with InsightsJobFailedException

use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.

the class PDFExecutionSubscriber method setPDFDetailsInEmailHistory.

private void setPDFDetailsInEmailHistory(JsonObject incomingTaskMessageJson) {
    try {
        long startTime = System.nanoTime();
        String workflowId = incomingTaskMessageJson.get(AssessmentReportAndWorkflowConstants.WORKFLOW_ID).getAsString();
        InsightsReportVisualizationContainer emailHistoryConfig = new InsightsReportVisualizationContainer();
        emailHistoryConfig.setExecutionId(assessmentReportDTO.getExecutionId());
        emailHistoryConfig.setMailAttachmentName(assessmentReportDTO.getAsseementreportname());
        File attachedFile = new File(assessmentReportDTO.getPdfExportedFilePath());
        if (attachedFile.exists()) {
            emailHistoryConfig.setAttachmentData(FileUtils.readFileToByteArray(attachedFile));
        } else {
            throw new InsightsJobFailedException("Worlflow Detail ==== Error setting PDF details in Email History table");
        }
        if (incomingTaskMessageJson.get("nextTaskId").getAsInt() == -1) {
            emailHistoryConfig.setStatus(WorkflowTaskEnum.WorkflowStatus.COMPLETED.name());
            emailHistoryConfig.setExecutionTime(InsightsUtils.getCurrentTimeInEpochMilliSeconds());
        } else {
            emailHistoryConfig.setStatus(WorkflowTaskEnum.EmailStatus.NOT_STARTED.name());
        }
        emailHistoryConfig.setWorkflowConfig(workflowId);
        workflowDAL.saveEmailExecutionHistory(emailHistoryConfig);
        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());
    } catch (Exception e) {
        log.error("Worlflow Detail ==== Error setting PDF details in Email History table");
        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() + "Error setting PDF details in Email History table" + e.getMessage());
        throw new InsightsJobFailedException("Worlflow Detail ==== Error setting PDF details in Email History table");
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsReportVisualizationContainer(com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer) File(java.io.File) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

InsightsJobFailedException (com.cognizant.devops.platformreports.exception.InsightsJobFailedException)63 IOException (java.io.IOException)31 JsonObject (com.google.gson.JsonObject)29 InsightsCustomException (com.cognizant.devops.platformcommons.exception.InsightsCustomException)21 ArrayList (java.util.ArrayList)16 File (java.io.File)14 JsonArray (com.google.gson.JsonArray)12 HashMap (java.util.HashMap)11 InsightsKPIResultDetails (com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails)8 List (java.util.List)8 InsightsContentDetail (com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)7 ReportEngineEnum (com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum)7 ExecutionException (java.util.concurrent.ExecutionException)7 ContentConfigDefinition (com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition)6 InsightsAssessmentConfigurationDTO (com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO)5 FileNotFoundException (java.io.FileNotFoundException)5 NoSuchFileException (java.nio.file.NoSuchFileException)5 Map (java.util.Map)5 InsightsContentConfig (com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig)4 InsightsReportVisualizationContainer (com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer)4