zhangshenghang commented on code in PR #8233:
URL: https://github.com/apache/seatunnel/pull/8233#discussion_r1875853647


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/ResourceRequestHandler.java:
##########
@@ -222,7 +250,53 @@ public Optional<WorkerProfile> 
preCheckWorkerResource(ResourceProfile r) {
                                                         slot ->
                                                                 
slot.getResourceProfile()
                                                                         
.enoughThan(r)))
-                        .findAny();
+                        .collect(Collectors.toList());
+
+        Optional<WorkerProfile> workerProfile;
+        switch (allocateStrategy) {
+            case SYSTEM_LOAD:
+                workerProfile =
+                        availableWorkers.stream()
+                                .max(
+                                        Comparator.comparingDouble(
+                                                w -> calculateWeight(w, 
workerAssignedSlots)));
+                workerProfile.ifPresent(
+                        profile -> {
+                            workerAssignedSlots.merge(
+                                    profile.getAddress(),
+                                    new ImmutableTriple<>(
+                                            0.0, 1, 
profile.getAssignedSlots().length),
+                                    (oldVal, newVal) ->
+                                            new ImmutableTriple<>(
+                                                    oldVal.left, oldVal.middle 
+ 1, oldVal.right));
+
+                            LOGGER.fine("Selected worker: " + 
profile.getAddress());
+                        });
+                break;
+            case RANDOM:
+                // Randomly obtain a worker
+                Collections.shuffle(availableWorkers);
+                Collections.shuffle(workerProfiles);
+                workerProfile = availableWorkers.stream().findFirst();
+                break;
+            default:
+                // The slot usage rate strategy is used by default. The lower 
the slot usage rate,
+                // the higher the priority.

Review Comment:
   Already modified



-- 
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]

Reply via email to