|
5 | 5 | import com.xiaojukeji.know.streaming.km.biz.cluster.MultiClusterPhyManager; |
6 | 6 | import com.xiaojukeji.know.streaming.km.common.bean.dto.metrices.MetricDTO; |
7 | 7 | import com.xiaojukeji.know.streaming.km.common.bean.dto.metrices.MetricsClusterPhyDTO; |
| 8 | +import com.xiaojukeji.know.streaming.km.common.bean.entity.cluster.ClusterPhysHealthState; |
8 | 9 | import com.xiaojukeji.know.streaming.km.common.bean.entity.cluster.ClusterPhysState; |
9 | 10 | import com.xiaojukeji.know.streaming.km.common.bean.entity.cluster.ClusterPhy; |
10 | 11 | import com.xiaojukeji.know.streaming.km.common.bean.dto.cluster.MultiClusterDashboardDTO; |
|
16 | 17 | import com.xiaojukeji.know.streaming.km.common.bean.vo.metrics.line.MetricMultiLinesVO; |
17 | 18 | import com.xiaojukeji.know.streaming.km.common.constant.Constant; |
18 | 19 | import com.xiaojukeji.know.streaming.km.common.converter.ClusterVOConverter; |
| 20 | +import com.xiaojukeji.know.streaming.km.common.enums.health.HealthStateEnum; |
19 | 21 | import com.xiaojukeji.know.streaming.km.common.utils.ConvertUtil; |
20 | 22 | import com.xiaojukeji.know.streaming.km.common.utils.PaginationUtil; |
21 | 23 | import com.xiaojukeji.know.streaming.km.common.utils.PaginationMetricsUtil; |
@@ -75,6 +77,32 @@ public ClusterPhysState getClusterPhysState() { |
75 | 77 | return physState; |
76 | 78 | } |
77 | 79 |
|
| 80 | + @Override |
| 81 | + public ClusterPhysHealthState getClusterPhysHealthState() { |
| 82 | + List<ClusterPhy> clusterPhyList = clusterPhyService.listAllClusters(); |
| 83 | + |
| 84 | + ClusterPhysHealthState physState = new ClusterPhysHealthState(clusterPhyList.size()); |
| 85 | + for (ClusterPhy clusterPhy: clusterPhyList) { |
| 86 | + ClusterMetrics metrics = clusterMetricService.getLatestMetricsFromCache(clusterPhy.getId()); |
| 87 | + Integer state = metrics.getMetric(ClusterMetricVersionItems.CLUSTER_METRIC_HEALTH_STATE).intValue(); |
| 88 | + if (state == null) { |
| 89 | + physState.setUnknownCount(physState.getUnknownCount() + 1); |
| 90 | + } else if (state.equals(HealthStateEnum.GOOD.getDimension())) { |
| 91 | + physState.setGoodCount(physState.getGoodCount() + 1); |
| 92 | + } else if (state.equals(HealthStateEnum.MEDIUM.getDimension())) { |
| 93 | + physState.setMediumCount(physState.getMediumCount() + 1); |
| 94 | + } else if (state.equals(HealthStateEnum.POOR.getDimension())) { |
| 95 | + physState.setPoorCount(physState.getPoorCount() + 1); |
| 96 | + } else if (state.equals(HealthStateEnum.DEAD.getDimension())) { |
| 97 | + physState.setDeadCount(physState.getDeadCount() + 1); |
| 98 | + } else { |
| 99 | + physState.setUnknownCount(physState.getUnknownCount() + 1); |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + return physState; |
| 104 | + } |
| 105 | + |
78 | 106 | @Override |
79 | 107 | public PaginationResult<ClusterPhyDashboardVO> getClusterPhysDashboard(MultiClusterDashboardDTO dto) { |
80 | 108 | // 获取集群 |
@@ -148,16 +176,7 @@ private PaginationResult<ClusterMetrics> getAndPagingClusterWithLatestMetricsFro |
148 | 176 | // 获取所有的metrics |
149 | 177 | List<ClusterMetrics> metricsList = new ArrayList<>(); |
150 | 178 | for (ClusterPhyDashboardVO vo: voList) { |
151 | | - ClusterMetrics clusterMetrics = clusterMetricService.getLatestMetricsFromCache(vo.getId()); |
152 | | - if (!clusterMetrics.getMetrics().containsKey(ClusterMetricVersionItems.CLUSTER_METRIC_HEALTH_SCORE)) { |
153 | | - Float alive = clusterMetrics.getMetrics().get(ClusterMetricVersionItems.CLUSTER_METRIC_ALIVE); |
154 | | - // 如果集群没有健康分,则设置一个默认的健康分数值 |
155 | | - clusterMetrics.putMetric(ClusterMetricVersionItems.CLUSTER_METRIC_HEALTH_SCORE, |
156 | | - (alive != null && alive <= 0)? 0.0f: Constant.DEFAULT_CLUSTER_HEALTH_SCORE.floatValue() |
157 | | - ); |
158 | | - } |
159 | | - |
160 | | - metricsList.add(clusterMetrics); |
| 179 | + metricsList.add(clusterMetricService.getLatestMetricsFromCache(vo.getId())); |
161 | 180 | } |
162 | 181 |
|
163 | 182 | // 范围搜索 |
|
0 commit comments