Skip to content

BIGTOP-4464: Optimize cluster/host metrics structure#240

Merged
lhpqaq merged 6 commits intoapache:mainfrom
kevinw66:bigtop-4464
Jul 11, 2025
Merged

BIGTOP-4464: Optimize cluster/host metrics structure#240
lhpqaq merged 6 commits intoapache:mainfrom
kevinw66:bigtop-4464

Conversation

@kevinw66
Copy link
Copy Markdown
Contributor

@kevinw66 kevinw66 commented Jul 9, 2025

No description provided.

@kevinw66 kevinw66 changed the title BIGTOP-4464: Add timestamp info to cluster/host range metrics BIGTOP-4464: Optimize cluster/host metrics structure Jul 9, 2025
@kevinw66 kevinw66 marked this pull request as draft July 10, 2025 14:23
@kevinw66 kevinw66 marked this pull request as ready for review July 11, 2025 14:55
@lhpqaq lhpqaq requested a review from Copilot July 11, 2025 15:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the metrics subsystem to use strongly-typed VO classes instead of raw JsonNode, updates related controllers, services, and tests, and optimizes cluster service to include a service count.

  • Switch metrics endpoints and service/DAO layers from JsonNode to HostMetricsVO and ClusterMetricsVO.
  • Replace old ProxyUtils-based JSON handling with a new PrometheusProxy under server/prometheus using PrometheusResponse/PrometheusResult.
  • Add countByClusterId to ServiceDao/mapper and update ClusterServiceImpl to set totalService; adjust mappers to remove outdated service joins.

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
bigtop-manager-server/src/test/java/org/apache/bigtop/manager/server/utils/ProxyUtilsTest.java Removed legacy JSON-based tests for ProxyUtils
bigtop-manager-server/src/test/java/org/apache/bigtop/manager/server/service/ClusterServiceTest.java Replaced RepoDao mock with ServiceDao and test totalService logic
bigtop-manager-server/src/test/java/org/apache/bigtop/manager/server/controller/MetricsControllerTest.java Updated tests to use HostMetricsVO and ClusterMetricsVO
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/ProxyUtils.java Deleted obsolete ProxyUtils
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/MetricsServiceImpl.java Changed return types to VO and removed JsonNode handling
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ClusterServiceImpl.java Added service count via ServiceDao, set totalService
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/MetricsService.java Updated interface methods to return VO types
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/proxy/PrometheusProxy.java Removed old proxy and migrated references to new package
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/prometheus/PrometheusResult.java Added new result model
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/prometheus/PrometheusResponse.java Added new response model
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/prometheus/PrometheusData.java Added new data model
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/prometheus/PrometheusProxy.java Introduced new PrometheusProxy implementation
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/HostMetricsVO.java Added HostMetricsVO
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/vo/ClusterMetricsVO.java Added ClusterMetricsVO
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/req/command/ServiceCommandReq.java Removed @NotNull from installed to adjust validation
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/MetricsController.java Updated endpoints to return VO and adjusted mappings
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/helper/ComponentStageHelper.java Modified INIT and PREPARE to use only the first hostname
bigtop-manager-dao/src/main/resources/mapper/postgresql/ServiceMapper.xml Added countByClusterId select
bigtop-manager-dao/src/main/resources/mapper/postgresql/ClusterMapper.xml Removed service join and total_service
bigtop-manager-dao/src/main/resources/mapper/mysql/ServiceMapper.xml Added countByClusterId select
bigtop-manager-dao/src/main/resources/mapper/mysql/ClusterMapper.xml Removed service join and total_service
bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/ServiceDao.java Declared countByClusterId method
bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/grpc/interceptor/TaskInterceptor.java Added taskRequest flag to minimize MDC/cache leakage
Comments suppressed due to low confidence (2)

bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/model/req/command/ServiceCommandReq.java:40

  • [nitpick] Removing @NotNull from the installed field disables null-check validation for a required parameter; consider retaining a constraint or handling null explicitly to prevent null pointer errors.
    private Boolean installed;

bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/prometheus/PrometheusProxy.java:44

  • [nitpick] Consider adding unit tests for timestamp cache behavior, HTTP response parsing, and VO conversion in PrometheusProxy to ensure metrics are parsed and formatted correctly.
public class PrometheusProxy {

Comment on lines +102 to +108
stageContext = createStageContext(componentName, List.of(hostnames.get(0)), commandDTO);
stages.add(new ComponentInitStage(stageContext));
break;
case PREPARE:
// Prepare phase runs after component started, client component shouldn't create this.
if (!StackUtils.isClientComponent(componentName)) {
stageContext = createStageContext(componentName, hostnames, commandDTO);
stageContext = createStageContext(componentName, List.of(hostnames.get(0)), commandDTO);
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

Restricting INIT and PREPARE stages to only the first hostname may skip running stages on other hosts; consider passing the full hostnames list or explicitly documenting that change.

Copilot uses AI. Check for mistakes.
@lhpqaq lhpqaq merged commit 2b1da68 into apache:main Jul 11, 2025
11 checks passed
@kevinw66 kevinw66 deleted the bigtop-4464 branch July 11, 2025 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants