use of com.cognizant.devops.platformdal.workflow.InsightsWorkflowExecutionHistory in project Insights by CognizantOneDevOps.
the class WorkflowTest method testStatusUpdateWith2Task.
@Test(priority = 6)
public void testStatusUpdateWith2Task() {
try {
InsightsWorkflowConfiguration workflowConfig = workflowDAL.getWorkflowConfigByWorkflowId(WorkflowIdWith2Task);
Assert.assertEquals(workflowConfig.getStatus(), "ERROR");
int task1 = getTaskId(mqChannel);
List<InsightsWorkflowExecutionHistory> executionHistory = workflowDAL.getWorkflowExecutionHistoryRecordsByWorkflowId(WorkflowIdWith2Task);
if (executionHistory.size() > 0) {
for (InsightsWorkflowExecutionHistory eachExecutionRecord : executionHistory) {
if (eachExecutionRecord.getCurrenttask() == task1) {
Assert.assertEquals(eachExecutionRecord.getTaskStatus(), "COMPLETED");
} else {
Assert.assertEquals(eachExecutionRecord.getTaskStatus(), "ERROR");
}
}
}
} catch (AssertionError e) {
Assert.fail(e.getMessage());
}
}
use of com.cognizant.devops.platformdal.workflow.InsightsWorkflowExecutionHistory in project Insights by CognizantOneDevOps.
the class WorkflowTest method testWorkflowRetryCount.
@Test(priority = 7)
public void testWorkflowRetryCount() throws InterruptedException {
try {
WorkflowRetryExecutor retryExecutor = new WorkflowRetryExecutor();
retryExecutor.retryWorkflows();
Thread.sleep(1000);
List<InsightsWorkflowExecutionHistory> executionHistory = workflowDAL.getWorkflowExecutionHistoryRecordsByWorkflowId(failWorkflowId);
if (executionHistory.size() > 0) {
for (InsightsWorkflowExecutionHistory eachExecutionRecord : executionHistory) {
Assert.assertTrue(eachExecutionRecord.getRetryCount() > 0);
Assert.assertEquals(eachExecutionRecord.getTaskStatus(), "ERROR");
}
}
} catch (AssertionError e) {
Assert.fail(e.getMessage());
}
}
use of com.cognizant.devops.platformdal.workflow.InsightsWorkflowExecutionHistory in project Insights by CognizantOneDevOps.
the class WorkflowServiceTestData method updateWorkflowExecutionHistory.
public int updateWorkflowExecutionHistory(String workflowId, int taskId) {
InsightsWorkflowConfiguration workflowConfig = workflowConfigDAL.getWorkflowConfigByWorkflowId(workflowId);
InsightsWorkflowExecutionHistory historyConfig = new InsightsWorkflowExecutionHistory();
historyConfig.setCurrenttask(taskId);
historyConfig.setExecutionId(System.currentTimeMillis());
historyConfig.setWorkflowConfig(workflowConfig);
historyConfig.setTaskStatus(WorkflowTaskEnum.WorkflowStatus.NOT_STARTED.toString());
historyConfig.setStatusLog("Testing");
int historyId = workflowConfigDAL.saveTaskworkflowExecutionHistory(historyConfig);
return historyId;
}
use of com.cognizant.devops.platformdal.workflow.InsightsWorkflowExecutionHistory in project Insights by CognizantOneDevOps.
the class WorkflowRetryExecutor method retryWorkflowWithCompletedTask.
/**
* Gell all rerty record if Workflow in error state and atleast one of the tasks
* is completed and none is in error state
*/
private void retryWorkflowWithCompletedTask() {
log.debug(" Worlflow Detail ==== Inside WorkflowRetryExecutor retryWorkflowWithCompletedTask ");
List<InsightsWorkflowExecutionHistory> readyToRunWorkflowHistory = workflowProcessing.getNextTasksForRetry();
for (InsightsWorkflowExecutionHistory lastCompletedTaskExecution : readyToRunWorkflowHistory) {
long startTime = System.nanoTime();
JsonObject mqRetryJsonObject = JsonUtils.parseStringAsJsonObject(lastCompletedTaskExecution.getRequestMessage());
mqRetryJsonObject.addProperty("exectionHistoryId", lastCompletedTaskExecution.getId());
String message = new Gson().toJson(mqRetryJsonObject);
Map<String, Object> requestMessage = WorkflowUtils.convertJsonObjectToMap(message);
log.debug(" Worlflow Detail ==== Inside WorkflowRetryExecutor retryWorkflowWithCompletedTask Retry flow workflowHistory {} ", lastCompletedTaskExecution);
try {
workflowProcessing.publishMessageToNextInMQ(requestMessage);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=WorkFlow ExecutionId={} WorkflowId={} WorkflowType={} TaskDescription={} TaskMQChannel={} status ={} LastRunTime ={} NextRunTime ={} Schedule ={} TaskRetryCount={} RetryType ={} isTaskRetry={} processingTime={} message={}", lastCompletedTaskExecution.getExecutionId(), lastCompletedTaskExecution.getWorkflowConfig().getWorkflowId(), lastCompletedTaskExecution.getWorkflowConfig().getWorkflowType(), "-", "-", lastCompletedTaskExecution.getTaskStatus(), lastCompletedTaskExecution.getWorkflowConfig().getLastRun(), "-", lastCompletedTaskExecution.getWorkflowConfig().getScheduleType(), lastCompletedTaskExecution.getRetryCount(), "-", "WorkflowWithCompletedTask", processingTime, "-");
log.debug(StringExpressionConstants.STR_EXP_WORKFLOW_4 + StringExpressionConstants.STR_EXP_TASKRETRYCOUNT, lastCompletedTaskExecution.getExecutionId(), lastCompletedTaskExecution.getWorkflowConfig().getWorkflowId(), lastCompletedTaskExecution.getWorkflowConfig().getLastRun(), lastCompletedTaskExecution.getWorkflowConfig().getNextRun(), lastCompletedTaskExecution.getWorkflowConfig().getScheduleType(), mqRetryJsonObject.get(WorkflowUtils.RETRY_JSON_PROPERTY).getAsString(), lastCompletedTaskExecution.getRetryCount(), "-", "-", lastCompletedTaskExecution.getWorkflowConfig().getWorkflowType(), processingTime, lastCompletedTaskExecution.getTaskStatus(), "Inside WorkflowRetryExecutor retryWorkflowWithCompletedTask Retry flow workflowHistory");
} catch (WorkflowTaskInitializationException e) {
log.error(" Worlflow Detail ==== workflow failed to retry and will be picked up in next retry schedule {} ", lastCompletedTaskExecution);
log.error(StringExpressionConstants.STR_EXP_WORKFLOW_4 + StringExpressionConstants.STR_EXP_TASKRETRYCOUNT, lastCompletedTaskExecution.getExecutionId(), lastCompletedTaskExecution.getWorkflowConfig().getWorkflowId(), lastCompletedTaskExecution.getWorkflowConfig().getLastRun(), lastCompletedTaskExecution.getWorkflowConfig().getNextRun(), lastCompletedTaskExecution.getWorkflowConfig().getScheduleType(), mqRetryJsonObject.get(WorkflowUtils.RETRY_JSON_PROPERTY).getAsString(), lastCompletedTaskExecution.getRetryCount(), "-", "-", lastCompletedTaskExecution.getWorkflowConfig().getWorkflowType(), 0, lastCompletedTaskExecution.getTaskStatus(), "In WorkflowRetryExecutor,retryWorkflowWithCompletedTask failed due to exception.");
InsightsStatusProvider.getInstance().createInsightStatusNode("In WorkflowRetryExecutor,retryWorkflowWithCompletedTask failed due to exception. Last completed execution: " + lastCompletedTaskExecution, PlatformServiceConstants.FAILURE);
}
}
}
use of com.cognizant.devops.platformdal.workflow.InsightsWorkflowExecutionHistory in project Insights by CognizantOneDevOps.
the class GrafanaDashboardPdfConfigDAL method deleteGrafanaDashboardConfig.
public void deleteGrafanaDashboardConfig(GrafanaDashboardPdfConfig grafanaDashboardPdfConfig) {
try {
Map<String, Object> parameters = new HashMap<>();
parameters.put("workflowId", grafanaDashboardPdfConfig.getWorkflowConfig().getWorkflowId());
List<InsightsWorkflowExecutionHistory> executionRecord = getResultList("FROM InsightsWorkflowExecutionHistory a WHERE a.workflowConfig.workflowId= :workflowId", InsightsWorkflowExecutionHistory.class, parameters);
for (InsightsWorkflowExecutionHistory history : executionRecord) {
delete(history);
}
delete(grafanaDashboardPdfConfig);
} catch (Exception e) {
log.error(e.getMessage());
throw e;
}
}
Aggregations