Skip to content

Commit

Permalink
Refactor TransmissionJobManager (#29265)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Dec 2, 2023
1 parent ffeb87f commit bdfd897
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,22 @@ public Collection<TransmissionJobItemInfo> getJobItemInfos(final String jobId) {
result.add(new TransmissionJobItemInfo(shardingItem, jobInfo.getTableName(), null, startTimeMillis, 0, errorMessage));
continue;
}
int inventoryFinishedPercentage = 0;
if (JobStatus.EXECUTE_INCREMENTAL_TASK == jobItemProgress.getStatus() || JobStatus.FINISHED == jobItemProgress.getStatus()) {
inventoryFinishedPercentage = 100;
} else if (0 != jobItemProgress.getProcessedRecordsCount() && 0 != jobItemProgress.getInventoryRecordsCount()) {
inventoryFinishedPercentage = (int) Math.min(100, jobItemProgress.getProcessedRecordsCount() * 100 / jobItemProgress.getInventoryRecordsCount());
}
int inventoryFinishedPercentage = getInventoryFinishedPercentage(jobItemProgress);
result.add(new TransmissionJobItemInfo(shardingItem, jobInfo.getTableName(), jobItemProgress, startTimeMillis, inventoryFinishedPercentage, errorMessage));
}
return result;
}

private static int getInventoryFinishedPercentage(final TransmissionJobItemProgress jobItemProgress) {
if (JobStatus.EXECUTE_INCREMENTAL_TASK == jobItemProgress.getStatus() || JobStatus.FINISHED == jobItemProgress.getStatus()) {
return 100;
}
if (0 != jobItemProgress.getProcessedRecordsCount() && 0 != jobItemProgress.getInventoryRecordsCount()) {
return (int) Math.min(100, jobItemProgress.getProcessedRecordsCount() * 100 / jobItemProgress.getInventoryRecordsCount());
}
return 0;
}

/**
* Get job progress.
*
Expand Down

0 comments on commit bdfd897

Please sign in to comment.