dybyte commented on code in PR #10078:
URL: https://github.com/apache/seatunnel/pull/10078#discussion_r2541470297
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CoordinatorService.java:
##########
@@ -1074,6 +1091,72 @@ public ConnectorPackageService
getConnectorPackageService() {
return connectorPackageService;
}
+ public PendingJobsResponse getPendingJobs(Map<String, String> tags, Long
jobId, int limit) {
+ Collection<PendingJobInfo> allPendingJobs =
+ new ArrayList<>(pendingJobQueue.getJobIdMap().values());
+
+ List<PendingJobInfo> selectedJobs = new ArrayList<>();
+ if (jobId != null) {
+ PendingJobInfo pendingJobInfo = pendingJobQueue.getById(jobId);
+ if (pendingJobInfo != null) {
+ selectedJobs.add(pendingJobInfo);
+ }
+ } else {
+ selectedJobs.addAll(allPendingJobs);
+
selectedJobs.sort(Comparator.comparingLong(PendingJobInfo::getEnqueueTimestamp));
+ if (limit > 0 && selectedJobs.size() > limit) {
+ selectedJobs = new ArrayList<>(selectedJobs.subList(0, limit));
+ }
+ }
+
+ ResourceManager resourceManager = getResourceManager();
+ List<PendingJobDiagnostic> diagnostics = new ArrayList<>();
+ for (PendingJobInfo jobInfo : selectedJobs) {
+ PendingJobDiagnostic diagnostic = jobInfo.getLastSnapshot();
+ if (diagnostic == null) {
+ diagnostic =
+ PendingDiagnosticsCollector.collectJobDiagnostic(
+ jobInfo, tags, resourceManager);
+ if (diagnostic != null) {
+ diagnostic.setCheckCount(jobInfo.getCheckTimes());
+ }
+ }
+ if (diagnostic != null) {
+ diagnostics.add(diagnostic);
+ }
+ }
+
+ PendingJobsResponse response = new PendingJobsResponse();
+ response.setPendingJobs(diagnostics);
+ response.setClusterSnapshot(
+
PendingDiagnosticsCollector.collectClusterSnapshot(resourceManager, tags));
+ response.setQueueSummary(buildQueueSummary(allPendingJobs,
diagnostics));
+ return response;
+ }
+
+ private PendingQueueSummary buildQueueSummary(
+ Collection<PendingJobInfo> pendingJobs, List<PendingJobDiagnostic>
diagnostics) {
+ PendingQueueSummary summary = new PendingQueueSummary();
+ summary.setSize(pendingJobQueue.size());
+ summary.setScheduleStrategy(scheduleStrategy.name());
+ summary.setLackingTaskGroups(
+
diagnostics.stream().mapToInt(PendingJobDiagnostic::getLackingTaskGroups).sum());
Review Comment:
I think `lackingTaskGroups` could use a more detailed description in the
documentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]