3、RemoteConfigLongPollService:远程配置长轮循服务,负责长轮循ConfigServer变更通知,当有更新时立即轮循触发更新
第一步RemetoConfigRepository构造中scheduleLongPollingRefresh()方法进入该类
private void scheduleLongPollingRefresh() {
remoteConfigLongPollService.submit(m_namespace, this);
}
进入RemoteCOnfigLongPollService下面方法
public boolean submit(String namespace, RemoteConfigRepository remoteConfigRepository) {
boolean added = m_longPollNamespaces.put(namespace, remoteConfigRepository);
m_notifications.putIfAbsent(namespace, INIT_NOTIFICATION_ID);
若未启动长轮询定时任务,进行启动
if (!m_longPollStarted.get()) {
startLongPolling();
}
return added;
若未启动长轮循,进行启动
private void startLongPolling() {
if (!m_longPollStarted.compareAndSet(false, true)) {
//already started
return;
}
try {
final String appId = m_configUtil.getAppId();
final String cluster = m_configUtil.getCluster();
final String dataCenter = m_configUtil.getDataCenter();
final long longPollingInitialDelayInMills = m_configUtil.getLongPollingInitialDelayInMills();
m_longPollingService.submit(new Runnable() {
@Override
public void run() {
if (longPollingInitialDelayInMills > 0) {
try {