Search in sources :

Example 1 with InsightsAssessmentConfigurationDTO

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO 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 2 with InsightsAssessmentConfigurationDTO

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO 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 3 with InsightsAssessmentConfigurationDTO

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO 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 4 with InsightsAssessmentConfigurationDTO

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO 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());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) JsonObject(com.google.gson.JsonObject) InsightsAssessmentConfigurationDTO(com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 5 with InsightsAssessmentConfigurationDTO

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO 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());
    }
}
Also used : BaseDataProcessor(com.cognizant.devops.platformreports.assessment.dataprocess.BaseDataProcessor) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) JsonObject(com.google.gson.JsonObject) InsightsAssessmentConfigurationDTO(com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Aggregations

InsightsAssessmentConfigurationDTO (com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO)5 InsightsJobFailedException (com.cognizant.devops.platformreports.exception.InsightsJobFailedException)5 JsonObject (com.google.gson.JsonObject)5 IOException (java.io.IOException)5 InsightsCustomException (com.cognizant.devops.platformcommons.exception.InsightsCustomException)4 TimeoutException (java.util.concurrent.TimeoutException)3 BasePDFProcessor (com.cognizant.devops.platformreports.assessment.pdf.BasePDFProcessor)2 MileStoneConfig (com.cognizant.devops.platformdal.milestone.MileStoneConfig)1 BaseDataProcessor (com.cognizant.devops.platformreports.assessment.dataprocess.BaseDataProcessor)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 ExecutionException (java.util.concurrent.ExecutionException)1