[manager,collector]新增mysql指标,采集器调度第0优先级失败则取消后续的优化

This commit is contained in:
tomsun28
2022-03-03 11:09:14 +08:00
parent c606b5596d
commit f3557b2859
5 changed files with 85 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
package com.usthe.collector.collect.database;
import com.mysql.cj.jdbc.exceptions.CommunicationsException;
import com.usthe.collector.collect.AbstractCollect;
import com.usthe.collector.collect.common.cache.CacheIdentifier;
import com.usthe.collector.collect.common.cache.CommonCache;
@@ -68,9 +69,12 @@ public class JdbcCommonCollect extends AbstractCollect {
builder.setMsg("Not support database query type: " + jdbcProtocol.getQueryType());
break;
}
} catch (CommunicationsException communicationsException) {
log.warn("Jdbc sql error: {}, code: {}.", communicationsException.getMessage(), communicationsException.getErrorCode());
builder.setCode(CollectRep.Code.UN_REACHABLE);
builder.setMsg("Query Error: " + communicationsException.getMessage() + " Code: " + communicationsException.getErrorCode());
} catch (SQLException sqlException) {
log.error("Jdbc sql error: {}, code: {}.", sqlException.getMessage(),
sqlException.getErrorCode(), sqlException);
log.warn("Jdbc sql error: {}, code: {}.", sqlException.getMessage(), sqlException.getErrorCode());
builder.setCode(CollectRep.Code.FAIL);
builder.setMsg("Query Error: " + sqlException.getMessage() + " Code: " + sqlException.getErrorCode());
} catch (Exception e) {

View File

@@ -144,7 +144,10 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
if (job.isCyclic()) {
// 若是异步的周期性循环任务,直接发送指标组的采集数据到消息中间件
kafkaDataExporter.send(metricsData);
if (metricsSet == null) {
// 若metricsSet为null表示执行完成
// 或判断采集指标组是否优先级为0即为可用性采集指标组 若可用性采集失败 则取消后面的指标组调度直接进入下一轮调度
if (metricsSet == null
|| (metrics.getPriority() == (byte)0 && metricsData.getCode() != CollectRep.Code.SUCCESS)) {
// 此Job所有指标组采集执行完成
// 周期性任务再次将任务push到时间轮
// 先判断此次任务执行时间与任务采集间隔时间