Skip to content
1 change: 1 addition & 0 deletions docs/en/seatunnel-engine/rest-api-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Please refer [security](security.md)
"unassignedSlot":"0",
"works":"1",
"runningJobs":"0",
"pendingJobs":"0",
"finishedJobs":"0",
"failedJobs":"0",
"cancelledJobs":"0"
Expand Down
1 change: 1 addition & 0 deletions docs/zh/seatunnel-engine/rest-api-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ seatunnel:
"unassignedSlot":"0",
"works":"1",
"runningJobs":"0",
"pendingJobs":"0",
"finishedJobs":"0",
"failedJobs":"0",
"cancelledJobs":"0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,8 @@ public void testOverview() {
.statusCode(200)
.body("projectVersion", notNullValue())
.body("totalSlot", equalTo("40"))
.body("workers", equalTo("2"));
.body("workers", equalTo("2"))
.body("pendingJobs", notNullValue());
given().get(
HOST
+ value
Expand All @@ -680,7 +681,8 @@ public void testOverview() {
.statusCode(200)
.body("projectVersion", notNullValue())
.body("totalSlot", equalTo("40"))
.body("workers", equalTo("2"));
.body("workers", equalTo("2"))
.body("pendingJobs", notNullValue());
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public static OverviewInfo getOverviewInfo(
overviewInfo.setTotalSlot(assignedSlots.size() + unassignedSlots.size());
overviewInfo.setUnassignedSlot(unassignedSlots.size());
overviewInfo.setWorkers(resourceManager.workerCount(tags));
overviewInfo.setPendingJobs(
server.getCoordinatorService().getJobCountMetrics().getPendingJobCount());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about creating a method in CoordinatorService that directly returns only the pendingJobCount instead of using the getJobCountMetrics method?

Copy link
Member

@Hisoka-X Hisoka-X Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the constructor method of the JobHistoryService
jobHistoryService =
                new JobHistoryService(
                        nodeEngine,
                        runningJobStateIMap,
                        logger,
                        pendingJobQueue.getJobIdMap(),
                        runningJobMasterMap,
                        nodeEngine.getHazelcastInstance().getMap(Constant.IMAP_FINISHED_JOB_STATE),
                        nodeEngine
                                .getHazelcastInstance()
                                .getMap(Constant.IMAP_FINISHED_JOB_METRICS),
                        nodeEngine
                                .getHazelcastInstance()
                                .getMap(Constant.IMAP_FINISHED_JOB_VERTEX_INFO),
                        engineConfig.getHistoryJobExpireMinutes());
  • the getJobStatusData method of JobHistoryService
public List<JobStatusData> getJobStatusData() {
        List<JobStatusData> status = new ArrayList<>();
        final List<JobState> runningJobStateList =
                runningJobMasterMap.values().stream()
                        .map(master -> toJobStateMapper(master, true))
                        .collect(Collectors.toList());
        Set<Long> runningJonIds =
                runningJobStateList.stream().map(JobState::getJobId).collect(Collectors.toSet());

        List<JobState> pendingJobStateList =
                pendingJobInfoMap.entrySet().stream()
                        .map(
                                entry -> {
                                    Long jobId = entry.getKey();
                                    JobImmutableInformation jobImmutableInformation =
                                            entry.getValue()
                                                    .getJobMaster()
                                                    .getJobImmutableInformation();
                                    return new JobState(
                                            jobId,
                                            jobImmutableInformation.getJobName(),
                                            JobStatus.PENDING,
                                            jobImmutableInformation.getCreateTime(),
                                            null,
                                            null,
                                            null,
                                            null);
                                })
                        .collect(Collectors.toList());
....

jobIdMap has been assigned to pendingJobInfoMap of the JobHistoryService

Copy link
Contributor

@dybyte dybyte Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, the getJobStatusData() and getJobCountMetrics() methods perform a lot of extra work that isn’t needed if we only want to get the pendingJobCount.

overviewInfo.setRunningJobs(
nodeEngine.getHazelcastInstance().getMap(Constant.IMAP_RUNNING_JOB_INFO).size());
overviewInfo.setFailedJobs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class OverviewInfo implements Serializable {
private String gitCommitAbbrev;
private int totalSlot;
private int unassignedSlot;
private long pendingJobs;
private long runningJobs;
private long finishedJobs;
private long failedJobs;
Expand Down