LD is tigger forever,CG are not brothers forever, throw the pot and shine forever.
Modesty is not false, solid is not naive, treacherous but not deceitful, stay with good people, and stay away from poor people.
talk is cheap, show others the code and KPI, Keep progress,make a better result.
Survive during the day and develop at night。
目录
概 述
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 {
logger.debug("Long polling will start in {} ms.", longPollingInitialDelayInMills);

本文详细解析了Apollo配置中心的远程配置长轮询服务原理。通过剖析源码,展示了如何实现ConfigServer变更通知的长轮询机制,并介绍了ConfigController如何提供配置读取功能。
最低0.47元/天 解锁文章
2129

被折叠的 条评论
为什么被折叠?



