Skip to content

Commit

Permalink
build the back-end of help massage component (#1160)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuting Nie <yvettemisaki@outlook.com>
  • Loading branch information
FanTuanCat authored Aug 16, 2023
1 parent 34c716b commit 25b6398
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public class Job {
* en-US: PING CONNECT
*/
private Map<String, String> name;
/**
* The description and help of the monitoring type
* zh-CN: PING连通性 - 支持您使用在线配置对端服务的IP或域名地址,监控本机网络与对端网络的PING可连通性。
* en-US: PING CONNECT - You can use the IP address or domain address of the peer service to monitor the PING connectivity between the local network and the peer network.
*/
private Map<String, String> help;
/**
* Task dispatch start timestamp
* 任务派发开始时间戳
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class AppServiceImpl implements AppService, CommandLineRunner {

@Autowired
private MonitorDao monitorDao;

private final Map<String, Job> appDefines = new ConcurrentHashMap<>();

@Override
Expand Down Expand Up @@ -118,15 +118,22 @@ public List<String> getAppDefineMetricNames(String app) {
public Map<String, String> getI18nResources(String lang) {
Map<String, String> i18nMap = new HashMap<>(128);
for (Job job : appDefines.values()) {
// todo needs to support the indicator name
// 后面需要支持指标名称
// TODO needs to support the metrics name i18n
// TODO 后面需要支持指标名称国际化
Map<String, String> name = job.getName();
if (name != null && !name.isEmpty()) {
String i18nName = Optional.ofNullable(name.get(lang)).orElse(name.values().stream().findFirst().orElse(null));
if (i18nName != null) {
i18nMap.put("monitor.app." + job.getApp(), i18nName);
}
}
Map<String, String> help = job.getHelp();
if (help != null && !help.isEmpty()) {
String i18nHelp = Optional.ofNullable(help.get(lang)).orElse(help.values().stream().findFirst().orElse(null));
if (i18nHelp != null) {
i18nMap.put("monitor.app." + job.getApp() + ".help", i18nHelp);
}
}
for (ParamDefine paramDefine : job.getParams()) {
Map<String, String> paramDefineName = paramDefine.getName();
if (paramDefineName != null && !paramDefineName.isEmpty()) {
Expand Down Expand Up @@ -264,7 +271,7 @@ private void verifyDefineAppContent(Job app, boolean isModify) {
boolean hasAvailableMetrics = app.getMetrics().stream().anyMatch(item -> item.getPriority() == 0);
Assert.isTrue(hasAvailableMetrics, "monitoring template metrics list must have one priority 0 metrics");
if (!isModify) {
Assert.isNull(appDefines.get(app.getApp().toLowerCase()),
Assert.isNull(appDefines.get(app.getApp().toLowerCase()),
"monitoring template name " + app.getApp() + " already exists.");
}
}
Expand Down Expand Up @@ -338,8 +345,8 @@ public void run(String... args) throws Exception {
log.info("load define path {}", defineAppPath);
for (File appFile : Objects.requireNonNull(directory.listFiles())) {
if (appFile.exists() && appFile.isFile()) {
if (appFile.isHidden()
|| (!appFile.getName().endsWith("yml") && !appFile.getName().endsWith("yaml"))) {
if (appFile.isHidden()
|| (!appFile.getName().endsWith("yml") && !appFile.getName().endsWith("yaml"))) {
log.error("Ignore this template file: {}.", appFile.getName());
continue;
}
Expand Down
5 changes: 5 additions & 0 deletions manager/src/main/resources/define/app-a_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ app: a_example
name:
zh-CN: 模拟应用
en-US: EXAMPLE APP
# The description and help of this monitoring type
# 监控类型的帮助描述信息
help:
zh-CN: PING连通性 - Hertzbeat 支持您使用在线配置对端服务的IP或域名地址,监控本机网络与对端网络的PING可连通性。
en-US: PING CONNECT - You can use the IP address or domain address of the peer service to monitor the PING connectivity between the local network and the peer network.
# 监控所需输入参数定义(根据定义渲染页面UI)
# Input params define for monitoring(render web ui by the definition)
params:
Expand Down

0 comments on commit 25b6398

Please sign in to comment.