commit bcea68078121d85550b35f50b5ead34bd83d1a8e Author: tomsun28 Date: Wed Nov 10 20:07:27 2021 +0800 迁移collector,合并到整个工程 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84ee25c --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +Thumbs.db +.DS_Store +.gradle +build/ +out/ +micronaut-cli.yml +.mvn/ +mvnw +mvnw.bat +.log + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +### VS Code ### +.vscode/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b018625 --- /dev/null +++ b/LICENSE @@ -0,0 +1,207 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, and + distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by the + copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all other + entities that control, are controlled by, or are under common control with + that entity. For the purposes of this definition, "control" means (i) the + power, direct or indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (ii) ownership of + fifty percent (50%) or more of the outstanding shares, or (iii) beneficial + ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity exercising + permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation source, + and configuration files. + + "Object" form shall mean any form resulting from mechanical transformation + or translation of a Source form, including but not limited to compiled + object code, generated documentation, and conversions to + other media types. + + "Work" shall mean the work of authorship, whether in Source or Object + form, made available under the License, as indicated by a copyright notice + that is included in or attached to the work (an example is provided in the + Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object form, + that is based on (or derived from) the Work and for which the editorial + revisions, annotations, elaborations, or other modifications represent, + as a whole, an original work of authorship. For the purposes of this + License, Derivative Works shall not include works that remain separable + from, or merely link (or bind by name) to the interfaces of, the Work and + Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including the original + version of the Work and any modifications or additions to that Work or + Derivative Works thereof, that is intentionally submitted to Licensor for + inclusion in the Work by the copyright owner or by an individual or + Legal Entity authorized to submit on behalf of the copyright owner. + For the purposes of this definition, "submitted" means any form of + electronic, verbal, or written communication sent to the Licensor or its + representatives, including but not limited to communication on electronic + mailing lists, source code control systems, and issue tracking systems + that are managed by, or on behalf of, the Licensor for the purpose of + discussing and improving the Work, but excluding communication that is + conspicuously marked or otherwise designated in writing by the copyright + owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity on + behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. + + Subject to the terms and conditions of this License, each Contributor + hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, + royalty-free, irrevocable copyright license to reproduce, prepare + Derivative Works of, publicly display, publicly perform, sublicense, + and distribute the Work and such Derivative Works in + Source or Object form. + +3. Grant of Patent License. + + Subject to the terms and conditions of this License, each Contributor + hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, + royalty-free, irrevocable (except as stated in this section) patent + license to make, have made, use, offer to sell, sell, import, and + otherwise transfer the Work, where such license applies only to those + patent claims licensable by such Contributor that are necessarily + infringed by their Contribution(s) alone or by combination of their + Contribution(s) with the Work to which such Contribution(s) was submitted. + If You institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work or a + Contribution incorporated within the Work constitutes direct or + contributory patent infringement, then any patent licenses granted to + You under this License for that Work shall terminate as of the date such + litigation is filed. + +4. Redistribution. + + You may reproduce and distribute copies of the Work or Derivative Works + thereof in any medium, with or without modifications, and in Source or + Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a + copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You + distribute, all copyright, patent, trademark, and attribution notices from + the Source form of the Work, excluding those notices that do not pertain + to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable copy + of the attribution notices contained within such NOTICE file, excluding + those notices that do not pertain to any part of the Derivative Works, + in at least one of the following places: within a NOTICE text file + distributed as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, within a + display generated by the Derivative Works, if and wherever such + third-party notices normally appear. The contents of the NOTICE file are + for informational purposes only and do not modify the License. + You may add Your own attribution notices within Derivative Works that You + distribute, alongside or as an addendum to the NOTICE text from the Work, + provided that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and may + provide additional or different license terms and conditions for use, + reproduction, or distribution of Your modifications, or for any such + Derivative Works as a whole, provided Your use, reproduction, and + distribution of the Work otherwise complies with the conditions + stated in this License. + +5. Submission of Contributions. + + Unless You explicitly state otherwise, any Contribution intentionally + submitted for inclusion in the Work by You to the Licensor shall be under + the terms and conditions of this License, without any additional + terms or conditions. Notwithstanding the above, nothing herein shall + supersede or modify the terms of any separate license agreement you may + have executed with Licensor regarding such Contributions. + +6. Trademarks. + + This License does not grant permission to use the trade names, trademarks, + service marks, or product names of the Licensor, except as required for + reasonable and customary use in describing the origin of the Work and + reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + + Unless required by applicable law or agreed to in writing, Licensor + provides the Work (and each Contributor provides its Contributions) + on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + either express or implied, including, without limitation, any warranties + or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS + FOR A PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any risks + associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + + In no event and under no legal theory, whether in tort + (including negligence), contract, or otherwise, unless required by + applicable law (such as deliberate and grossly negligent acts) or agreed + to in writing, shall any Contributor be liable to You for damages, + including any direct, indirect, special, incidental, or consequential + damages of any character arising as a result of this License or out of + the use or inability to use the Work (including but not limited to damages + for loss of goodwill, work stoppage, computer failure or malfunction, + or any and all other commercial damages or losses), even if such + Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + + While redistributing the Work or Derivative Works thereof, You may choose + to offer, and charge a fee for, acceptance of support, warranty, + indemnity, or other liability obligations and/or rights consistent with + this License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf of any + other Contributor, and only if You agree to indemnify, defend, and hold + each Contributor harmless for any liability incurred by, or claims + asserted against, such Contributor by reason of your accepting any such + warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + + To apply the Apache License to your work, attach the following boilerplate + notice, with the fields enclosed by brackets "[]" replaced with your own + identifying information. (Don't include the brackets!) The text should be + enclosed in the appropriate comment syntax for the file format. We also + recommend that a file or class name and description of purpose be included + on the same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright tomsun28 usthe.com. + + 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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa42ce7 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +## monitor + +- 提供监控管理服务 +- 提供监控任务下发服务 +- 提供监控数据查询服务 +- 告警服务 \ No newline at end of file diff --git a/alerter/pom.xml b/alerter/pom.xml new file mode 100644 index 0000000..1c6b56b --- /dev/null +++ b/alerter/pom.xml @@ -0,0 +1,18 @@ + + + + monitor + com.usthe.tancloud + 1.0-SNAPSHOT + + 4.0.0 + + alerter + + + + + + \ No newline at end of file diff --git a/collector/README.md b/collector/README.md new file mode 100644 index 0000000..f9ecdd2 --- /dev/null +++ b/collector/README.md @@ -0,0 +1,42 @@ +### TanCloud Collector + +* 操作系统 + * Linux + * Windows + * Ubuntu + * CentOs +* 数据库 + * Mysql + * Oracle + * PostgreSQL +* 中间件 + * Kafka + * Zookeeper + * RocketMq + * Etcd +* 云原生 + * Docker + * Kubernetes + * Istio +* 应用服务 + * Tomcat + * Jetty + * Http + * Ping + * 服务端口 + +#### HELP + +1. ARK插件类隔离未生效 +> 注意需构建在jdk1.8环境中运行 +> 插件是否配置导入并配置正确 +> 本地DEBUG时需单独IDEA打开运行collector工程,不能将plugin和collector在同一工程打开运行 + +2. metaspace元空间内存占用多或溢出 +> 建议调整JVM参数 ```-Dsun.reflect.inflationThreshold=100000``` +> 由于使用太多反射,超过参数`inflationThreshold`默认值15阈值导致触发JVM反射优化(加快反射速度), +> 反射获取类信息由使用*JNI存取器**膨胀(Inflation)* +> 为*反射每个方法生成一个类加载器DelegatingClassLoader和Java类MethodAccessor*. +> 动态加载的字节码导致PermGen持续增长. + + diff --git a/collector/plugins/pom.xml b/collector/plugins/pom.xml new file mode 100644 index 0000000..14c317b --- /dev/null +++ b/collector/plugins/pom.xml @@ -0,0 +1,19 @@ + + + + collector + com.usthe.tancloud + 1.0-SNAPSHOT + + 4.0.0 + + plugins + pom + + sample-plugin + + + + \ No newline at end of file diff --git a/collector/plugins/sample-plugin/pom.xml b/collector/plugins/sample-plugin/pom.xml new file mode 100644 index 0000000..6ce90c0 --- /dev/null +++ b/collector/plugins/sample-plugin/pom.xml @@ -0,0 +1,48 @@ + + + + plugins + com.usthe.tancloud + 1.0-SNAPSHOT + + 4.0.0 + + sample-plugin + + + + + + com.alipay.sofa + sofa-ark-plugin-maven-plugin + 1.1.6 + + + default-cli + + ark-plugin + + + + + 2000 + + + + + + com.com.usthe.plugin.sample.ExportDemo + + + + + + + + + + + + \ No newline at end of file diff --git a/collector/plugins/sample-plugin/src/main/java/com/usthe/collector/plugin/SameClass.java b/collector/plugins/sample-plugin/src/main/java/com/usthe/collector/plugin/SameClass.java new file mode 100644 index 0000000..b6bbe94 --- /dev/null +++ b/collector/plugins/sample-plugin/src/main/java/com/usthe/collector/plugin/SameClass.java @@ -0,0 +1,12 @@ +package com.usthe.collector.plugin; + +/** + * @author tomsun28 + * @date 2021/10/8 15:12 + */ +public class SameClass { + + public static String hello() { + return "hello plugin"; + } +} diff --git a/collector/plugins/sample-plugin/src/main/java/com/usthe/plugin/sample/ExportDemo.java b/collector/plugins/sample-plugin/src/main/java/com/usthe/plugin/sample/ExportDemo.java new file mode 100644 index 0000000..c3e163d --- /dev/null +++ b/collector/plugins/sample-plugin/src/main/java/com/usthe/plugin/sample/ExportDemo.java @@ -0,0 +1,14 @@ +package com.usthe.plugin.sample; + +import com.usthe.collector.plugin.SameClass; + +/** + * @author tomsun28 + * @date 2021/10/8 15:11 + */ +public class ExportDemo { + + public String hello() { + return SameClass.hello(); + } +} diff --git a/collector/pom.xml b/collector/pom.xml new file mode 100644 index 0000000..e30de1e --- /dev/null +++ b/collector/pom.xml @@ -0,0 +1,18 @@ + + + + monitor + com.usthe.tancloud + 1.0-SNAPSHOT + + 4.0.0 + + collector + pom + + server + plugins + + \ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 0000000..31f597f --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,35 @@ + + + + monitor + com.usthe.tancloud + 1.0-SNAPSHOT + + 4.0.0 + + common + + + + + + io.etcd + jetcd-core + 0.5.10 + provided + + + + com.google.guava + guava + 31.0.1-jre + + + com.google.code.gson + gson + 2.8.8 + + + \ No newline at end of file diff --git a/common/src/main/java/com/usthe/common/entity/job/Configmap.java b/common/src/main/java/com/usthe/common/entity/job/Configmap.java new file mode 100644 index 0000000..e21bc5f --- /dev/null +++ b/common/src/main/java/com/usthe/common/entity/job/Configmap.java @@ -0,0 +1,35 @@ +package com.usthe.common.entity.job; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 监控配置参数属性及值 + * 过程中需要将协议配置参数里面的标识符为^_^key^_^的内容替换为配置参数里的真实值 + * @author tomsun28 + * @date 2021/10/29 22:04 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Configmap { + + /** + * 参数key,将协议配置参数里面的标识符为^^_key_^^的内容替换为配置参数里的真实值 + */ + private String key; + + /** + * 参数value + */ + private Object value; + + /** + * number,string,secret + * 数字,非加密字符串,加密字符串 + */ + private String type; +} diff --git a/common/src/main/java/com/usthe/common/entity/job/Job.java b/common/src/main/java/com/usthe/common/entity/job/Job.java new file mode 100644 index 0000000..f87413b --- /dev/null +++ b/common/src/main/java/com/usthe/common/entity/job/Job.java @@ -0,0 +1,162 @@ +package com.usthe.common.entity.job; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 采集任务详情 + * @author tomsun28 + * @date 2021/10/17 21:19 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Slf4j +public class Job { + + private static final String AVAILABILITY = "availability"; + + /** + * 任务ID + */ + private long id; + /** + * 监控ID 应用ID + */ + private long appId; + /** + * 监控的类型 eg: linux | mysql | jvm + */ + private String app; + /** + * 任务派发开始时间戳 + */ + private long timestamp; + /** + * 任务采集时间间隔(单位秒) eg: 30,60,600 + */ + private long interval; + /** + * 是否是循环周期性任务 true为是,false为否 + */ + private boolean isCyclic; + /** + * 指标组配置 eg: cpu memory + */ + private List metrics; + /** + * 监控配置参数属性及值 eg: username password timeout host + */ + private List configmap; + + /** + * collector使用 - 任务版本,此字段不存储于etcd + */ + private transient long version; + /** + * collector使用 - 指标组任务执行优先级视图 + * 0 - availability + * 1 - cpu | memory + * 2 - health + * 3 - otherMetrics + * .... + * 126 - otherMetrics + * 127 - lastPriorMetrics + */ + private transient List> priorMetrics; + + /** + * collector使用 - 构造初始化标志 + */ + private transient boolean isConstruct = false; + + /** + * collector使用 - 构造初始化指标组 + */ + public synchronized void constructMetrics() { + if (isConstruct) { + return; + } + Map> map = metrics.stream() + .peek(metric -> { + // 判断是否配置aliasFields 没有则配置默认 + if (metric.getAliasFields() == null || metric.getAliasFields().isEmpty()) { + metric.setAliasFields(metric.getFields()); + } + // 设置默认的指标组执行优先级 + if (metric.getPriority() == null) { + if (AVAILABILITY.equals(metric.getName())) { + metric.setPriority((byte)0); + } else { + metric.setPriority(Byte.MAX_VALUE); + } + } + }) + .collect(Collectors.groupingBy(Metrics::getPriority)); + // 构造指标组任务执行顺序链表 + priorMetrics = new LinkedList<>(); + map.values().forEach(metric -> { + Set metricsSet = new HashSet<>(metric); + priorMetrics.add(metricsSet); + }); + priorMetrics.sort(Comparator.comparing(e -> { + Optional metric = e.stream().findAny(); + if (metric.isPresent()) { + return metric.get().getPriority(); + } else { + return Byte.MAX_VALUE; + } + })); + } + + /** + * collector使用 - 获取下一组优先级的指标组任务 + * @param metrics 当前指标组 + * @param first 是否是第一次获取 + * @return 指标组任务 + * 返回null表示:job已完成,所有指标组采集结束 + * 返回empty的集合表示:当前级别下还有指标组采集任务未结束,无法进行下一级别的指标组任务采集 + * 返回有数据集合表示:获取到下一组优先级的指标组任务 + */ + public synchronized Set getNextCollectMetrics(Metrics metrics, boolean first) { + if (!isConstruct || priorMetrics == null || priorMetrics.isEmpty()) { + return null; + } + Set metricsSet = priorMetrics.get(0); + if (first) { + log.error("metrics must has one [availability] metrics at least."); + return metricsSet; + } + if (metrics == null) { + log.error("metrics can not null when not first get"); + } + if (metrics != null && !metricsSet.remove(metrics)) { + log.error("Job {} appId {} app {} metrics {} remove empty error in priorMetrics.", + id, appId, app, metrics.getName()); + } + if (metricsSet.isEmpty()) { + if (priorMetrics.size() == 1) { + return null; + } + priorMetrics.remove(0); + return priorMetrics.get(0); + } else { + return Collections.emptySet(); + } + } +} diff --git a/common/src/main/java/com/usthe/common/entity/job/Metrics.java b/common/src/main/java/com/usthe/common/entity/job/Metrics.java new file mode 100644 index 0000000..dc1fd4a --- /dev/null +++ b/common/src/main/java/com/usthe/common/entity/job/Metrics.java @@ -0,0 +1,70 @@ +package com.usthe.common.entity.job; + +import com.usthe.common.entity.job.protocol.HttpProtocol; +import com.usthe.common.entity.job.protocol.IcmpProtocol; +import com.usthe.common.entity.job.protocol.JdbcProtocol; +import com.usthe.common.entity.job.protocol.TcpUdpProtocol; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 监控采集的指标集合详情 eg: cpu | memory | health + * @author tomsun28 + * @date 2021/10/17 21:24 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Metrics { + + /** + * 公共属性-名称 eg: cpu | memory | health + */ + private String name; + /** + * 公共属性-采集监控协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk + */ + private String protocol; + /** + * 范围(0-127)指标组调度优先级,数值越小优先级越高 + * 优先级高的调度采集完成后才会调度下一优先级的指标组采集任务 + * 可用性指标组(availability)默认优先级为0,其它普通指标组范围为1-127,即需要等availability采集成功后才会调度后面的指标组任务 + */ + private Byte priority; + /** + * 公共属性-采集监控的最终结果属性集合 eg: speed | times | size + */ + private List fields; + /** + * 公共属性-采集监控的前置查询属性集合 eg: size1 | size2 | speedSize + */ + private List aliasFields; + /** + * 公共属性-表达式计算,将前置查询属性(preFields)与最终属性(fields)映射,计算出最终属性(fields)值 + * eg: size = size1 + size2, speed = speedSize + * https://www.yuque.com/boyan-avfmj/aviatorscript/ban32m + */ + private List calculates; + + /** + * 使用http协议的监控配置信息 + */ + private HttpProtocol http; + /** + * 使用icmp协议进行ping的监控配置信息 + */ + private IcmpProtocol icmp; + /** + * 使用socket实现的tcp或ucp进行服务端口探测配置信息 + */ + private TcpUdpProtocol tcpUdp; + /** + * 使用公共的jdbc规范实现的数据库配置信息 + */ + private JdbcProtocol jdbc; +} diff --git a/common/src/main/java/com/usthe/common/entity/job/protocol/HttpProtocol.java b/common/src/main/java/com/usthe/common/entity/job/protocol/HttpProtocol.java new file mode 100644 index 0000000..95cd54c --- /dev/null +++ b/common/src/main/java/com/usthe/common/entity/job/protocol/HttpProtocol.java @@ -0,0 +1,93 @@ +package com.usthe.common.entity.job.protocol; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * http 协议配置 + * @author tomsun28 + * @date 2021/10/31 12:41 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class HttpProtocol { + /** + * 对端主机ip或域名 + */ + private String host; + /** + * http/https 请求访问的url链接 + */ + private String url; + /** + * http是否使用链路加密ssl/tls,即是http还是https + */ + private boolean ssl = false; + /** + * http请求方法: get, post, put, delete, patch + */ + private String method; + /** + * http请求携带头 eg: Content-Type = application/json + */ + private Map headers; + /** + * http请求携带查询参数 eg: localhost:80/api?paramKey=value + */ + private Map params; + /** + * 认证信息 + */ + private Authorization authorization; + /** + * 响应数据解析方式 + * default - 自有的数据解析规则 + * json_path 自定义jsonPath脚本 https://www.jsonpath.cn/ + * xml_path 自定义xmlPath脚本 + * prometheus Prometheus数据规则 + */ + private String parseType; + /** + * 数据解析脚本 当解析方式为 jsonPath or xmlPath时存在 + */ + private String parseScript; + + /** + * 认证信息 + */ + @Data + @AllArgsConstructor + @NoArgsConstructor + public class Authorization { + /** + * 认证类型:Bearer Token, Basic Auth, Digest Auth + */ + private String type; + /** + * Bearer Token's token + */ + private String bearerTokenToken; + /** + * Basic Auth's username + */ + private String basicAuthUsername; + /** + * Basic Auth's password + */ + private String basicAuthPassword; + /** + * Digest Auth's username + */ + private String digestAuthUsername; + /** + * Digest Auth's password + */ + private String digestAuthPassword; + } +} diff --git a/common/src/main/java/com/usthe/common/entity/job/protocol/IcmpProtocol.java b/common/src/main/java/com/usthe/common/entity/job/protocol/IcmpProtocol.java new file mode 100644 index 0000000..f9ba6d4 --- /dev/null +++ b/common/src/main/java/com/usthe/common/entity/job/protocol/IcmpProtocol.java @@ -0,0 +1,23 @@ +package com.usthe.common.entity.job.protocol; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * icmp(即ping)协议配置 + * @author tomsun28 + * @date 2021/10/31 16:41 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class IcmpProtocol { + /** + * 对端主机ip或域名 + */ + private String host; + +} diff --git a/common/src/main/java/com/usthe/common/entity/job/protocol/JdbcProtocol.java b/common/src/main/java/com/usthe/common/entity/job/protocol/JdbcProtocol.java new file mode 100644 index 0000000..4c61915 --- /dev/null +++ b/common/src/main/java/com/usthe/common/entity/job/protocol/JdbcProtocol.java @@ -0,0 +1,38 @@ +package com.usthe.common.entity.job.protocol; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 公共的jdbc规范实现的数据库配置信息 + * @author tomsun28 + * @date 2021/10/31 17:33 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class JdbcProtocol { + /** + * 对端主机ip或域名 + */ + private String host; + /** + * 端口号 + */ + private Integer port; + /** + * 数据库用户名(可选) + */ + private String username; + /** + * 数据库密码(可选) + */ + private String password; + /** + * 数据库链接url eg: jdbc:mysql://localhost:3306 + */ + private String url; +} diff --git a/common/src/main/java/com/usthe/common/entity/job/protocol/TcpUdpProtocol.java b/common/src/main/java/com/usthe/common/entity/job/protocol/TcpUdpProtocol.java new file mode 100644 index 0000000..3f2afd0 --- /dev/null +++ b/common/src/main/java/com/usthe/common/entity/job/protocol/TcpUdpProtocol.java @@ -0,0 +1,30 @@ +package com.usthe.common.entity.job.protocol; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 使用socket实现的tcp或ucp进行服务端口可用性探测 + * @author tomsun28 + * @date 2021/10/31 17:27 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TcpUdpProtocol { + /** + * 具体协议类型 tcp, udp + */ + private String protocol; + /** + * 对端主机ip或域名 + */ + private String host; + /** + * 端口号 + */ + private Integer port; +} diff --git a/common/src/main/java/com/usthe/common/entity/message/CollectRep.java b/common/src/main/java/com/usthe/common/entity/message/CollectRep.java new file mode 100644 index 0000000..a990c4d --- /dev/null +++ b/common/src/main/java/com/usthe/common/entity/message/CollectRep.java @@ -0,0 +1,3225 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: collect_rep.proto + +package com.usthe.common.entity.message; + +@SuppressWarnings("PMD") +public final class CollectRep { + private CollectRep() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + /** + * Protobuf enum {@code com.usthe.common.entity.message.Code} + */ + public enum Code + implements com.google.protobuf.ProtocolMessageEnum { + /** + *
+     * 采集成功
+     * 
+ * + * SUCCESS = 0; + */ + SUCCESS(0), + /** + *
+     * 采集器不可用
+     * 
+ * + * UN_AVAILABLE = 1; + */ + UN_AVAILABLE(1), + /** + *
+     * 对端不可达(网络层icmp)
+     * 
+ * + * UN_REACHABLE = 2; + */ + UN_REACHABLE(2), + /** + *
+     * 对端连接失败(传输层tcp,udp)
+     * 
+ * + * UN_CONNECTABLE = 3; + */ + UN_CONNECTABLE(3), + /** + *
+     * 数据采集失败(应用层http,ssh,snmp)
+     * 
+ * + * FAIL = 4; + */ + FAIL(4), + /** + *
+     * 采集超时
+     * 
+ * + * TIMEOUT = 5; + */ + TIMEOUT(5), + UNRECOGNIZED(-1), + ; + + /** + *
+     * 采集成功
+     * 
+ * + * SUCCESS = 0; + */ + public static final int SUCCESS_VALUE = 0; + /** + *
+     * 采集器不可用
+     * 
+ * + * UN_AVAILABLE = 1; + */ + public static final int UN_AVAILABLE_VALUE = 1; + /** + *
+     * 对端不可达(网络层icmp)
+     * 
+ * + * UN_REACHABLE = 2; + */ + public static final int UN_REACHABLE_VALUE = 2; + /** + *
+     * 对端连接失败(传输层tcp,udp)
+     * 
+ * + * UN_CONNECTABLE = 3; + */ + public static final int UN_CONNECTABLE_VALUE = 3; + /** + *
+     * 数据采集失败(应用层http,ssh,snmp)
+     * 
+ * + * FAIL = 4; + */ + public static final int FAIL_VALUE = 4; + /** + *
+     * 采集超时
+     * 
+ * + * TIMEOUT = 5; + */ + public static final int TIMEOUT_VALUE = 5; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Code valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static Code forNumber(int value) { + switch (value) { + case 0: return SUCCESS; + case 1: return UN_AVAILABLE; + case 2: return UN_REACHABLE; + case 3: return UN_CONNECTABLE; + case 4: return FAIL; + case 5: return TIMEOUT; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + Code> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Code findValueByNumber(int number) { + return Code.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return com.usthe.common.entity.message.CollectRep.getDescriptor().getEnumTypes().get(0); + } + + private static final Code[] VALUES = values(); + + public static Code valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Code(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:com.usthe.common.entity.message.Code) + } + + public interface MetricsDataOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.usthe.common.entity.message.MetricsData) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * 监控的ID
+     * 
+ * + * uint64 id = 1; + * @return The id. + */ + long getId(); + + /** + *
+     * 监控的类型 eg: linux | mysql | jvm
+     * 
+ * + * string app = 2; + * @return The app. + */ + java.lang.String getApp(); + /** + *
+     * 监控的类型 eg: linux | mysql | jvm
+     * 
+ * + * string app = 2; + * @return The bytes for app. + */ + com.google.protobuf.ByteString + getAppBytes(); + + /** + *
+     * 监控采集的指标集合 eg: cpu | memory | health
+     * 
+ * + * string metrics = 3; + * @return The metrics. + */ + java.lang.String getMetrics(); + /** + *
+     * 监控采集的指标集合 eg: cpu | memory | health
+     * 
+ * + * string metrics = 3; + * @return The bytes for metrics. + */ + com.google.protobuf.ByteString + getMetricsBytes(); + + /** + *
+     * 采集时间
+     * 
+ * + * uint64 time = 4; + * @return The time. + */ + long getTime(); + + /** + *
+     * 采集响应码
+     * 
+ * + * .com.usthe.common.entity.message.Code code = 5; + * @return The enum numeric value on the wire for code. + */ + int getCodeValue(); + /** + *
+     * 采集响应码
+     * 
+ * + * .com.usthe.common.entity.message.Code code = 5; + * @return The code. + */ + com.usthe.common.entity.message.CollectRep.Code getCode(); + + /** + *
+     * 采集响应信息
+     * 
+ * + * string msg = 6; + * @return The msg. + */ + java.lang.String getMsg(); + /** + *
+     * 采集响应信息
+     * 
+ * + * string msg = 6; + * @return The bytes for msg. + */ + com.google.protobuf.ByteString + getMsgBytes(); + + /** + *
+     * 采集指标名
+     * 
+ * + * repeated string fields = 7; + * @return A list containing the fields. + */ + java.util.List + getFieldsList(); + /** + *
+     * 采集指标名
+     * 
+ * + * repeated string fields = 7; + * @return The count of fields. + */ + int getFieldsCount(); + /** + *
+     * 采集指标名
+     * 
+ * + * repeated string fields = 7; + * @param index The index of the element to return. + * @return The fields at the given index. + */ + java.lang.String getFields(int index); + /** + *
+     * 采集指标名
+     * 
+ * + * repeated string fields = 7; + * @param index The index of the value to return. + * @return The bytes of the fields at the given index. + */ + com.google.protobuf.ByteString + getFieldsBytes(int index); + + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + java.util.List + getValuesList(); + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + com.usthe.common.entity.message.CollectRep.ValueRow getValues(int index); + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + int getValuesCount(); + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + java.util.List + getValuesOrBuilderList(); + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + com.usthe.common.entity.message.CollectRep.ValueRowOrBuilder getValuesOrBuilder( + int index); + } + /** + * Protobuf type {@code com.usthe.common.entity.message.MetricsData} + */ + public static final class MetricsData extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.usthe.common.entity.message.MetricsData) + MetricsDataOrBuilder { + private static final long serialVersionUID = 0L; + // Use MetricsData.newBuilder() to construct. + private MetricsData(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MetricsData() { + app_ = ""; + metrics_ = ""; + code_ = 0; + msg_ = ""; + fields_ = com.google.protobuf.LazyStringArrayList.EMPTY; + values_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new MetricsData(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MetricsData( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + id_ = input.readUInt64(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + app_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + metrics_ = s; + break; + } + case 32: { + + time_ = input.readUInt64(); + break; + } + case 40: { + int rawValue = input.readEnum(); + + code_ = rawValue; + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + msg_ = s; + break; + } + case 58: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + fields_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + fields_.add(s); + break; + } + case 66: { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + values_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + values_.add( + input.readMessage(com.usthe.common.entity.message.CollectRep.ValueRow.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + fields_ = fields_.getUnmodifiableView(); + } + if (((mutable_bitField0_ & 0x00000002) != 0)) { + values_ = java.util.Collections.unmodifiableList(values_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_MetricsData_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_MetricsData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.usthe.common.entity.message.CollectRep.MetricsData.class, com.usthe.common.entity.message.CollectRep.MetricsData.Builder.class); + } + + public static final int ID_FIELD_NUMBER = 1; + private long id_; + /** + *
+     * 监控的ID
+     * 
+ * + * uint64 id = 1; + * @return The id. + */ + @java.lang.Override + public long getId() { + return id_; + } + + public static final int APP_FIELD_NUMBER = 2; + private volatile java.lang.Object app_; + /** + *
+     * 监控的类型 eg: linux | mysql | jvm
+     * 
+ * + * string app = 2; + * @return The app. + */ + @java.lang.Override + public java.lang.String getApp() { + java.lang.Object ref = app_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + app_ = s; + return s; + } + } + /** + *
+     * 监控的类型 eg: linux | mysql | jvm
+     * 
+ * + * string app = 2; + * @return The bytes for app. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getAppBytes() { + java.lang.Object ref = app_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + app_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int METRICS_FIELD_NUMBER = 3; + private volatile java.lang.Object metrics_; + /** + *
+     * 监控采集的指标集合 eg: cpu | memory | health
+     * 
+ * + * string metrics = 3; + * @return The metrics. + */ + @java.lang.Override + public java.lang.String getMetrics() { + java.lang.Object ref = metrics_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + metrics_ = s; + return s; + } + } + /** + *
+     * 监控采集的指标集合 eg: cpu | memory | health
+     * 
+ * + * string metrics = 3; + * @return The bytes for metrics. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getMetricsBytes() { + java.lang.Object ref = metrics_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + metrics_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TIME_FIELD_NUMBER = 4; + private long time_; + /** + *
+     * 采集时间
+     * 
+ * + * uint64 time = 4; + * @return The time. + */ + @java.lang.Override + public long getTime() { + return time_; + } + + public static final int CODE_FIELD_NUMBER = 5; + private int code_; + /** + *
+     * 采集响应码
+     * 
+ * + * .com.usthe.common.entity.message.Code code = 5; + * @return The enum numeric value on the wire for code. + */ + @java.lang.Override public int getCodeValue() { + return code_; + } + /** + *
+     * 采集响应码
+     * 
+ * + * .com.usthe.common.entity.message.Code code = 5; + * @return The code. + */ + @java.lang.Override public com.usthe.common.entity.message.CollectRep.Code getCode() { + @SuppressWarnings("deprecation") + com.usthe.common.entity.message.CollectRep.Code result = com.usthe.common.entity.message.CollectRep.Code.valueOf(code_); + return result == null ? com.usthe.common.entity.message.CollectRep.Code.UNRECOGNIZED : result; + } + + public static final int MSG_FIELD_NUMBER = 6; + private volatile java.lang.Object msg_; + /** + *
+     * 采集响应信息
+     * 
+ * + * string msg = 6; + * @return The msg. + */ + @java.lang.Override + public java.lang.String getMsg() { + java.lang.Object ref = msg_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + msg_ = s; + return s; + } + } + /** + *
+     * 采集响应信息
+     * 
+ * + * string msg = 6; + * @return The bytes for msg. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getMsgBytes() { + java.lang.Object ref = msg_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + msg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FIELDS_FIELD_NUMBER = 7; + private com.google.protobuf.LazyStringList fields_; + /** + *
+     * 采集指标名
+     * 
+ * + * repeated string fields = 7; + * @return A list containing the fields. + */ + public com.google.protobuf.ProtocolStringList + getFieldsList() { + return fields_; + } + /** + *
+     * 采集指标名
+     * 
+ * + * repeated string fields = 7; + * @return The count of fields. + */ + public int getFieldsCount() { + return fields_.size(); + } + /** + *
+     * 采集指标名
+     * 
+ * + * repeated string fields = 7; + * @param index The index of the element to return. + * @return The fields at the given index. + */ + public java.lang.String getFields(int index) { + return fields_.get(index); + } + /** + *
+     * 采集指标名
+     * 
+ * + * repeated string fields = 7; + * @param index The index of the value to return. + * @return The bytes of the fields at the given index. + */ + public com.google.protobuf.ByteString + getFieldsBytes(int index) { + return fields_.getByteString(index); + } + + public static final int VALUES_FIELD_NUMBER = 8; + private java.util.List values_; + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + @java.lang.Override + public java.util.List getValuesList() { + return values_; + } + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + @java.lang.Override + public java.util.List + getValuesOrBuilderList() { + return values_; + } + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + @java.lang.Override + public int getValuesCount() { + return values_.size(); + } + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.ValueRow getValues(int index) { + return values_.get(index); + } + /** + *
+     * 采集指标值集合(fields作为字段名称与ValueRow映射)
+     * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.ValueRowOrBuilder getValuesOrBuilder( + int index) { + return values_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (id_ != 0L) { + output.writeUInt64(1, id_); + } + if (!getAppBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, app_); + } + if (!getMetricsBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, metrics_); + } + if (time_ != 0L) { + output.writeUInt64(4, time_); + } + if (code_ != com.usthe.common.entity.message.CollectRep.Code.SUCCESS.getNumber()) { + output.writeEnum(5, code_); + } + if (!getMsgBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, msg_); + } + for (int i = 0; i < fields_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, fields_.getRaw(i)); + } + for (int i = 0; i < values_.size(); i++) { + output.writeMessage(8, values_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (id_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(1, id_); + } + if (!getAppBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, app_); + } + if (!getMetricsBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, metrics_); + } + if (time_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(4, time_); + } + if (code_ != com.usthe.common.entity.message.CollectRep.Code.SUCCESS.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(5, code_); + } + if (!getMsgBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, msg_); + } + { + int dataSize = 0; + for (int i = 0; i < fields_.size(); i++) { + dataSize += computeStringSizeNoTag(fields_.getRaw(i)); + } + size += dataSize; + size += 1 * getFieldsList().size(); + } + for (int i = 0; i < values_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, values_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.usthe.common.entity.message.CollectRep.MetricsData)) { + return super.equals(obj); + } + com.usthe.common.entity.message.CollectRep.MetricsData other = (com.usthe.common.entity.message.CollectRep.MetricsData) obj; + + if (getId() + != other.getId()) return false; + if (!getApp() + .equals(other.getApp())) return false; + if (!getMetrics() + .equals(other.getMetrics())) return false; + if (getTime() + != other.getTime()) return false; + if (code_ != other.code_) return false; + if (!getMsg() + .equals(other.getMsg())) return false; + if (!getFieldsList() + .equals(other.getFieldsList())) return false; + if (!getValuesList() + .equals(other.getValuesList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getId()); + hash = (37 * hash) + APP_FIELD_NUMBER; + hash = (53 * hash) + getApp().hashCode(); + hash = (37 * hash) + METRICS_FIELD_NUMBER; + hash = (53 * hash) + getMetrics().hashCode(); + hash = (37 * hash) + TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTime()); + hash = (37 * hash) + CODE_FIELD_NUMBER; + hash = (53 * hash) + code_; + hash = (37 * hash) + MSG_FIELD_NUMBER; + hash = (53 * hash) + getMsg().hashCode(); + if (getFieldsCount() > 0) { + hash = (37 * hash) + FIELDS_FIELD_NUMBER; + hash = (53 * hash) + getFieldsList().hashCode(); + } + if (getValuesCount() > 0) { + hash = (37 * hash) + VALUES_FIELD_NUMBER; + hash = (53 * hash) + getValuesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.usthe.common.entity.message.CollectRep.MetricsData parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.usthe.common.entity.message.CollectRep.MetricsData prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.usthe.common.entity.message.MetricsData} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.usthe.common.entity.message.MetricsData) + com.usthe.common.entity.message.CollectRep.MetricsDataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_MetricsData_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_MetricsData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.usthe.common.entity.message.CollectRep.MetricsData.class, com.usthe.common.entity.message.CollectRep.MetricsData.Builder.class); + } + + // Construct using com.usthe.common.entity.message.CollectRep.MetricsData.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getValuesFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + id_ = 0L; + + app_ = ""; + + metrics_ = ""; + + time_ = 0L; + + code_ = 0; + + msg_ = ""; + + fields_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + if (valuesBuilder_ == null) { + values_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + valuesBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_MetricsData_descriptor; + } + + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.MetricsData getDefaultInstanceForType() { + return com.usthe.common.entity.message.CollectRep.MetricsData.getDefaultInstance(); + } + + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.MetricsData build() { + com.usthe.common.entity.message.CollectRep.MetricsData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.MetricsData buildPartial() { + com.usthe.common.entity.message.CollectRep.MetricsData result = new com.usthe.common.entity.message.CollectRep.MetricsData(this); + int from_bitField0_ = bitField0_; + result.id_ = id_; + result.app_ = app_; + result.metrics_ = metrics_; + result.time_ = time_; + result.code_ = code_; + result.msg_ = msg_; + if (((bitField0_ & 0x00000001) != 0)) { + fields_ = fields_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.fields_ = fields_; + if (valuesBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + values_ = java.util.Collections.unmodifiableList(values_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.values_ = values_; + } else { + result.values_ = valuesBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.usthe.common.entity.message.CollectRep.MetricsData) { + return mergeFrom((com.usthe.common.entity.message.CollectRep.MetricsData)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.usthe.common.entity.message.CollectRep.MetricsData other) { + if (other == com.usthe.common.entity.message.CollectRep.MetricsData.getDefaultInstance()) return this; + if (other.getId() != 0L) { + setId(other.getId()); + } + if (!other.getApp().isEmpty()) { + app_ = other.app_; + onChanged(); + } + if (!other.getMetrics().isEmpty()) { + metrics_ = other.metrics_; + onChanged(); + } + if (other.getTime() != 0L) { + setTime(other.getTime()); + } + if (other.code_ != 0) { + setCodeValue(other.getCodeValue()); + } + if (!other.getMsg().isEmpty()) { + msg_ = other.msg_; + onChanged(); + } + if (!other.fields_.isEmpty()) { + if (fields_.isEmpty()) { + fields_ = other.fields_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureFieldsIsMutable(); + fields_.addAll(other.fields_); + } + onChanged(); + } + if (valuesBuilder_ == null) { + if (!other.values_.isEmpty()) { + if (values_.isEmpty()) { + values_ = other.values_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureValuesIsMutable(); + values_.addAll(other.values_); + } + onChanged(); + } + } else { + if (!other.values_.isEmpty()) { + if (valuesBuilder_.isEmpty()) { + valuesBuilder_.dispose(); + valuesBuilder_ = null; + values_ = other.values_; + bitField0_ = (bitField0_ & ~0x00000002); + valuesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getValuesFieldBuilder() : null; + } else { + valuesBuilder_.addAllMessages(other.values_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.usthe.common.entity.message.CollectRep.MetricsData parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.usthe.common.entity.message.CollectRep.MetricsData) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long id_ ; + /** + *
+       * 监控的ID
+       * 
+ * + * uint64 id = 1; + * @return The id. + */ + @java.lang.Override + public long getId() { + return id_; + } + /** + *
+       * 监控的ID
+       * 
+ * + * uint64 id = 1; + * @param value The id to set. + * @return This builder for chaining. + */ + public Builder setId(long value) { + + id_ = value; + onChanged(); + return this; + } + /** + *
+       * 监控的ID
+       * 
+ * + * uint64 id = 1; + * @return This builder for chaining. + */ + public Builder clearId() { + + id_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object app_ = ""; + /** + *
+       * 监控的类型 eg: linux | mysql | jvm
+       * 
+ * + * string app = 2; + * @return The app. + */ + public java.lang.String getApp() { + java.lang.Object ref = app_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + app_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * 监控的类型 eg: linux | mysql | jvm
+       * 
+ * + * string app = 2; + * @return The bytes for app. + */ + public com.google.protobuf.ByteString + getAppBytes() { + java.lang.Object ref = app_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + app_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * 监控的类型 eg: linux | mysql | jvm
+       * 
+ * + * string app = 2; + * @param value The app to set. + * @return This builder for chaining. + */ + public Builder setApp( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + app_ = value; + onChanged(); + return this; + } + /** + *
+       * 监控的类型 eg: linux | mysql | jvm
+       * 
+ * + * string app = 2; + * @return This builder for chaining. + */ + public Builder clearApp() { + + app_ = getDefaultInstance().getApp(); + onChanged(); + return this; + } + /** + *
+       * 监控的类型 eg: linux | mysql | jvm
+       * 
+ * + * string app = 2; + * @param value The bytes for app to set. + * @return This builder for chaining. + */ + public Builder setAppBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + app_ = value; + onChanged(); + return this; + } + + private java.lang.Object metrics_ = ""; + /** + *
+       * 监控采集的指标集合 eg: cpu | memory | health
+       * 
+ * + * string metrics = 3; + * @return The metrics. + */ + public java.lang.String getMetrics() { + java.lang.Object ref = metrics_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + metrics_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * 监控采集的指标集合 eg: cpu | memory | health
+       * 
+ * + * string metrics = 3; + * @return The bytes for metrics. + */ + public com.google.protobuf.ByteString + getMetricsBytes() { + java.lang.Object ref = metrics_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + metrics_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * 监控采集的指标集合 eg: cpu | memory | health
+       * 
+ * + * string metrics = 3; + * @param value The metrics to set. + * @return This builder for chaining. + */ + public Builder setMetrics( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + metrics_ = value; + onChanged(); + return this; + } + /** + *
+       * 监控采集的指标集合 eg: cpu | memory | health
+       * 
+ * + * string metrics = 3; + * @return This builder for chaining. + */ + public Builder clearMetrics() { + + metrics_ = getDefaultInstance().getMetrics(); + onChanged(); + return this; + } + /** + *
+       * 监控采集的指标集合 eg: cpu | memory | health
+       * 
+ * + * string metrics = 3; + * @param value The bytes for metrics to set. + * @return This builder for chaining. + */ + public Builder setMetricsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + metrics_ = value; + onChanged(); + return this; + } + + private long time_ ; + /** + *
+       * 采集时间
+       * 
+ * + * uint64 time = 4; + * @return The time. + */ + @java.lang.Override + public long getTime() { + return time_; + } + /** + *
+       * 采集时间
+       * 
+ * + * uint64 time = 4; + * @param value The time to set. + * @return This builder for chaining. + */ + public Builder setTime(long value) { + + time_ = value; + onChanged(); + return this; + } + /** + *
+       * 采集时间
+       * 
+ * + * uint64 time = 4; + * @return This builder for chaining. + */ + public Builder clearTime() { + + time_ = 0L; + onChanged(); + return this; + } + + private int code_ = 0; + /** + *
+       * 采集响应码
+       * 
+ * + * .com.usthe.common.entity.message.Code code = 5; + * @return The enum numeric value on the wire for code. + */ + @java.lang.Override public int getCodeValue() { + return code_; + } + /** + *
+       * 采集响应码
+       * 
+ * + * .com.usthe.common.entity.message.Code code = 5; + * @param value The enum numeric value on the wire for code to set. + * @return This builder for chaining. + */ + public Builder setCodeValue(int value) { + + code_ = value; + onChanged(); + return this; + } + /** + *
+       * 采集响应码
+       * 
+ * + * .com.usthe.common.entity.message.Code code = 5; + * @return The code. + */ + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.Code getCode() { + @SuppressWarnings("deprecation") + com.usthe.common.entity.message.CollectRep.Code result = com.usthe.common.entity.message.CollectRep.Code.valueOf(code_); + return result == null ? com.usthe.common.entity.message.CollectRep.Code.UNRECOGNIZED : result; + } + /** + *
+       * 采集响应码
+       * 
+ * + * .com.usthe.common.entity.message.Code code = 5; + * @param value The code to set. + * @return This builder for chaining. + */ + public Builder setCode(com.usthe.common.entity.message.CollectRep.Code value) { + if (value == null) { + throw new NullPointerException(); + } + + code_ = value.getNumber(); + onChanged(); + return this; + } + /** + *
+       * 采集响应码
+       * 
+ * + * .com.usthe.common.entity.message.Code code = 5; + * @return This builder for chaining. + */ + public Builder clearCode() { + + code_ = 0; + onChanged(); + return this; + } + + private java.lang.Object msg_ = ""; + /** + *
+       * 采集响应信息
+       * 
+ * + * string msg = 6; + * @return The msg. + */ + public java.lang.String getMsg() { + java.lang.Object ref = msg_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + msg_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * 采集响应信息
+       * 
+ * + * string msg = 6; + * @return The bytes for msg. + */ + public com.google.protobuf.ByteString + getMsgBytes() { + java.lang.Object ref = msg_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + msg_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * 采集响应信息
+       * 
+ * + * string msg = 6; + * @param value The msg to set. + * @return This builder for chaining. + */ + public Builder setMsg( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + msg_ = value; + onChanged(); + return this; + } + /** + *
+       * 采集响应信息
+       * 
+ * + * string msg = 6; + * @return This builder for chaining. + */ + public Builder clearMsg() { + + msg_ = getDefaultInstance().getMsg(); + onChanged(); + return this; + } + /** + *
+       * 采集响应信息
+       * 
+ * + * string msg = 6; + * @param value The bytes for msg to set. + * @return This builder for chaining. + */ + public Builder setMsgBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + msg_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList fields_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureFieldsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + fields_ = new com.google.protobuf.LazyStringArrayList(fields_); + bitField0_ |= 0x00000001; + } + } + /** + *
+       * 采集指标名
+       * 
+ * + * repeated string fields = 7; + * @return A list containing the fields. + */ + public com.google.protobuf.ProtocolStringList + getFieldsList() { + return fields_.getUnmodifiableView(); + } + /** + *
+       * 采集指标名
+       * 
+ * + * repeated string fields = 7; + * @return The count of fields. + */ + public int getFieldsCount() { + return fields_.size(); + } + /** + *
+       * 采集指标名
+       * 
+ * + * repeated string fields = 7; + * @param index The index of the element to return. + * @return The fields at the given index. + */ + public java.lang.String getFields(int index) { + return fields_.get(index); + } + /** + *
+       * 采集指标名
+       * 
+ * + * repeated string fields = 7; + * @param index The index of the value to return. + * @return The bytes of the fields at the given index. + */ + public com.google.protobuf.ByteString + getFieldsBytes(int index) { + return fields_.getByteString(index); + } + /** + *
+       * 采集指标名
+       * 
+ * + * repeated string fields = 7; + * @param index The index to set the value at. + * @param value The fields to set. + * @return This builder for chaining. + */ + public Builder setFields( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * 采集指标名
+       * 
+ * + * repeated string fields = 7; + * @param value The fields to add. + * @return This builder for chaining. + */ + public Builder addFields( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.add(value); + onChanged(); + return this; + } + /** + *
+       * 采集指标名
+       * 
+ * + * repeated string fields = 7; + * @param values The fields to add. + * @return This builder for chaining. + */ + public Builder addAllFields( + java.lang.Iterable values) { + ensureFieldsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, fields_); + onChanged(); + return this; + } + /** + *
+       * 采集指标名
+       * 
+ * + * repeated string fields = 7; + * @return This builder for chaining. + */ + public Builder clearFields() { + fields_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + *
+       * 采集指标名
+       * 
+ * + * repeated string fields = 7; + * @param value The bytes of the fields to add. + * @return This builder for chaining. + */ + public Builder addFieldsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureFieldsIsMutable(); + fields_.add(value); + onChanged(); + return this; + } + + private java.util.List values_ = + java.util.Collections.emptyList(); + private void ensureValuesIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + values_ = new java.util.ArrayList(values_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.usthe.common.entity.message.CollectRep.ValueRow, com.usthe.common.entity.message.CollectRep.ValueRow.Builder, com.usthe.common.entity.message.CollectRep.ValueRowOrBuilder> valuesBuilder_; + + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public java.util.List getValuesList() { + if (valuesBuilder_ == null) { + return java.util.Collections.unmodifiableList(values_); + } else { + return valuesBuilder_.getMessageList(); + } + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public int getValuesCount() { + if (valuesBuilder_ == null) { + return values_.size(); + } else { + return valuesBuilder_.getCount(); + } + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public com.usthe.common.entity.message.CollectRep.ValueRow getValues(int index) { + if (valuesBuilder_ == null) { + return values_.get(index); + } else { + return valuesBuilder_.getMessage(index); + } + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public Builder setValues( + int index, com.usthe.common.entity.message.CollectRep.ValueRow value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValuesIsMutable(); + values_.set(index, value); + onChanged(); + } else { + valuesBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public Builder setValues( + int index, com.usthe.common.entity.message.CollectRep.ValueRow.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.set(index, builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public Builder addValues(com.usthe.common.entity.message.CollectRep.ValueRow value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValuesIsMutable(); + values_.add(value); + onChanged(); + } else { + valuesBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public Builder addValues( + int index, com.usthe.common.entity.message.CollectRep.ValueRow value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValuesIsMutable(); + values_.add(index, value); + onChanged(); + } else { + valuesBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public Builder addValues( + com.usthe.common.entity.message.CollectRep.ValueRow.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.add(builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public Builder addValues( + int index, com.usthe.common.entity.message.CollectRep.ValueRow.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.add(index, builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public Builder addAllValues( + java.lang.Iterable values) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, values_); + onChanged(); + } else { + valuesBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public Builder clearValues() { + if (valuesBuilder_ == null) { + values_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + valuesBuilder_.clear(); + } + return this; + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public Builder removeValues(int index) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.remove(index); + onChanged(); + } else { + valuesBuilder_.remove(index); + } + return this; + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public com.usthe.common.entity.message.CollectRep.ValueRow.Builder getValuesBuilder( + int index) { + return getValuesFieldBuilder().getBuilder(index); + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public com.usthe.common.entity.message.CollectRep.ValueRowOrBuilder getValuesOrBuilder( + int index) { + if (valuesBuilder_ == null) { + return values_.get(index); } else { + return valuesBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public java.util.List + getValuesOrBuilderList() { + if (valuesBuilder_ != null) { + return valuesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(values_); + } + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public com.usthe.common.entity.message.CollectRep.ValueRow.Builder addValuesBuilder() { + return getValuesFieldBuilder().addBuilder( + com.usthe.common.entity.message.CollectRep.ValueRow.getDefaultInstance()); + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public com.usthe.common.entity.message.CollectRep.ValueRow.Builder addValuesBuilder( + int index) { + return getValuesFieldBuilder().addBuilder( + index, com.usthe.common.entity.message.CollectRep.ValueRow.getDefaultInstance()); + } + /** + *
+       * 采集指标值集合(fields作为字段名称与ValueRow映射)
+       * 
+ * + * repeated .com.usthe.common.entity.message.ValueRow values = 8; + */ + public java.util.List + getValuesBuilderList() { + return getValuesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + com.usthe.common.entity.message.CollectRep.ValueRow, com.usthe.common.entity.message.CollectRep.ValueRow.Builder, com.usthe.common.entity.message.CollectRep.ValueRowOrBuilder> + getValuesFieldBuilder() { + if (valuesBuilder_ == null) { + valuesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + com.usthe.common.entity.message.CollectRep.ValueRow, com.usthe.common.entity.message.CollectRep.ValueRow.Builder, com.usthe.common.entity.message.CollectRep.ValueRowOrBuilder>( + values_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + values_ = null; + } + return valuesBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.usthe.common.entity.message.MetricsData) + } + + // @@protoc_insertion_point(class_scope:com.usthe.common.entity.message.MetricsData) + private static final com.usthe.common.entity.message.CollectRep.MetricsData DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.usthe.common.entity.message.CollectRep.MetricsData(); + } + + public static com.usthe.common.entity.message.CollectRep.MetricsData getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MetricsData parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MetricsData(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.MetricsData getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ValueRowOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.usthe.common.entity.message.ValueRow) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * 主键实例,唯一标识这行数据
+     * 
+ * + * string instance = 1; + * @return The instance. + */ + java.lang.String getInstance(); + /** + *
+     * 主键实例,唯一标识这行数据
+     * 
+ * + * string instance = 1; + * @return The bytes for instance. + */ + com.google.protobuf.ByteString + getInstanceBytes(); + + /** + *
+     * 采集指标值
+     * 
+ * + * repeated string columns = 2; + * @return A list containing the columns. + */ + java.util.List + getColumnsList(); + /** + *
+     * 采集指标值
+     * 
+ * + * repeated string columns = 2; + * @return The count of columns. + */ + int getColumnsCount(); + /** + *
+     * 采集指标值
+     * 
+ * + * repeated string columns = 2; + * @param index The index of the element to return. + * @return The columns at the given index. + */ + java.lang.String getColumns(int index); + /** + *
+     * 采集指标值
+     * 
+ * + * repeated string columns = 2; + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. + */ + com.google.protobuf.ByteString + getColumnsBytes(int index); + } + /** + * Protobuf type {@code com.usthe.common.entity.message.ValueRow} + */ + public static final class ValueRow extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.usthe.common.entity.message.ValueRow) + ValueRowOrBuilder { + private static final long serialVersionUID = 0L; + // Use ValueRow.newBuilder() to construct. + private ValueRow(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ValueRow() { + instance_ = ""; + columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ValueRow(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ValueRow( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + instance_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + columns_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + columns_.add(s); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + columns_ = columns_.getUnmodifiableView(); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_ValueRow_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_ValueRow_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.usthe.common.entity.message.CollectRep.ValueRow.class, com.usthe.common.entity.message.CollectRep.ValueRow.Builder.class); + } + + public static final int INSTANCE_FIELD_NUMBER = 1; + private volatile java.lang.Object instance_; + /** + *
+     * 主键实例,唯一标识这行数据
+     * 
+ * + * string instance = 1; + * @return The instance. + */ + @java.lang.Override + public java.lang.String getInstance() { + java.lang.Object ref = instance_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + instance_ = s; + return s; + } + } + /** + *
+     * 主键实例,唯一标识这行数据
+     * 
+ * + * string instance = 1; + * @return The bytes for instance. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getInstanceBytes() { + java.lang.Object ref = instance_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + instance_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int COLUMNS_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList columns_; + /** + *
+     * 采集指标值
+     * 
+ * + * repeated string columns = 2; + * @return A list containing the columns. + */ + public com.google.protobuf.ProtocolStringList + getColumnsList() { + return columns_; + } + /** + *
+     * 采集指标值
+     * 
+ * + * repeated string columns = 2; + * @return The count of columns. + */ + public int getColumnsCount() { + return columns_.size(); + } + /** + *
+     * 采集指标值
+     * 
+ * + * repeated string columns = 2; + * @param index The index of the element to return. + * @return The columns at the given index. + */ + public java.lang.String getColumns(int index) { + return columns_.get(index); + } + /** + *
+     * 采集指标值
+     * 
+ * + * repeated string columns = 2; + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. + */ + public com.google.protobuf.ByteString + getColumnsBytes(int index) { + return columns_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getInstanceBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, instance_); + } + for (int i = 0; i < columns_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, columns_.getRaw(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getInstanceBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, instance_); + } + { + int dataSize = 0; + for (int i = 0; i < columns_.size(); i++) { + dataSize += computeStringSizeNoTag(columns_.getRaw(i)); + } + size += dataSize; + size += 1 * getColumnsList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.usthe.common.entity.message.CollectRep.ValueRow)) { + return super.equals(obj); + } + com.usthe.common.entity.message.CollectRep.ValueRow other = (com.usthe.common.entity.message.CollectRep.ValueRow) obj; + + if (!getInstance() + .equals(other.getInstance())) return false; + if (!getColumnsList() + .equals(other.getColumnsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + INSTANCE_FIELD_NUMBER; + hash = (53 * hash) + getInstance().hashCode(); + if (getColumnsCount() > 0) { + hash = (37 * hash) + COLUMNS_FIELD_NUMBER; + hash = (53 * hash) + getColumnsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.usthe.common.entity.message.CollectRep.ValueRow parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.usthe.common.entity.message.CollectRep.ValueRow prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.usthe.common.entity.message.ValueRow} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.usthe.common.entity.message.ValueRow) + com.usthe.common.entity.message.CollectRep.ValueRowOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_ValueRow_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_ValueRow_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.usthe.common.entity.message.CollectRep.ValueRow.class, com.usthe.common.entity.message.CollectRep.ValueRow.Builder.class); + } + + // Construct using com.usthe.common.entity.message.CollectRep.ValueRow.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + instance_ = ""; + + columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.usthe.common.entity.message.CollectRep.internal_static_com_usthe_common_entity_message_ValueRow_descriptor; + } + + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.ValueRow getDefaultInstanceForType() { + return com.usthe.common.entity.message.CollectRep.ValueRow.getDefaultInstance(); + } + + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.ValueRow build() { + com.usthe.common.entity.message.CollectRep.ValueRow result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.ValueRow buildPartial() { + com.usthe.common.entity.message.CollectRep.ValueRow result = new com.usthe.common.entity.message.CollectRep.ValueRow(this); + int from_bitField0_ = bitField0_; + result.instance_ = instance_; + if (((bitField0_ & 0x00000001) != 0)) { + columns_ = columns_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.columns_ = columns_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.usthe.common.entity.message.CollectRep.ValueRow) { + return mergeFrom((com.usthe.common.entity.message.CollectRep.ValueRow)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.usthe.common.entity.message.CollectRep.ValueRow other) { + if (other == com.usthe.common.entity.message.CollectRep.ValueRow.getDefaultInstance()) return this; + if (!other.getInstance().isEmpty()) { + instance_ = other.instance_; + onChanged(); + } + if (!other.columns_.isEmpty()) { + if (columns_.isEmpty()) { + columns_ = other.columns_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureColumnsIsMutable(); + columns_.addAll(other.columns_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.usthe.common.entity.message.CollectRep.ValueRow parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.usthe.common.entity.message.CollectRep.ValueRow) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object instance_ = ""; + /** + *
+       * 主键实例,唯一标识这行数据
+       * 
+ * + * string instance = 1; + * @return The instance. + */ + public java.lang.String getInstance() { + java.lang.Object ref = instance_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + instance_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * 主键实例,唯一标识这行数据
+       * 
+ * + * string instance = 1; + * @return The bytes for instance. + */ + public com.google.protobuf.ByteString + getInstanceBytes() { + java.lang.Object ref = instance_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + instance_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * 主键实例,唯一标识这行数据
+       * 
+ * + * string instance = 1; + * @param value The instance to set. + * @return This builder for chaining. + */ + public Builder setInstance( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + instance_ = value; + onChanged(); + return this; + } + /** + *
+       * 主键实例,唯一标识这行数据
+       * 
+ * + * string instance = 1; + * @return This builder for chaining. + */ + public Builder clearInstance() { + + instance_ = getDefaultInstance().getInstance(); + onChanged(); + return this; + } + /** + *
+       * 主键实例,唯一标识这行数据
+       * 
+ * + * string instance = 1; + * @param value The bytes for instance to set. + * @return This builder for chaining. + */ + public Builder setInstanceBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + instance_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureColumnsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + columns_ = new com.google.protobuf.LazyStringArrayList(columns_); + bitField0_ |= 0x00000001; + } + } + /** + *
+       * 采集指标值
+       * 
+ * + * repeated string columns = 2; + * @return A list containing the columns. + */ + public com.google.protobuf.ProtocolStringList + getColumnsList() { + return columns_.getUnmodifiableView(); + } + /** + *
+       * 采集指标值
+       * 
+ * + * repeated string columns = 2; + * @return The count of columns. + */ + public int getColumnsCount() { + return columns_.size(); + } + /** + *
+       * 采集指标值
+       * 
+ * + * repeated string columns = 2; + * @param index The index of the element to return. + * @return The columns at the given index. + */ + public java.lang.String getColumns(int index) { + return columns_.get(index); + } + /** + *
+       * 采集指标值
+       * 
+ * + * repeated string columns = 2; + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. + */ + public com.google.protobuf.ByteString + getColumnsBytes(int index) { + return columns_.getByteString(index); + } + /** + *
+       * 采集指标值
+       * 
+ * + * repeated string columns = 2; + * @param index The index to set the value at. + * @param value The columns to set. + * @return This builder for chaining. + */ + public Builder setColumns( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureColumnsIsMutable(); + columns_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * 采集指标值
+       * 
+ * + * repeated string columns = 2; + * @param value The columns to add. + * @return This builder for chaining. + */ + public Builder addColumns( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureColumnsIsMutable(); + columns_.add(value); + onChanged(); + return this; + } + /** + *
+       * 采集指标值
+       * 
+ * + * repeated string columns = 2; + * @param values The columns to add. + * @return This builder for chaining. + */ + public Builder addAllColumns( + java.lang.Iterable values) { + ensureColumnsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, columns_); + onChanged(); + return this; + } + /** + *
+       * 采集指标值
+       * 
+ * + * repeated string columns = 2; + * @return This builder for chaining. + */ + public Builder clearColumns() { + columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + *
+       * 采集指标值
+       * 
+ * + * repeated string columns = 2; + * @param value The bytes of the columns to add. + * @return This builder for chaining. + */ + public Builder addColumnsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureColumnsIsMutable(); + columns_.add(value); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.usthe.common.entity.message.ValueRow) + } + + // @@protoc_insertion_point(class_scope:com.usthe.common.entity.message.ValueRow) + private static final com.usthe.common.entity.message.CollectRep.ValueRow DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.usthe.common.entity.message.CollectRep.ValueRow(); + } + + public static com.usthe.common.entity.message.CollectRep.ValueRow getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ValueRow parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ValueRow(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.usthe.common.entity.message.CollectRep.ValueRow getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_usthe_common_entity_message_MetricsData_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_usthe_common_entity_message_MetricsData_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_usthe_common_entity_message_ValueRow_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_usthe_common_entity_message_ValueRow_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\021collect_rep.proto\022\037com.usthe.common.en" + + "tity.message\"\322\001\n\013MetricsData\022\n\n\002id\030\001 \001(\004" + + "\022\013\n\003app\030\002 \001(\t\022\017\n\007metrics\030\003 \001(\t\022\014\n\004time\030\004" + + " \001(\004\0223\n\004code\030\005 \001(\0162%.com.usthe.common.en" + + "tity.message.Code\022\013\n\003msg\030\006 \001(\t\022\016\n\006fields" + + "\030\007 \003(\t\0229\n\006values\030\010 \003(\0132).com.usthe.commo" + + "n.entity.message.ValueRow\"-\n\010ValueRow\022\020\n" + + "\010instance\030\001 \001(\t\022\017\n\007columns\030\002 \003(\t*b\n\004Code" + + "\022\013\n\007SUCCESS\020\000\022\020\n\014UN_AVAILABLE\020\001\022\020\n\014UN_RE" + + "ACHABLE\020\002\022\022\n\016UN_CONNECTABLE\020\003\022\010\n\004FAIL\020\004\022" + + "\013\n\007TIMEOUT\020\005b\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_com_usthe_common_entity_message_MetricsData_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_com_usthe_common_entity_message_MetricsData_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_usthe_common_entity_message_MetricsData_descriptor, + new java.lang.String[] { "Id", "App", "Metrics", "Time", "Code", "Msg", "Fields", "Values", }); + internal_static_com_usthe_common_entity_message_ValueRow_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_com_usthe_common_entity_message_ValueRow_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_usthe_common_entity_message_ValueRow_descriptor, + new java.lang.String[] { "Instance", "Columns", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/common/src/main/java/com/usthe/common/util/GsonUtil.java b/common/src/main/java/com/usthe/common/util/GsonUtil.java new file mode 100644 index 0000000..4508a84 --- /dev/null +++ b/common/src/main/java/com/usthe/common/util/GsonUtil.java @@ -0,0 +1,41 @@ +package com.usthe.common.util; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import io.etcd.jetcd.ByteSequence; + +import javax.annotation.concurrent.ThreadSafe; +import java.nio.charset.StandardCharsets; + +/** + * gson 工具类 + * @author tomsun28 + * @date 2021/10/16 20:49 + */ +@ThreadSafe +public class GsonUtil { + + private static Gson gson; + + static { + gson = new GsonBuilder().enableComplexMapKeySerialization() + .serializeNulls() + .create(); + } + + public static String toJson(Object source) { + return gson.toJson(source); + } + + public static T fromJson(String jsonStr, Class clazz) { + return gson.fromJson(jsonStr, clazz); + } + + public static T fromJson(ByteSequence byteSequence, Class clazz) { + if (byteSequence == null || byteSequence.isEmpty()) { + return null; + } + return gson.fromJson(byteSequence.toString(StandardCharsets.UTF_8), clazz); + } + +} diff --git a/common/src/main/message/collect_rep.proto b/common/src/main/message/collect_rep.proto new file mode 100644 index 0000000..0b9c5fb --- /dev/null +++ b/common/src/main/message/collect_rep.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; +package com.usthe.common.entity.message; + +message MetricsData +{ + // 监控的ID + uint64 id = 1; + // 监控的类型 eg: linux | mysql | jvm + string app = 2; + // 监控采集的指标集合 eg: cpu | memory | health + string metrics = 3; + // 采集时间 + uint64 time = 4; + // 采集响应码 + Code code = 5; + // 采集响应信息 + string msg = 6; + // 采集指标名 + repeated string fields = 7; + // 采集指标值集合(fields作为字段名称与ValueRow映射) + repeated ValueRow values = 8; +} + +message ValueRow +{ + // 主键实例,唯一标识这行数据 + string instance = 1; + // 采集指标值 + repeated string columns = 2; +} + +enum Code +{ + // 采集成功 + SUCCESS = 0; + // 采集器不可用 + UN_AVAILABLE = 1; + // 对端不可达(网络层icmp) + UN_REACHABLE = 2; + // 对端连接失败(传输层tcp,udp) + UN_CONNECTABLE = 3; + // 数据采集失败(应用层http,ssh,snmp) + FAIL = 4; + // 采集超时 + TIMEOUT = 5; +} \ No newline at end of file diff --git a/manager/pom.xml b/manager/pom.xml new file mode 100644 index 0000000..0bf1bcb --- /dev/null +++ b/manager/pom.xml @@ -0,0 +1,18 @@ + + + + monitor + com.usthe.tancloud + 1.0-SNAPSHOT + + 4.0.0 + + manager + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..99dc15d --- /dev/null +++ b/pom.xml @@ -0,0 +1,129 @@ + + + 4.0.0 + + com.usthe.tancloud + monitor + pom + 1.0-SNAPSHOT + + scheduler + manager + alerter + common + collector + + + + 1.8 + 1.8 + 1.8 + UTF-8 + 1.7.21 + 2.3.0 + 1.18.20 + + 5.7.0 + 4.0.2 + + + + + + + org.springframework.boot + spring-boot-dependencies + 2.4.5 + pom + import + + + javax.xml.bind + jaxb-api + ${xml.bind.version} + + + + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + org.junit.jupiter + junit-jupiter + ${junit.version} + test + + + org.easymock + easymock + ${easymock.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.8 + + + rulesets/java/ali-comment.xml + rulesets/java/ali-concurrent.xml + rulesets/java/ali-constant.xml + rulesets/java/ali-exception.xml + + rulesets/java/ali-naming.xml + rulesets/java/ali-oop.xml + rulesets/java/ali-orm.xml + rulesets/java/ali-other.xml + rulesets/java/ali-set.xml + + true + + + + validate + validate + + check + + + + + + com.alibaba.p3c + p3c-pmd + 1.3.0 + + + + + + \ No newline at end of file