文档章节

TBSchedule源码阅读1-TBScheduleManagerFactory

穿林度水
 穿林度水
发布于 2016/11/07 14:27
字数 1294
阅读 28
收藏 0

TBSchedule

1 TBScheduleManagerFactory 初始化
    成员变量
    ZKManager;
    IScheduleDataManager;
    ScheduleStrategyDataManager4ZK;
    ManagerFactoryTimerTask; TimerTask
    InitialThread 内部类
    1.1 init 方法初始化
         1.1.1读取schedule.xml 配置的 zookeeper
         1.1.2 ConsoleManager.setScheduleManagerFactory(this);
         1.1.3 this.zkManager = new ZKManager(p);
                private void connect() throws Exception {
                    CountDownLatch connectionLatch = new CountDownLatch(1);
                    createZookeeper(connectionLatch);
                    connectionLatch.await(10,TimeUnit.SECONDS);
                }
         1.1.4 初始化相关信息
            initialThread = new initialThread(this); 检测zookeeper状态,在Zk状态正常后回调数据初始化,初始化数据 initialData
            initialThread.setName("TBScheduleManagerFactory-initialThread");
            initialThread.start();
            1.1.4.1 initialThread run方法:initialData
                public void initialData() throws Exception{
                        this.zkManager.initial(); //创建根路径,设置版本信息
                        this.scheduleDataManager = new ScheduleDataManager4ZK(this.zkManager);//调度配置中心客户端接口,可以有基于数据库的实现,可以有基于ConfigServer的实现
                        this.scheduleStrategyManager  = new ScheduleStrategyDataManager4ZK(this.zkManager);//调度策略
                        if (this.start == true) {
                            // 注册调度管理器
                            this.scheduleStrategyManager.registerManagerFactory(this);
                            if(timer == null){
                                timer = new Timer("TBScheduleManagerFactory-Timer");
                            }
                            if(timerTask == null){
                                timerTask = new ManagerFactoryTimerTask(this);//Zookeeper连接失败,关闭所有的任务后,重新连接Zookeeper服务器
                                timer.schedule(timerTask, 2000,this.timerInterval);
                            }
                        }
                }
                ScheduleDataManager4ZK :构造方法 zkManager
                    建立 根路径+/baseTaskType
                    获取 zookeeper 时间,同本地时间比较
                ScheduleStrategyDataManager4ZK : 构造方法    zkManager
                    建立 根路径+/strategy
                    建立 根路径+/factory
                注册调度管理器
                    根路径+/factory 写入TBScheduleManagerFactory 的id: ip+"$"+hostname+"$"+随机数
                    遍历根路径+/strategy,
                        如果//暂停或者不在IP范围 //添加可管理TaskType CreateMode.EPHEMERAL(断开连接节点就删除)
                        否则//清除原来注册的Factory
                ManagerFactoryTimerTask : Zookeeper连接失败,关闭所有的任务后,重新连接Zookeeper服务器
    1.2 zookeeper 路径
   

/tbSchedule/zmlTbScheduleTest[v.1][taobao-pamirs-schedule-3.0.0]
/tbSchedule/zmlTbScheduleTest/baseTaskType
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task[v.3][{"baseTaskType":"DBDemoSingle_task","heartBeatRate":5000,"judgeDeadInterval":60000,"sleepTimeNoData":500,"sleepTimeInterval":0,"fetchDataNumber":500,"executeNumber":1,"threadNumber":5,"processorType":"SLEEP","permitRunStartTime":"0 * * * * ?","expireOwnSignInterval":1.0,"dealBeanName":"demoTaskBean","taskParameter":"","taskKind":"static","taskItems":["1","2","3","4","5","6"],"maxTaskItemsOfOneThreadGroup":0,"version":0,"sts":"resume"}]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/server[v.4][reload=true]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/server/DBDemoSingle_task$192.168.255.1$29C5AFD33E254391B2D7FA01E8D88A57$0000000013[v.21][{"uuid":"DBDemoSingle_task$192.168.255.1$29C5AFD33E254391B2D7FA01E8D88A57$0000000013","id":16103079872455,"taskType":"DBDemoSingle_task","baseTaskType":"DBDemoSingle_task","ownSign":"BASE","ip":"192.168.255.1","hostName":"zhuml","threadNum":5,"registerTime":"2016-10-30 13:59:19","heartBeatTime":"2016-10-30 14:00:10","lastFetchDataTime":"2016-10-30 14:00:10","dealInfoDesc":"到达开始时间,resume调度:FetchDataCount\u003d3,FetchDataNum\u003d1500,DealDataSucess\u003d1005,DealDataFail\u003d0,DealSpendTime\u003d50501,otherCompareCount\u003d0","nextRunStartTime":"2016-10-30 14:01:00","nextRunEndTime":"当不能获取到数据的时候pause","version":20,"isRegister":true,"managerFactoryUUID":"192.168.255.1$zhuml$0BDBD014D78042A88F8DF06CF781C452$0000000004"}]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/server/DBDemoSingle_task$192.168.255.1$42BE86701CF14F5487EDC966DD484262$0000000014[v.21][{"uuid":"DBDemoSingle_task$192.168.255.1$42BE86701CF14F5487EDC966DD484262$0000000014","id":16103064628283,"taskType":"DBDemoSingle_task","baseTaskType":"DBDemoSingle_task","ownSign":"BASE","ip":"192.168.255.1","hostName":"zhuml","threadNum":5,"registerTime":"2016-10-30 13:59:20","heartBeatTime":"2016-10-30 14:00:10","lastFetchDataTime":"2016-10-30 14:00:10","dealInfoDesc":"到达开始时间,resume调度:FetchDataCount\u003d3,FetchDataNum\u003d1500,DealDataSucess\u003d1010,DealDataFail\u003d0,DealSpendTime\u003d50768,otherCompareCount\u003d0","nextRunStartTime":"2016-10-30 14:01:00","nextRunEndTime":"当不能获取到数据的时候pause","version":20,"isRegister":true,"managerFactoryUUID":"192.168.255.1$zhuml$0BDBD014D78042A88F8DF06CF781C452$0000000004"}]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/server/DBDemoSingle_task$192.168.255.1$B4B0C906A87A4944BD19CFBB68FBEDF7$0000000012[v.21][{"uuid":"DBDemoSingle_task$192.168.255.1$B4B0C906A87A4944BD19CFBB68FBEDF7$0000000012","id":16103045591231,"taskType":"DBDemoSingle_task","baseTaskType":"DBDemoSingle_task","ownSign":"BASE","ip":"192.168.255.1","hostName":"zhuml","threadNum":5,"registerTime":"2016-10-30 13:59:19","heartBeatTime":"2016-10-30 14:00:10","lastFetchDataTime":"2016-10-30 14:00:10","dealInfoDesc":"到达开始时间,resume调度:FetchDataCount\u003d3,FetchDataNum\u003d1500,DealDataSucess\u003d1000,DealDataFail\u003d0,DealSpendTime\u003d50233,otherCompareCount\u003d0","nextRunStartTime":"2016-10-30 14:01:00","nextRunEndTime":"当不能获取到数据的时候pause","version":20,"isRegister":true,"managerFactoryUUID":"192.168.255.1$zhuml$0BDBD014D78042A88F8DF06CF781C452$0000000004"}]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/server/DBDemoSingle_task$192.168.255.1$F67CFFE9F5DA4E008AF7BB694C1197E1$0000000011[v.21][{"uuid":"DBDemoSingle_task$192.168.255.1$F67CFFE9F5DA4E008AF7BB694C1197E1$0000000011","id":16103071968380,"taskType":"DBDemoSingle_task","baseTaskType":"DBDemoSingle_task","ownSign":"BASE","ip":"192.168.255.1","hostName":"zhuml","threadNum":5,"registerTime":"2016-10-30 13:59:19","heartBeatTime":"2016-10-30 14:00:10","lastFetchDataTime":"2016-10-30 14:00:10","dealInfoDesc":"到达开始时间,resume调度:FetchDataCount\u003d2,FetchDataNum\u003d1000,DealDataSucess\u003d1000,DealDataFail\u003d0,DealSpendTime\u003d50277,otherCompareCount\u003d0","nextRunStartTime":"2016-10-30 14:01:00","nextRunEndTime":"当不能获取到数据的时候pause","version":20,"isRegister":true,"managerFactoryUUID":"192.168.255.1$zhuml$0BDBD014D78042A88F8DF06CF781C452$0000000004"}]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem[v.12][DBDemoSingle_task$192.168.255.1$F67CFFE9F5DA4E008AF7BB694C1197E1$0000000011]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/1
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/1/cur_server[v.1][DBDemoSingle_task$192.168.255.1$F67CFFE9F5DA4E008AF7BB694C1197E1$0000000011]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/1/deal_desc[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/1/parameter[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/1/req_server
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/1/sts[v.0][ACTIVTE]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/2
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/2/cur_server[v.1][DBDemoSingle_task$192.168.255.1$F67CFFE9F5DA4E008AF7BB694C1197E1$0000000011]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/2/deal_desc[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/2/parameter[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/2/req_server
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/2/sts[v.0][ACTIVTE]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/3
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/3/cur_server[v.1][DBDemoSingle_task$192.168.255.1$B4B0C906A87A4944BD19CFBB68FBEDF7$0000000012]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/3/deal_desc[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/3/parameter[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/3/req_server
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/3/sts[v.0][ACTIVTE]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/4
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/4/cur_server[v.1][DBDemoSingle_task$192.168.255.1$B4B0C906A87A4944BD19CFBB68FBEDF7$0000000012]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/4/deal_desc[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/4/parameter[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/4/req_server
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/4/sts[v.0][ACTIVTE]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/5
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/5/cur_server[v.1][DBDemoSingle_task$192.168.255.1$29C5AFD33E254391B2D7FA01E8D88A57$0000000013]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/5/deal_desc[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/5/parameter[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/5/req_server
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/5/sts[v.0][ACTIVTE]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/6
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/6/cur_server[v.1][DBDemoSingle_task$192.168.255.1$42BE86701CF14F5487EDC966DD484262$0000000014]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/6/deal_desc[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/6/parameter[v.0][]
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/6/req_server
/tbSchedule/zmlTbScheduleTest/baseTaskType/DBDemoSingle_task/DBDemoSingle_task/taskItem/6/sts[v.0][ACTIVTE]
/tbSchedule/zmlTbScheduleTest/factory
/tbSchedule/zmlTbScheduleTest/factory/192.168.255.1$zhuml$0BDBD014D78042A88F8DF06CF781C452$0000000004
/tbSchedule/zmlTbScheduleTest/strategy
/tbSchedule/zmlTbScheduleTest/strategy/DBDemoSingle-stratrery[v.0][{"strategyName":"DBDemoSingle-stratrery","IPList":["127.0.0.1"],"numOfSingleServer":0,"assignNum":4,"kind":"Schedule","taskName":"DBDemoSingle_task","taskParameter":"","sts":"resume"}]
/tbSchedule/zmlTbScheduleTest/strategy/DBDemoSingle-stratrery/192.168.255.1$zhuml$0BDBD014D78042A88F8DF06CF781C452$0000000004[v.28][{"strategyName":"DBDemoSingle-stratrery","uuid":"192.168.255.1$zhuml$0BDBD014D78042A88F8DF06CF781C452$0000000004","requestNum":4,"currentNum":0,"message":""}]

1.3 ManagerFactoryTimerTask 定时任务 :this.factory.refresh();
this.factory.refresh(); 判断任务状态 详细说明见 TBSchedule源码阅读2-TBScheduleManagerFactory 定时任务ManagerFactoryTimerTask

© 著作权归作者所有

穿林度水
粉丝 0
博文 250
码字总数 167120
作品 0
海淀
程序员
私信 提问
TBSchedule应用实战(零)—— 前言

TaoBaoSchedule(以下简称tbs)是国产市面上最早开源得一款“分布式定时任务调度”框架。开源之初因其卓越的性能、近乎零侵入的api设计、去中心化的设计思想、故障自动转移等等特性,几乎是一...

Wednesday_OSC
2017/12/18
923
0
tbschedule中创建策略之后为什么输入的中文乱码了 怎么解决

tbschedule中创建策略之后为什么输入的中文乱码了 该怎么解决 tBScheduleManagerFactory.getScheduleStrategyManager() .createScheduleStrategy(scheduleStrategy); List list = tBSchedul......

xujibai
2016/06/01
95
0
球推荐一个好用的开源的企业级定时调度任务的开源框架

类似tbschedule这样的,不过tbschedule常年没人维护了,存在许多bug,开得自己二次开发,不是很好用!求推荐一个类似的开源工具

小武0515
2017/07/18
199
1
企业业务数据处理用“work”还是“MQ”

  近期公司在做架构梳理已经项目架构方向,不知不觉就引起了使用“work”跑数据还是用“MQ”进行跑数据的争论! 对于争论这件事在各行各业都有,其实我觉得针对“争论”这个词的根源在于一...

zygfengyuwuzu
2018/08/29
0
0
分布式调度平台 XXL_Job

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 https://blog.csdn.net/wxb141001yxx/article/details/93927459 Where? 发展历史 特性发展 ...

Jessica-小波
06/28
0
0

没有更多内容

加载失败,请刷新页面

加载更多

ArrayList输出的几种方法

ArrayList输出的几种方法!!! import java.util.ArrayList;import java.util.Iterator;import java.util.List; public class ArrayList1 {    public static void main(Str......

柒礼拜
9分钟前
3
0
ZKEYS公有云管理系统账号注册流程

1.进入ZKEYS官网,单击首页右上角免费注册按钮 2.选择注册方式,有手机注册和有限注册两种 3.填写手机或邮箱,设置密码 4.注册完成,即可登录ZKEYS会员中心 单击右上角免费注册按钮 填写手机...

BirdCloud
11分钟前
3
0
好程序员web前端分享web前端入门知识

好程序员web前端分享web前端入门知识,给大家分享一些Web前端工程师要掌握的基础知识和技能,下面一起来看看。 1、网页的基本结构(HTML、CSS) HTML是一种标记语言,而不是编程语言,最基本是...

好程序员官网
14分钟前
4
0
使用pyinstaller打包qt程序提示 找不到.dll问题

使用pyinstaller打包qt程序,运行时提示 找不到.dll问题。 import osimport sysif hasattr(sys, 'frozen'): os.environ['PATH'] = sys._MEIPASS + ";" + os.environ['PATH'] 需要在......

開援带碼
15分钟前
4
0
mysql导入数据库

原链接:https://msd.misuland.com/pd/3223833238703185046 发现row size长度过长,导致出现错误: 解决方案: 查询系统参数: show variables like '%innodb_strict_mode%';show variab......

tobej
17分钟前
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部