You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "EricJoy2048 (via GitHub)" <gi...@apache.org> on 2023/04/01 06:43:18 UTC
[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #4467: [Improve][Zeta] Improve JobMetrics fetch performance
EricJoy2048 commented on code in PR #4467:
URL: https://github.com/apache/incubator-seatunnel/pull/4467#discussion_r1155066711
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/master/JobMaster.java:
##########
@@ -449,53 +451,81 @@ public JobStatus getJobStatus() {
}
public List<RawJobMetrics> getCurrJobMetrics() {
- return getCurrJobMetrics(ownedSlotProfilesIMap.values());
+ return getCurrJobMetrics(
+ ownedSlotProfilesIMap.keySet().stream()
+ .filter(
+ pipelineLocation ->
+ pipelineLocation.getJobId()
+ == this.getJobImmutableInformation().getJobId())
+ .collect(Collectors.toList()));
+ }
+
+ public List<RawJobMetrics> getCurrJobMetrics(List<PipelineLocation> pipelineLocations) {
+ Map<TaskGroupLocation, Address> taskGroupLocationSlotProfileMap = new HashMap<>();
+
+ ownedSlotProfilesIMap.forEach(
+ (pipelineLocation, map) -> {
+ if (pipelineLocations.contains(pipelineLocation)) {
+ map.forEach(
+ (taskGroupLocation, slotProfile) -> {
+ if (taskGroupLocation.getJobId()
+ == this.getJobImmutableInformation().getJobId()) {
+ taskGroupLocationSlotProfileMap.put(
+ taskGroupLocation, slotProfile.getWorker());
+ }
+ });
+ }
+ });
+
+ Map<Address, List<TaskGroupLocation>> taskGroupLocationMap = new HashMap<>();
+
+ for (Map.Entry<TaskGroupLocation, Address> entry :
+ taskGroupLocationSlotProfileMap.entrySet()) {
+ taskGroupLocationMap
+ .computeIfAbsent(entry.getValue(), k -> new ArrayList<>())
+ .add(entry.getKey());
+ }
+
+ return getCurrJobMetrics(taskGroupLocationMap);
}
public List<RawJobMetrics> getCurrJobMetrics(
- Collection<Map<TaskGroupLocation, SlotProfile>> groupLocations) {
+ Map<Address, List<TaskGroupLocation>> groupLocationMap) {
List<RawJobMetrics> metrics = new ArrayList<>();
- for (Map<TaskGroupLocation, SlotProfile> groupLocation : groupLocations) {
- groupLocation.forEach(
- (taskGroupLocation, slotProfile) -> {
- if (taskGroupLocation.getJobId()
- == this.getJobImmutableInformation().getJobId()) {
- try {
- if (nodeEngine
- .getClusterService()
- .getMember(slotProfile.getWorker())
- != null) {
- RawJobMetrics rawJobMetrics =
- (RawJobMetrics)
- NodeEngineUtil.sendOperationToMemberNode(
- nodeEngine,
- new GetTaskGroupMetricsOperation(
- taskGroupLocation),
- slotProfile.getWorker())
- .get();
- metrics.add(rawJobMetrics);
- }
- }
- // HazelcastInstanceNotActiveException. It means that the node is
- // offline, so waiting for the taskGroup to restore can be successful
- catch (HazelcastInstanceNotActiveException e) {
- LOGGER.warning(
- String.format(
- "%s get current job metrics with exception: %s.",
- taskGroupLocation, ExceptionUtils.getMessage(e)));
- } catch (Exception e) {
- throw new SeaTunnelException(e.getMessage());
- }
+
+ groupLocationMap.forEach(
+ (address, taskGroupLocations) -> {
+ try {
+ if (nodeEngine.getClusterService().getMember(address) != null) {
+ RawJobMetrics rawJobMetrics =
+ (RawJobMetrics)
+ NodeEngineUtil.sendOperationToMemberNode(
+ nodeEngine,
+ new GetTaskGroupMetricsOperation(
+ taskGroupLocations),
+ address)
+ .get();
+ metrics.add(rawJobMetrics);
}
- });
- }
+ }
+ // HazelcastInstanceNotActiveException. It means that the node is
+ // offline, so waiting for the taskGroup to restore can be successful
+ catch (HazelcastInstanceNotActiveException e) {
+ LOGGER.warning(
+ String.format(
+ "%s get current job metrics with exception: %s.",
+ Arrays.toString(taskGroupLocations.toArray()),
+ ExceptionUtils.getMessage(e)));
+ } catch (Exception e) {
+ throw new SeaTunnelException(e.getMessage());
Review Comment:
```suggestion
throw new SeaTunnelEngineException(e.getMessage());
```
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/operation/GetTaskGroupMetricsOperation.java:
##########
@@ -56,27 +59,34 @@ public void run() {
"Caller "
+ callerAddress
+ " cannot get taskGroupLocation metrics"
- + taskGroupLocation.toString()
+ + Arrays.toString(taskGroupLocations.toArray())
Review Comment:
`Arrays.toString(taskGroupLocations.toArray())` have a same result as `taskGroupLocations.toString()`.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org