优化重试中数据监控
This commit is contained in:
byteblogs168 2023-01-14 20:47:58 +08:00
parent db09bc4d9c
commit 69ef41cbaf
3 changed files with 8 additions and 6 deletions

View File

@ -12,6 +12,7 @@ public interface RetryTaskMapper extends BaseMapper<RetryTask> {
int deleteBatch(@Param("ids") List<Long> ids, @Param("partition") Integer partition); int deleteBatch(@Param("ids") List<Long> ids, @Param("partition") Integer partition);
int countAllRetryTask(@Param("partition") Integer partition); int countAllRetryTaskByRetryStatus(@Param("partition") Integer partition,
@Param("retryStatus") Integer retryStatus);
} }

View File

@ -4,6 +4,7 @@ import com.x.retry.common.core.alarm.Alarm;
import com.x.retry.common.core.alarm.AlarmContext; import com.x.retry.common.core.alarm.AlarmContext;
import com.x.retry.common.core.alarm.AltinAlarmFactory; import com.x.retry.common.core.alarm.AltinAlarmFactory;
import com.x.retry.common.core.enums.NotifySceneEnum; import com.x.retry.common.core.enums.NotifySceneEnum;
import com.x.retry.common.core.enums.RetryStatusEnum;
import com.x.retry.common.core.log.LogUtils; import com.x.retry.common.core.log.LogUtils;
import com.x.retry.common.core.util.EnvironmentUtils; import com.x.retry.common.core.util.EnvironmentUtils;
import com.x.retry.common.core.util.HostUtils; import com.x.retry.common.core.util.HostUtils;
@ -69,7 +70,7 @@ public class AlarmNotifyThreadSchedule {
continue; continue;
} }
int count = retryTaskMapper.countAllRetryTask(groupConfig.getGroupPartition()); int count = retryTaskMapper.countAllRetryTaskByRetryStatus(groupConfig.getGroupPartition(), RetryStatusEnum.RUNNING.getLevel());
if (count > notifyConfig.getNotifyThreshold()) { if (count > notifyConfig.getNotifyThreshold()) {
// 预警 // 预警
AlarmContext context = AlarmContext.build() AlarmContext context = AlarmContext.build()

View File

@ -21,7 +21,7 @@
create_dt, update_dt create_dt, update_dt
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from retry_task_${partition} from retry_task_${partition}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
@ -51,10 +51,10 @@
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from retry_task_${partition} where retry_status = #{retryStatus,jdbcType=TINYINT} limit 1000 from retry_task_${partition} where retry_status = #{retryStatus,jdbcType=TINYINT} limit 1000
</select> </select>
<select id="countAllRetryTask" resultType="int"> <select id="countAllRetryTaskByRetryStatus" resultType="int">
select select
count(*) count(*)
from retry_task_${partition} from retry_task_${partition} where retry_status = #{retryStatus}
</select> </select>
<select id="selectRetryTaskByGroupIdAndSceneId" resultMap="BaseResultMap"> <select id="selectRetryTaskByGroupIdAndSceneId" resultMap="BaseResultMap">
select select
@ -66,4 +66,4 @@
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from retry_task_${partition} from retry_task_${partition}
</select> </select>
</mapper> </mapper>