Mycat-启动分析

mycat版本:1.4.1-DEV

 

mycat启动类:org.opencloudb.MycatStartup

mycat在linux启动时,采用java server wrapper进行包装,所以mycat启动配置jdk时,其实配置的是wrapper。

 

MYCAT_HOME

org.opencloudb.config.model.SystemConfig  mycat系统基础配置项。

mycat启动时,首先会检查MYCAT_HOME是否设置。如果没有设置则读取正在运行程序的目录作为MYCAT_HOME.

 

MycatServer

org.opencloudb.MycatServer经典的单例模式。包含MycatConfig等许多信息。

初始化org.opencloudb.cache.CacheService.CacheService()

初始化org.opencloudb.route.RouteService.RouteService(CacheService)

初始化org.opencloudb.interceptor.impl.DefaultSqlInterceptor

 

MycatConfig

org.opencloudb.MycatConfig.MycatConfig()包含mycat的各种配置文件信息。

 

MycatServer.startup

初始化ManagerConnectionFactory

初始化ServerConnectionFactory

如果使用AIO,这使用AsynchronousChannelGroup

manager使用AsynchronousServerSocketChannel

server使用AsynchronousServerSocketChannel

读取datanode,开始心跳检测

开启timer,包括空闲线程、catlet

 

阻塞线程:

while (true) {

Thread.sleep(300 * 1000);

}

 

 

连接mycat:

org.opencloudb.server.ServerConnectionFactory.getConnection(NetworkChannel)

 

读取schema.xml:

 org.opencloudb.config.loader.xml.XMLSchemaLoader 

 

读取缓存/cacheservice.properties:

org.opencloudb.cache.CacheService

猜你喜欢

转载自joandora.iteye.com/blog/2259881