public AbstractJobNode() { application = getApplication(); config = JobNodeConfigFactory.getDefaultConfig(); application.setConfig(config); nodeChangeListeners = new ArrayList<NodeChangeListener>(); masterChangeListeners = new ArrayList<MasterChangeListener>(); }
protected void initConfig() { application.setEventCenter(eventCenterFactory.getEventCenter(config)); application.setCommandBodyWrapper(new CommandBodyWrapper(config)); application.setMasterElector(new MasterElector(application)); application.getMasterElector().addMasterChangeListener(masterChangeListeners); application.setRegistryStatMonitor(new RegistryStatMonitor(application)); node = NodeFactory.create(getNodeClass(), config); config.setNodeType(node.getNodeType()); LOGGER.info("Current node config :{}", config); // 订阅的node管理 SubscribedNodeManager subscribedNodeManager = new SubscribedNodeManager(application); application.setSubscribedNodeManager(subscribedNodeManager); nodeChangeListeners.add(subscribedNodeManager); // 用于master选举的监听器 nodeChangeListeners.add(new MasterElectionListener(application)); // 监听自己节点变化(如,当前节点被禁用了) nodeChangeListeners.add(new SelfChangeListener(application)); }