private void RecalculateExtenderConfig() { ExtenderConfig mergedConfig = null; foreach (IKsiService service in ExtendingServices) { if (!_currentExtenderConfigList.ContainsKey(service)) { continue; } ExtenderConfig config = _currentExtenderConfigList[service]; Logger.Debug("ExtenderConfig in cache: " + config + "; Sub-service: " + service.ExtenderAddress); mergedConfig = HAExtenderConfigRequestRunner.MergeConfigs(mergedConfig, config); } if (_currentExtenderConfig == null || !_currentExtenderConfig.Equals(mergedConfig)) { Logger.Debug("New merged ExtenderConfig: " + mergedConfig); _currentExtenderConfig = mergedConfig; ExtenderConfigChanged?.Invoke(this, new ExtenderConfigChangedEventArgs(mergedConfig, this)); } else { Logger.Debug("Merged ExtenderConfig not changed."); } }
/// <summary> /// End get additional extender configuration data (async) /// </summary> /// <param name="asyncResult"></param> /// <returns>Extender configuration data</returns> public ExtenderConfig EndGetExtenderConfig(IAsyncResult asyncResult) { HAAsyncResult haAsyncResult = GetHAAsyncResult(asyncResult); HAExtenderConfigRequestRunner runner = GetRequestRunner <HAExtenderConfigRequestRunner>(haAsyncResult); ExtenderConfig config = runner.EndGetExtenderConfig(haAsyncResult); if (config == null) { lock (_extenderConfigChangedLock) { _currentExtenderConfigList.Clear(); _currentExtenderConfig = null; } HAKsiServiceException ex = new HAKsiServiceException("Could not get extender configuration.", runner.SubServiceErrors); Logger.Warn(ex); ExtenderConfigChangedEventArgs extenderConfigChangedEventArgs = new ExtenderConfigChangedEventArgs(ex, this); ExtenderConfigChanged?.Invoke(this, extenderConfigChangedEventArgs); throw ex; } // if sub-service config request failed then remove corresponding config from cache foreach (HAKsiSubServiceException ex in runner.SubServiceErrors) { if (ex.ThrownBySubService == null) { continue; } lock (_extenderConfigChangedLock) { if (_currentExtenderConfigList.ContainsKey(ex.ThrownBySubService)) { _currentExtenderConfigList.Remove(ex.ThrownBySubService); RecalculateExtenderConfig(); } } } return(config); }
private void RequestResponseParser_ExtenderConfigChanged(object sender, ExtenderConfigChangedEventArgs e) { ExtenderConfigChanged?.Invoke(this, new ExtenderConfigChangedEventArgs(e.ExtenderConfig, this)); }