Skip to content

Commit

Permalink
MINOR: DI APP Support Partial Success
Browse files Browse the repository at this point in the history
  • Loading branch information
ulixius9 committed Sep 26, 2024
1 parent d264495 commit 840f06c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private WorkflowStats processWebAnalytics() {
try {
workflow.process();
} catch (SearchIndexException ex) {
jobData.setStatus(EventPublisherJob.Status.FAILED);
jobData.setStatus(EventPublisherJob.Status.RUNNING);
jobData.setFailure(ex.getIndexingError());
}

Expand All @@ -252,7 +252,7 @@ private WorkflowStats processCostAnalysis() {
try {
workflow.process();
} catch (SearchIndexException ex) {
jobData.setStatus(EventPublisherJob.Status.FAILED);
jobData.setStatus(EventPublisherJob.Status.RUNNING);
jobData.setFailure(ex.getIndexingError());
}

Expand All @@ -268,7 +268,7 @@ private WorkflowStats processDataAssets() {
try {
workflow.process();
} catch (SearchIndexException ex) {
jobData.setStatus(EventPublisherJob.Status.FAILED);
jobData.setStatus(EventPublisherJob.Status.RUNNING);
jobData.setFailure(ex.getIndexingError());
}

Expand All @@ -282,13 +282,32 @@ private void updateJobStatsWithWorkflowStats(WorkflowStats workflowStats) {
updateStats(stepName, stats);
}
}
private boolean isPartialSuccess(){
try{
if (jobData.getStats() != null && jobData.getStats().getJobStats() != null){
float failure = jobData.getStats().getJobStats().getFailedRecords();
float success = jobData.getStats().getJobStats().getSuccessRecords();
// if success % is >= 90%
if (success/(success+failure) >= 0.9) return true;
}
}
catch (ArithmeticException ex){
// ignore in case there are 0 success and failures
}
return false;
}

private void updateJobStatus() {
if (stopped) {
jobData.setStatus(EventPublisherJob.Status.STOPPED);
} else {
if (jobData.getFailure() != null) {
jobData.setStatus(EventPublisherJob.Status.FAILED);
if (isPartialSuccess()){
jobData.setStatus(EventPublisherJob.Status.PARTIAL_SUCCESS);
}
else {
jobData.setStatus(EventPublisherJob.Status.FAILED);
}
} else {
jobData.setStatus(EventPublisherJob.Status.COMPLETED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"active",
"activeError",
"stopped",
"success"
"success",
"partialSuccess"
]
},
"runType": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"active",
"activeError",
"stopped",
"success"
"success",
"partialSuccess"
]
},
"failure": {
Expand Down

0 comments on commit 840f06c

Please sign in to comment.