/// <summary> /// this (or <see cref="ReloadConfig"/>) gets called (depending) when the TypeSettings.Config file /// are changed. /// </summary> /// <remarks> /// Added: craigbro /// cachedTypeSettings now held with the forwarder for reference of /// exceptions on Synchronous "in" messages. /// To reload, we just null out the cached TypeSettingsCollection object and the /// accessor will reload it on next call /// While ConfigurationManager.GetSection is quite performant after the 1st hit, /// keeping them cached is about twice as fast. /// </remarks> /// <param name="config"></param> /// <param name="runState"></param> private void LoadConfig(RelayNodeConfig config, ComponentRunState runState) { if (config != null) { if (config.RelayComponents != null) { object configObject = config.RelayComponents.GetConfigFor(GetComponentName()); ForwardingConfig forwardingConfig = configObject as ForwardingConfig; if (forwardingConfig == null) { if (log.IsInfoEnabled) { log.Info("No forwarding configuration supplied. Using defaults."); } forwardingConfig = new ForwardingConfig(); } NodeManager.Initialize(config, forwardingConfig, GetErrorQueues(runState)); TypeSettingCollection typeSettingCollection = null; if (NodeManager.Instance.Config != null) { if (NodeManager.Instance.Config.TypeSettings != null) { typeSettingCollection = NodeManager.Instance.Config.TypeSettings.TypeSettingCollection; } } TypeSpecificStatisticsManager.Initialize(typeSettingCollection); _enableAsyncBulkGets = forwardingConfig.EnableAsyncBulkGets; _myNodeDefinition = NodeManager.Instance.GetMyNodeDefinition(); _myZone = Node.DetermineZone(_myNodeDefinition); short maxTypeId = 0; if (config.TypeSettings != null) { maxTypeId = config.TypeSettings.MaxTypeId; } DebugWriter.SetTraceSettings(maxTypeId, forwardingConfig.TraceSettings); DebugWriter.WriteCallingMethod = forwardingConfig.WriteCallingMethod; DebugWriter.WriteMessageTrace = forwardingConfig.WriteMessageTrace; } else { NodeManager.Initialize(null, null, null); TypeSpecificStatisticsManager.Initialize(null); } } else { NodeManager.Initialize(null, null, null); TypeSpecificStatisticsManager.Initialize(null); } }
/// <summary> /// this (or <see cref="LoadConfig"/>) gets called (depending) when the TypeSettings.Config file /// are changed. /// </summary> /// <remarks> /// Added: craigbro /// cachedTypeSettings now held with the forwarder for reference of /// exceptions on Synchronous "in" messages. /// To reload, we just null out the cached TypeSettingsCollection object and the /// accessor will reload it on next call /// While ConfigurationManager.GetSection is quite performant after the 1st hit, /// keeping them cached is about twice as fast. /// </remarks> /// <param name="config">The config to reload</param> public void ReloadConfig(RelayNodeConfig config) { lock (reloadLock) { if (config != null) { try { object configObject = config.RelayComponents.GetConfigFor(GetComponentName()); ForwardingConfig forwardingConfig = configObject as ForwardingConfig; if (forwardingConfig == null) { if (log.IsInfoEnabled) { log.InfoFormat("No forwarding configuration supplied. Reloading using defaults."); } forwardingConfig = new ForwardingConfig(); } NodeManager.Instance.ReloadConfig(config, forwardingConfig); if (NodeManager.Instance.Config != null) { if (NodeManager.Instance.Config.TypeSettings != null) { TypeSpecificStatisticsManager.Instance.ReloadMapping( NodeManager.Instance.Config.TypeSettings.TypeSettingCollection); } } _enableAsyncBulkGets = forwardingConfig.EnableAsyncBulkGets; _myNodeDefinition = NodeManager.Instance.GetMyNodeDefinition(); _myZone = Node.DetermineZone(_myNodeDefinition); short maxTypeId = 0; if (config.TypeSettings != null) { maxTypeId = config.TypeSettings.MaxTypeId; } DebugWriter.SetTraceSettings(maxTypeId, forwardingConfig.TraceSettings); DebugWriter.WriteCallingMethod = forwardingConfig.WriteCallingMethod; DebugWriter.WriteMessageTrace = forwardingConfig.WriteMessageTrace; } catch (Exception ex) { if (log.IsErrorEnabled) { log.ErrorFormat("Exception reloading config: {0}", ex); } } } } }