Hisoka-X commented on code in PR #6883:
URL: https://github.com/apache/seatunnel/pull/6883#discussion_r1620498446
##########
seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java:
##########
@@ -39,7 +39,7 @@ public static void main(String[] args)
clientCommandArgs.setJobName(Paths.get(configFile).getFileName().toString());
// Change Execution Mode to CLUSTER to use client mode, before do
this, you should start
// SeaTunnelEngineServerExample
- clientCommandArgs.setMasterType(MasterType.LOCAL);
+ clientCommandArgs.setMasterType(MasterType.CLUSTER);
Review Comment:
```suggestion
clientCommandArgs.setMasterType(MasterType.LOCAL);
```
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/AbstractResourceManager.java:
##########
@@ -223,4 +223,16 @@ public List<SlotProfile> getUnassignedSlots() {
.flatMap(workerProfile ->
Arrays.stream(workerProfile.getUnassignedSlots()))
.collect(Collectors.toList());
}
+
+ @Override
+ public List<SlotProfile> getAssignedSlots() {
+ return registerWorker.values().stream()
+ .flatMap(workerProfile ->
Arrays.stream(workerProfile.getAssignedSlots()))
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public int workCount() {
Review Comment:
```suggestion
public int workerCount() {
```
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/opeartion/GetOverviewOperation.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.engine.server.resourcemanager.opeartion;
+
+import org.apache.seatunnel.engine.common.Constant;
+import org.apache.seatunnel.engine.core.job.JobStatus;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.master.JobHistoryService.JobState;
+import org.apache.seatunnel.engine.server.resourcemanager.ResourceManager;
+import
org.apache.seatunnel.engine.server.resourcemanager.resource.OverviewInfo;
+import org.apache.seatunnel.engine.server.resourcemanager.resource.SlotProfile;
+import
org.apache.seatunnel.engine.server.serializable.ResourceDataSerializerHook;
+
+import com.hazelcast.map.IMap;
+import com.hazelcast.nio.serialization.IdentifiedDataSerializable;
+import com.hazelcast.spi.impl.operationservice.Operation;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.List;
+
+@Slf4j
+public class GetOverviewOperation extends Operation implements
IdentifiedDataSerializable {
+
+ private final OverviewInfo overviewInfo = new OverviewInfo();
+
+ @Override
+ public void run() throws Exception {
+ SeaTunnelServer server = getService();
+ ResourceManager resourceManager =
server.getCoordinatorService().getResourceManager();
+
+ List<SlotProfile> assignedSlots = resourceManager.getAssignedSlots();
+
+ List<SlotProfile> unassignedSlots =
resourceManager.getUnassignedSlots();
+ IMap<Long, JobState> finishedJob =
+
getNodeEngine().getHazelcastInstance().getMap(Constant.IMAP_FINISHED_JOB_STATE);
+ overviewInfo.setTotalSlot(assignedSlots.size() +
unassignedSlots.size());
+ overviewInfo.setUnassignedSlot(unassignedSlots.size());
+ overviewInfo.setRunningJobs(
+ getNodeEngine()
+ .getHazelcastInstance()
+ .getMap(Constant.IMAP_RUNNING_JOB_INFO)
+ .size());
+ overviewInfo.setFailedJobs(
+ finishedJob.values().stream()
+ .filter(
+ jobState ->
+ jobState.getJobStatus()
+ .name()
+
.equals(JobStatus.FAILED.toString()))
+ .count());
+ overviewInfo.setCancelledJobs(
+ finishedJob.values().stream()
+ .filter(
+ jobState ->
+ jobState.getJobStatus()
+ .name()
+
.equals(JobStatus.CANCELED.toString()))
+ .count());
+ overviewInfo.setWorks(resourceManager.workCount());
+ overviewInfo.setFinishedJobs(
+ finishedJob.values().stream()
Review Comment:
I find this part show up twice. Please do some refactor.
--
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]