Skip to content

Commit

Permalink
[collector]bugfix recurring tasks caused by priority processing excep…
Browse files Browse the repository at this point in the history
…tion (#663)
  • Loading branch information
tomsun28 authored Feb 21, 2023
1 parent b456aa0 commit cd47df8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ public void dispatchCollectData(Timeout timeout, Metrics metrics, CollectRep.Met
// If the availability collection fails, the next indicator group scheduling will be cancelled and the next round of scheduling will be entered directly.
// 若metricsSet为null表示执行完成
// 或判断采集指标组是否优先级为0,即为可用性采集指标组 若可用性采集失败 则取消后面的指标组调度直接进入下一轮调度
if (metricsSet == null
|| (metrics.getPriority() == (byte) 0 && metricsData.getCode() != CollectRep.Code.SUCCESS)) {
boolean isAvailableCollectFailed = metricsSet != null && !metricsSet.isEmpty()
&& metrics.getPriority() == (byte) 0 && metricsData.getCode() != CollectRep.Code.SUCCESS;
if (metricsSet == null || isAvailableCollectFailed) {
// The collection and execution of all index groups of this job are completed.
// The periodic task pushes the task to the time wheel again.
// First, determine the execution time of the task and the task collection interval.
Expand Down
11 changes: 5 additions & 6 deletions common/src/main/java/com/usthe/common/entity/job/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public class Job {
* 127 - lastPriorMetrics
*/
@JsonIgnore
private transient List<Set<Metrics>> priorMetrics;
private transient LinkedList<Set<Metrics>> priorMetrics;

/**
* collector use - Temporarily store one-time task indicator group response data
Expand Down Expand Up @@ -194,11 +194,10 @@ public synchronized Set<Metrics> getNextCollectMetrics(Metrics metrics, boolean
if (priorMetrics == null || priorMetrics.isEmpty()) {
return null;
}
Set<Metrics> metricsSet = priorMetrics.get(0);
Set<Metrics> metricsSet = priorMetrics.peek();
if (first) {
if (metricsSet.isEmpty()) {
log.error("metrics must has one [availability] metrics at least.");

}
return metricsSet;
}
Expand All @@ -211,11 +210,11 @@ public synchronized Set<Metrics> getNextCollectMetrics(Metrics metrics, boolean
id, monitorId, app, metrics.getName());
}
if (metricsSet.isEmpty()) {
priorMetrics.remove(0);
if (priorMetrics.size() == 0) {
priorMetrics.poll();
if (priorMetrics.isEmpty()) {
return null;
}
return priorMetrics.get(0);
return priorMetrics.peek();
} else {
return Collections.emptySet();
}
Expand Down
2 changes: 1 addition & 1 deletion manager/src/main/resources/define/app/app-nacos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ metrics:
parseType: jsonPath
parseScript: $.measurements[*]
- name: memory
priority: 0
priority: 1
fields:
- field: jvm_memory_used
type: 0
Expand Down
4 changes: 1 addition & 3 deletions manager/src/main/resources/define/app/app-zookeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ metrics:
parseType: netcat

- name: stats
priority: 0
priority: 1
# 指标组中的具体监控指标
fields:
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
Expand Down Expand Up @@ -163,8 +163,6 @@ metrics:
- field: zk_min_latency
type: 0
unit: ms


# 协议
protocol: ssh
ssh:
Expand Down

0 comments on commit cd47df8

Please sign in to comment.