当前位置:网站首页>[cloud native] use of Nacos taskmanager task management
[cloud native] use of Nacos taskmanager task management
2022-07-25 20:23:00 【InfoQ】
1、 Task management class
AbstractTask
/* The interval between two processes of a task , In milliseconds */
private long taskInterval;
/* The last time the task was processed , In milliseconds */
private long lastProcessTime;
/* TaskManager Determine whether you need to deal with this Task, Subclasses can Override This function implements its own logic
*/
public boolean shouldProcess() {
return (System.currentTimeMillis() - this.lastProcessTime >= this.taskInterval);
}
TaskProcessor Task processor
boolean process(String taskType, AbstractTask task);
TaskManager Task management class
/** Tasks to be consumed AbstractTask**/
private final ConcurrentHashMap<String, AbstractTask> tasks = new ConcurrentHashMap<String, AbstractTask>();
/** Mission AbstractTask Corresponding task executor TaskProcessor**/
private final ConcurrentHashMap<String, TaskProcessor> taskProcessors =new ConcurrentHashMap<String, TaskProcessor>();
/** Default actuator **/
private TaskProcessor defaultTaskProcessor;
2、 Use cases
DumpTask


DumpProcessor
public boolean process(String taskType, AbstractTask task)
3、DumpAllTask Where the task triggers execution
DumpService initialization Dump Configuration information
@PostConstruct
public void init() {
DumpAllProcessor dumpAllProcessor = new DumpAllProcessor(this);
/** stay new This TaskManager Class time , A thread dedicated to the task has already started , But there is no task at this time Task Add in **/
dumpAllTaskMgr = new TaskManager( "com.alibaba.nacos.server.DumpAllTaskManager");
dumpAllTaskMgr.setDefaultTaskProcessor(dumpAllProcessor);
Runnable dumpAll = new Runnable() {
@Override
public void run() {
dumpAllTaskMgr.addTask(DumpAllTask.TASK_ID, new DumpAllTask());
}
};
/** Every time 10 Once per minute DumpAll operation **/
TimerTaskService.scheduleWithFixedDelay(dumpAll, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE,
TimeUnit.MINUTES);
}
processingThread边栏推荐
- JVM (XXIII) -- JVM runtime parameters
- Remote monitoring solution of intelligent electronic boundary stake Nature Reserve
- 【NOI模拟赛】字符串匹配(后缀自动机SAM,莫队,分块)
- PreScan快速入门到精通第十九讲之PreScan执行器配置、轨迹同步及非配多个轨迹
- Volcanic engine Xiang Liang: machine learning and intelligent recommendation platform multi cloud deployment solution officially released
- TGA file format (waveform sound file format)
- Arrow parquet
- Summarize the level of intelligent manufacturing discussion [macro understanding]
- Difference Between Accuracy and Precision
- 第六章 修改规范(SPEC)类
猜你喜欢

分享 25 个有用的 JS 单行代码
![[today in history] July 2: BitTorrent came out; The commercial system linspire was acquired; Sony deploys Playstation now](/img/7d/7a01c8c6923077d6c201bf1ae02c8c.png)
[today in history] July 2: BitTorrent came out; The commercial system linspire was acquired; Sony deploys Playstation now
![[today in history] July 19: the father of IMAP agreement was born; Project kotlin made a public appearance; New breakthroughs in CT imaging](/img/e9/5751dc435cfbbefc22d84fd9ebbaea.png)
[today in history] July 19: the father of IMAP agreement was born; Project kotlin made a public appearance; New breakthroughs in CT imaging

Volcanic engine Xiang Liang: machine learning and intelligent recommendation platform multi cloud deployment solution officially released

Vivo official website app full model UI adaptation scheme

智能电子界桩自然保护区远程监控解决方案

Notes - record a cannotfinddatasourceexception: dynamic datasource can not find primary datasource problem solving

JMeter - interface test

Advantages of network virtualization of various manufacturers

Recommended system topic | Minet: cross domain CTR prediction
随机推荐
Vivo official website app full model UI adaptation scheme
LP dual currency pledge liquidity mining DAPP system development logic analysis
wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
推荐系统专题 | MiNet:跨域CTR预测
Technology cloud report: what is the difference between zero trust and SASE? The answer is not really important
[today in history] July 4: the first e-book came out; The inventor of magnetic stripe card was born; Palm computer pioneer was born
Dataloader reports an error "default_collate: batch must contain tensors, numpy arrays, numbers, dicts" when pytorch trains the model
Redis source code -ziplist
What is cluster analysis? Categories of cluster analysis methods [easy to understand]
2022.7.24-----leetcode.1184
qml 结合 QSqlTableModel 动态加载数据 MVC「建议收藏」
Formatdatetime explanation [easy to understand]
[today in history] July 13: the father of database passed away; Apple buys cups code; IBM chip Alliance
Remote monitoring solution of intelligent electronic boundary stake Nature Reserve
Network RTK UAV test [easy to understand]
Dataframe first performs grouping operation and then combines output
PMP adopts the latest exam outline, here is [agile project management]
CarSim simulation quick start (16) - ADAS sensor objects of CarSim sensor simulation (2)
接口请求合并的3种技巧,性能直接爆表!
【高等数学】【1】函数、极限、连续