先拿HMaster启动来说, 会根据serverName初始化一个 ExcutorService ,然后通过 ExcutorService.startExecutorService 会跟ExcutorType 去初始化 Excutor , Excutor 里面会初始化一个 ThreadPoolExecutor 。 这样来了一个Event (比如Disable Table),然后指定哪个EventHandler实现类去 process() ,然后从ExcutorService 找到处理EventType的Excutor,然后 Exutor 中的ThreadPoolExecutor 去执行EventHandler实现类这个线程。
下面是详细介绍:
EventHandler 是一个Hbase所有事件的一个抽象类,所有子类都应该实现process方法,如果有必要,子类需要在自己的构造函数中去检查表是否存在、是否disable等等。
EventHandler中定义EventType 即事件类型,事件类型主要有如下几大类
// Messages originating from RS (NOTE: there is NO direct communication from
// RS to Master). These are a result of RS updates into ZK.
<span style="color: rgb(255, 0, 0);"> RS 更新到 ZK的事件</span>
//RS_ZK_REGION_CLOSING (1), // It is replaced by M_ZK_REGION_CLOSING(HBASE-4739)
RS_ZK_REGION_CLOSED (2), // RS has finished closing a region RS完成关闭region
RS_ZK_REGION_OPENING (3), // RS is in process of opening a reg