Mycat1.6 source code reading top ten scheduler scheduling

1. Scheduler  initialization process

private MycatServer() { 

  //Timed thread pool, single thread thread pool

  scheduler = Executors.newSingleThreadScheduledExecutor();

}

 

2. Part of the code stripped from the Big Mac method for the ten timed tasks

Permalink:  http://gaojingsong.iteye.com/blog/2346941

//This is a super big method with more than 200 lines, so this code is bad code and needs to be optimized

server.startup();


 The source code is as follows:

public void startup() throws IOException {

SystemConfig system = config.getSystem();

//1. The system time is updated regularly, similar to the SCN (system commit number/system change number) in the Oracle system

scheduler.scheduleAtFixedRate(updateTime(), 0L, TIME_UPDATE_PERIOD,TimeUnit.MILLISECONDS);

//2, the processor regularly checks the task

scheduler.scheduleAtFixedRate(processorCheck(), 0L, system.getProcessorCheckPeriod(),TimeUnit.MILLISECONDS);

//3. Data node timing connection idle timeout check task

scheduler.scheduleAtFixedRate(dataNodeConHeartBeatCheck(dataNodeIldeCheckPeriod), 0L, dataNodeIldeCheckPeriod,TimeUnit.MILLISECONDS);

//4. Data node timing heartbeat task

scheduler.scheduleAtFixedRate(dataNodeHeartbeat(), 0L, system.getDataNodeHeartbeatPeriod(),TimeUnit.MILLISECONDS);

//5. After cleaning up reload @@config_all, the old connection is connected

scheduler.scheduleAtFixedRate(dataSourceOldConsClear(), 0L, DEFAULT_OLD_CONNECTION_CLEAR_PERIOD, TimeUnit.MILLISECONDS);

//6、clear unused catlet

scheduler.schedule(catletClassClear(), 30000,TimeUnit.MILLISECONDS);

       

if(system.getCheckTableConsistency()==1) {

//7. Regularly check the structure consistency of different sharding tables

 scheduler.scheduleAtFixedRate(tableStructureCheck(), 0L, system.getCheckTableConsistencyPeriod(), TimeUnit.MILLISECONDS);

        }

if(system.getUseSqlStat()==1) {

//8. Regularly clean and save the data in SqlStat

scheduler.scheduleAtFixedRate(recycleSqlStat(), 0L, DEFAULT_SQL_STAT_RECYCLE_PERIOD, TimeUnit.MILLISECONDS);

}

if(system.getUseGlobleTableCheck() == 1){

// 9. Whether the global table consistency check is enabled

scheduler.scheduleAtFixedRate(glableTableConsistencyCheck(), 0L, system.getGlableTableCheckPeriod(), TimeUnit.MILLISECONDS);

}

//10. Regularly clean up the result set leaderboard and control the rejection strategy

scheduler.scheduleAtFixedRate(resultSetMapClear(),0L,  system.getClearBigSqLResultSetMapMs(),TimeUnit.MILLISECONDS);

 

//XA Init recovery Log

performXARecoveryLog();

 

if(isUseZkSwitch()) {

//If the dnindex on zk is found to be empty at the first startup, it will be initialized locally on zk

}

}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326704185&siteId=291194637