XXL-JOB 架构设计图
2023-08-09 15:16:43 0 举报
类图、定时器、XXL-JOb
作者其他创作
大纲/内容
slowTriggerPool
启动扫描配置
入口方法:com.caic.job.core.executor.impl.XxlJobSpringExecutor#initJobHandlerMethodRepository功能描述:扫描注册XxlJob任务,调用super.registJobHandler注册执行器入口
monitorThread线程:负责巡检触发失败任务和执行失败的任务。1、当还有剩余失败次数,出发重新调度,更新日志;2、如果失败出发告警,更新任务日志
ExecutorBizClient
- String addressUrl- String accessToken
//定义RPC通信
任务出发执行线程通过定义线程池最大线程数来定义fast/slow的线程执行
TriggerCallbackThread
- static TriggerCallbackThread instance = new TriggerCallbackThread()- static String failCallbackFilePath = XxlJobFileAppender.getLogPath().concat(File.separator).concat(\"callbacklog\").concat(File.separator)- static String failCallbackFileName = failCallbackFilePath.concat(\"caic-job-callback-{x}\").concat(\".log\")- LinkedBlockingQueue<HandleCallbackParam> callBackQueue = new LinkedBlockingQueue<HandleCallbackParam>()- Thread triggerCallbackThread- Thread triggerRetryCallbackThread- volatile boolean toStop = false
+ static void pushCallBack(HandleCallbackParam callback)+ void start()+ void toStop()
JobFailMonitorHelper
- static JobCompleteHelper instance- ThreadPoolExecutor callbackThreadPool- Thread monitorThread- volatile boolean toStop
//包装类方法+ static void toStart()+ static void toStop()
XxlJobScheduler.getExecutorBiz(address)
scheduleThread线程:实时巡检调度任务。1、当任务调度时间过期,判断过期策略,如果是立即执行,则执行。2、当任务可调度,则JobTriggerPoolHelper.trigger执行。ringThread线程:频繁调度任务执行器。暂时无用。
JobTrigger
+ void trigger() //具体任务调度
服务端启动设计
init(){ initI18n() JobTriggerPoolHelper.toStart() JobRegistryHelper.getInstance().start() JobFailMonitorHelper.getInstance().start() JobCompleteHelper.getInstance().start() JobLogReportHelper.getInstance().start() JobScheduleHelper.getInstance().start()}
JobRegistryHelper
- ThreadPoolExecutor registryOrRemoveThreadPool- Thread registryMonitorThread- volatile boolean toStop //控制任务结束开关
runExecutor
logrThread线程:负责实时统计报表和日志清理处理
JobAlarmer
- ApplicationContext applicationContext- List<JobAlarm> jobAlarmList
<interface>ExecutorBiz
- ReturnT<String> beat()- ReturnT<String> idleBeat(IdleBeatParam idleBeatParam)- ReturnT<String> run(TriggerParam triggerParam)- ReturnT<String> kill(KillParam killParam)- ReturnT<LogResult> log(LogParam logParam)
callbackThreadPool线程池:异步处理执行器返回的结果monitorThread线程:巡检任务结果丢失处理:调度记录停留在 \"运行中\" 状态超过10min,且对应执行器心跳注册失败不在线,则将本地调度主动标记失败;
环形回调任务处理器。如果任务执行结果放在队列中,该线程消费回调结果。
ThreadPoolExecutor
destroy(){ JobScheduleHelper.getInstance().toStop() JobLogReportHelper.getInstance().toStop() JobCompleteHelper.getInstance().toStop() JobFailMonitorHelper.getInstance().toStop() JobRegistryHelper.getInstance().toStop() JobTriggerPoolHelper.toStop();}
自定义文件系统,存储日志框架中间日志
XxlJobSpringExecutor
- static ApplicationContext applicationContext
DingDingAlarm
XxlJobFileAppender
+ static void initLogPath(String logPath)+ static String getLogPath() + static String getGlueSrcPath()+ static String makeLogFileName+ static void appendLog+ static LogResult readLog+ static String readLines(File logFile)
XxlJobAdminConfig
- static XxlJobAdminConfig adminConfig- XxlJobScheduler xxlJobScheduler- XxlJobLogDao xxlJobLogDao- XxlJobInfoDao xxlJobInfoDao- XxlJobRegistryDao xxlJobRegistryDao- XxlJobGroupDao xxlJobGroupDao- XxlJobLogReportDao xxlJobLogReportDao- JavaMailSender mailSender- DataSource dataSource- JobAlarmer jobAlarmer
+void afterPropertiesSet()
XxlJobExecutor
- static List<AdminBiz> adminBizList- static JobBizServiceFactory jobBizServiceFactoryfont color=\"#323232\
registryMonitorThread线程:负责定时诊断注册excutor——address是否存货,然后把活着的客户端同步到xxlJobGroupDao
JobScheduleHelper
<interface>JobAlarm
JobLogReportHelper
- static JobLogReportHelper instance- Thread logrThread- volatile boolean toStop
定时器:清理客户端定时任务日志
JobLogFileCleanThread
- static JobLogFileCleanThread instance- Thread localThread- volatile boolean toStop
+ void start(final long logRetentionDays)
- static JobFailMonitorHelper instance - Thread monitorThread- volatile boolean toStop
XxlJobScheduler
+ static ExecutorBiz getExecutorBiz(String address)+ void init() throws Exception //启动定时任务线程+ void destroy() throws Exception //安全管理定时任务线程
JobTriggerPoolHelper
EmailJobAlarm
fastTriggerPool
<interface>SmartInitializingSingleton
+ afterSingletonsInstantiated()
0 条评论
回复 删除
下一页