/*
* Licensed 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 com.zto.zms.collector.report;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.zto.zms.stats.*;
import com.zto.zms.collector.kafka.mbean.MBeanRateInfo;
import com.zto.zms.collector.model.KafkaMetrics;
import com.zto.zms.collector.model.*;
import com.zto.zms.service.domain.MetricsDo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* Created by liangyong on 2018/9/17.
*/
@Service
public class MetricsTransformService {
private static final Logger logger = LoggerFactory.getLogger(MetricsTransformService.class);
private Map<String, Long> cacheMap = Maps.newHashMap();
public List<MetricsDo> transformMqRtInfo(ClusterRtTime info) {
List<MetricsDo> metricsDoList = Lists.newArrayList();
if (null == info.getTimes()) {
return metricsDoList;
}
info.getTimes().forEach((timer) -> {
MetricsDo<Double> metricsDo = new MetricsDo<Double>();
Map<String, String> tagOptions = metricsDo.getTagOptions();
Map<String, Double> segmentMap = metricsDo.getSegmentMap();
tagOptions.put("clusterName", info.getCluster());
tagOptions.put("brokerName", timer.getBrokerName());
segmentMap.put("result", (double) timer.getResult());
segmentMap.put("rt", (double) timer.getRt());
metricsDo.setTagOptions(tagOptions);
metricsDo.setSegmentMap(segmentMap);
metricsDoList.add(metricsDo);
});
return metricsDoList;
}
public List<MetricsDo> transformStrDataKafkaCluster(KafkaMetrics info) {
List<MetricsDo> metricsDoList = Lists.newArrayList();
if (null == info) {
return metricsDoList;
}
MetricsDo<String> metricsDo = new MetricsDo<String>();
Map<String, String> tagOptions = metricsDo.getTagOptions();
Map<String, String> segmentMap = metricsDo.getSegmentMap();
tagOptions.put("clusterName", info.getClusterName());
segmentMap.put("controllerHost", info.getControllerHost());
segmentMap.put("controllerId", String.valueOf(info.getControllerId()));
metricsDo.setTagOptions(tagOptions);
metricsDo.setSegmentMap(segmentMap);
metricsDoList.add(metricsDo);
return metricsDoList;
}
public List<MetricsDo> transformDoubleDataKafkaCluster(KafkaMetrics info) {
List<MetricsDo> metricsDoList = Lists.newArrayList();
if (null == info || null == info.getBrokersMetrics()) {
return metricsDoList;
}
double totalTps = 0d;
Map<String, KafkaBrokerInfo> brokerInfoMap = info.getBrokersMetrics();
for (Map.Entry<String, KafkaBrokerInfo> entry : brokerInfoMap.entrySet()) {
KafkaBrokerInfo kafkaBrokerInfo = entry.getValue();
if (null == kafkaBrokerInfo.getMessagesInPerSec()) {
continue;
}
totalTps = addCalc(totalTps, kafkaBrokerInfo.getMessagesInPerSec().getOneMinuteRate());
}
return clusterTpsMetrics(metricsDoList, info.getClusterName(), totalTps);
}
private double addCalc(double value1, double value2) {
BigDecimal b1 = BigDecimal.valueOf(value1);
BigDecimal b2 = BigDecimal.valueOf(value2);
return b1.add(b2).doubleValue();
}
public List<MetricsDo> transformMqCluster(RocketmqStatus info) {
List<MetricsDo> metricsDoList = Lists.newArrayList();
if (null == info) {
return metricsDoList;
}
return clusterTpsMetrics(metricsDoList, info.getClusterName(), info.getTotalTps());
}
private List<MetricsDo> clusterTpsMetrics(List<MetricsDo> metricsDoList, String clusterName, double totalTps) {
MetricsDo<Double> metricsDo = new MetricsDo<>();
Map<String, Double> segmentMap = metricsDo.getSegmentMap();
Map<String, String> tagOptions = metricsDo.getTagOptions();
tagOptions.put("clusterName", clusterName);
segmentMap.put("totalTps", totalTps);
metricsDo.setTagOptions(tagOptions);
metricsDo.setSegmentMap(segmentMap);
metricsDoList.add(metricsDo);
return metricsDoList;
}
public List<MetricsDo> transformMqBroker(RocketmqStatus info) {
List<MetricsDo> metricsDoList = Lists.newArrayList();
if (null == info.getBrokers()) {
return metricsDoList;
}
info.getBrokers().forEach((broker) -> {
MetricsDo<Double> metricsDo = new MetricsDo<Double>();
Map<String, String> tagOptions = metricsDo.getTagOptions();
Map<String, Double> segmentMap = metricsDo.getSegmentMap();
tagOptions.put("clusterName", info.getClusterName());
tagOptions.put("brokerName", broker.getBrokerName());
segmentMap.put("bootTime", broker.getBootTime());
segmentMap.put("brokerId", (double) broker.getBrokerId());
segmentMap.put("getTotalTps", broker.getGetTotalTps());
segmentMap.put("msgGetTotalTodayNow", (double) broker.getMsgGetTotalTodayNow());
segmentMap.put("msgPutTotalTodayNow", (double) broker.getMsgPutTotalTodayNow());
segmentMap.put("pageCacheLockTimeMillis", (double) broker.getPageCacheLockTimeMillis());
segmentMap.put("pullThreadPoolQueueCapacity", (double) broker.getPullThreadPoolQueueCapacity());
segmentMap.put("pullThreadPoolQueueHeadWaitTimeMills", (double) broker.getPullThreadPoolQueueHeadWaitTimeMills());
segmentMap.put("pullThreadPoolQueueSize", (double) broker.getPullThreadPoolQueueSize());
segmentMap.put("putTps", broker.getPutTps());
segmentMap.put("sendThreadPoolQueueCapacity", (double) broker.getSendThreadPoolQueueCapacity());
segmentMap.put("sendThreadPoolQueueSize", (double) broker.getSendThreadPoolQueueSize());
metricsDo.setTagOptions(tagOptions);
metricsDo.setSegmentMap(segmentMap);
metricsDoList.add(metricsDo);
});
return metricsDoList;
}
public List<MetricsDo> transformStringDataMqBroker(RocketmqStatus info) {
List<MetricsDo> metricsDoList = Lists.newArrayList();
if (null == info.getBrokers()) {
return metricsDoList;
}
info.getBrokers().forEach((broker) -> {
MetricsDo<String> metricsStrDo = new MetricsDo<>();
Map<String, String> tagOptions = metricsStrDo.getTagOptions();
Map<String, String> segmentStrMap = metricsStrDo.getSegmentMap();
tagOptions.put("clusterName", info.getClusterName());
tagOptions.put("brokerName", broker.getBrokerName());
segmentStrMap.put("ip", broker.getIp());
segmentStrMap.put("putMessageDistributeTime", broker.getPutMessageDistributeTime());
metricsStrDo.setTagOptions(tagOptions);
metricsStrDo.setSegmentMap(segmentStrMap);
metricsDoList.add(metricsStrDo);
});
return metricsDoList;
}
public List<MetricsDo> transformMqTopic(RocketmqStatus info) {
List<MetricsDo> metricsDoList = Lists.newArrayLis
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目为基于Java语言的ZTO消息服务(ZMS)集群管理平台设计源码,共包含899个文件,涵盖491个Java源文件、154个JavaScript文件、85个Vue组件文件、41个XML配置文件、30个PNG图片文件、25个CSS样式文件、19个SCSS样式文件、14个Shell脚本文件、5个属性文件以及4个字体文件。ZMS平台旨在实现与消息集群(如RocketMQ和Kafka)的解耦,提供统一的消息服务接口,并支持集群的安装、管理、监控和告警管理功能。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java语言的ZTO消息服务(ZMS)集群管理平台设计源码 (903个子文件)
supervisord.conf 999B
chunk-elementUI.43fc3011.css 228KB
app.84bbfac5.css 32KB
chunk-libs.39a2421b.css 30KB
normalize.css 8KB
iconfont.css 5KB
chunk-705dd7fc.771118ca.css 3KB
chunk-commons.32b5ad9d.css 3KB
chunk-67eca906.ae2a93c5.css 2KB
chunk-18a1b24e.fe366f15.css 2KB
chunk-e5c05400.cc257d65.css 1KB
chunk-a748d3aa.abd26b9a.css 1KB
chunk-d0ed2588.f1dc26ed.css 1KB
chunk-205dafde.c7d7f4b8.css 1KB
chunk-7cfd592c.b77406ca.css 894B
chunk-0d236ed5.03727a34.css 811B
chunk-13db2eb8.75a7692f.css 424B
chunk-9ee6f6dc.ff91cd1b.css 319B
chunk-3ae0fada.20cabfc2.css 231B
chunk-9d5795d4.dd883621.css 197B
chunk-47fde93b.2d554d5c.css 191B
chunk-db0ff40c.16afd24a.css 188B
chunk-6adaf3f0.a1ebbd4c.css 108B
chunk-2e5479cf.804929b7.css 101B
chunk-2b11d48c.804929b7.css 101B
chunk-0fa7b04e.7e4f808c.css 20B
.env.development 215B
.editorconfig 217B
fontawesome-webfont.674f50d2.eot 162KB
iconfont.eot 5KB
iconfont.ad30a9a1.eot 5KB
.eslintignore 17B
.gitignore 266B
.gitignore 215B
index.html 4KB
index.html 1KB
favicon.ico 17KB
favicon.ico 17KB
MetricsTransformService.java 73KB
ServeInstanceService.java 64KB
ConsumerMapperService.java 30KB
RocketMQReporter.java 27KB
TopicMapperService.java 27KB
KafkaBrokerInfoController.java 21KB
KafkaEnvInfoController.java 19KB
AlertService.java 18KB
KafkaReporter.java 17KB
ProcessService.java 17KB
KafkaConsumerProxy.java 16KB
KafkaJMXCollector.java 14KB
RocketMqMiddlewareManager.java 13KB
MigrationService.java 13KB
ConsumerController.java 13KB
KafkaMbeanServiceImpl.java 13KB
RocketmqCmdController.java 12KB
ZmsZkClient.java 12KB
BackupClusterService.java 12KB
RocketMqBrokerSvrConfigAssembleImpl.java 10KB
ConsumerStatusService.java 10KB
RocketMessageService.java 10KB
InfluxdbModelTransformer.java 10KB
KafkaBrokerInfo.java 10KB
RocketmqConsumerProxy.java 10KB
TopicProducerController.java 10KB
RocketmqProducerProxy.java 10KB
ServeService.java 10KB
ClusterListService.java 9KB
StatsAllService.java 9KB
Consumer.java 9KB
TopicController.java 9KB
KafkaMiddlewareManager.java 9KB
InfluxdbClient.java 9KB
KafkaConfigAssembleImpl.java 9KB
ZookeeperConfigAssembleImpl.java 8KB
Topic.java 8KB
ReportRunner.java 8KB
AlertTask.java 8KB
ZmsBackupClusterAssembleImpl.java 8KB
MonitorServiceAdapt.java 8KB
RocketMqServiceInstanceListenerImpl.java 7KB
SupervisordApi.java 7KB
MessageView.java 7KB
ZmsEnvironmentService.java 7KB
AlertRuleConfig.java 7KB
ServeInstanceController.java 7KB
ConsumerDTO.java 7KB
KafkaServiceInstanceListenerImpl.java 7KB
TopicLoader.java 7KB
RunCommonConfig.java 7KB
AlertRuleConfig.java 7KB
KafkaServiceImpl.java 7KB
KafkaProducerProxy.java 7KB
Zms.java 7KB
HostServiceImpl.java 7KB
GCMBeanServiceImpl.java 7KB
ZkClientRouter.java 6KB
LogCommandConfigAssemble.java 6KB
UpdateTopicPermService.java 6KB
UnixProcessManager.java 6KB
ZmsConst.java 6KB
共 903 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
xyq2024
- 粉丝: 2502
- 资源: 5461
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功