public override void SetUpstreamRepository(ConfigRepository upstreamConfigRepository) { if (upstreamConfigRepository == null) { return; } //clear previous listener if (m_upstream != null) { m_upstream.RemoveChangeListener(this); } m_upstream = upstreamConfigRepository; TrySyncFromUpstream(); upstreamConfigRepository.AddChangeListener(this); }
private void Initialize() { try { m_configProperties.WriteFullFence(m_configRepository.GetConfig()); } catch (Exception ex) { logger.Warn( string.Format("Init Apollo Local Config failed - namespace: {0}, reason: {1}.", m_namespace, ExceptionUtil.GetDetailMessage(ex))); } finally { //register the change listener no matter config repository is working or not //so that whenever config repository is recovered, config could get changed m_configRepository.AddChangeListener(this); } }