https://blog.csdn.net/hosaos/article/details/88658676对NodeCache,PathChildrenCache,TreeCache做了比较详尽的分析,但有一点没有说的很直接:对于PathChildrenCache,不同的startMode:
**
* Method of priming cache on {@link PathChildrenCache#start(StartMode)}
*/
public enum StartMode
{
NORMAL,
BUILD_INITIAL_CACHE,
POST_INITIALIZED_EVENT
}
NORMAL,所有已经存在的childnode ,都会触发eventBUILD_INITIAL_CACHE,block模式初始化cache,只有新的child node变化才会触发实际POST_INITIALIZED_EVENT,在NORMAL的基础上触发INITIALIZED事件,但这个时间的child node的事件并不能保证时间顺序
另外PathChildrenCache本质还是TreeCache,可以从触发事件stack看到如下信息
Daemon Thread [main-EventThread] (Suspended (breakpoint at line 834 in TreeCache)) TreeCache.publishEvent(TreeCacheEvent) line: 834 TreeCache.publishEvent(TreeCacheEvent$Type, ChildData) line: 827 TreeCache.access$700(TreeCache, TreeCacheEvent$Type, ChildData) line: 71 TreeCache$TreeNode.processResult(Curatorframework, CuratorEvent) line: 452 CuratorframeworkImpl.sendToBackgroundCallback(OperationAndData, CuratorEvent) line: 749 CuratorframeworkImpl.processBackgroundOperation(OperationAndData , CuratorEvent) line: 522 GetDataBuilderImpl$3.processResult(int, String, Object, byte[], Stat) line: 256 ClientCnxn$EventThread.processEvent(Object) line: 561 ClientCnxn$EventThread.run() line: 498



