internal override void Load(XmlElement root) { var logger = TraceLogger.GetLogger("OrleansConfiguration", TraceLogger.LoggerType.Runtime); SeedNodes = new List <IPEndPoint>(); XmlElement child; foreach (XmlNode c in root.ChildNodes) { child = c as XmlElement; if (child != null && child.LocalName == "Networking") { Subnet = child.HasAttribute("Subnet") ? ConfigUtilities.ParseSubnet(child.GetAttribute("Subnet"), "Invalid Subnet") : null; } } foreach (XmlNode c in root.ChildNodes) { child = c as XmlElement; if (child == null) { continue; // Skip comment lines } switch (child.LocalName) { case "Liveness": if (child.HasAttribute("LivenessEnabled")) { LivenessEnabled = ConfigUtilities.ParseBool(child.GetAttribute("LivenessEnabled"), "Invalid boolean value for the LivenessEnabled attribute on the Liveness element"); } if (child.HasAttribute("ProbeTimeout")) { ProbeTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("ProbeTimeout"), "Invalid time value for the ProbeTimeout attribute on the Liveness element"); } if (child.HasAttribute("TableRefreshTimeout")) { TableRefreshTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("TableRefreshTimeout"), "Invalid time value for the TableRefreshTimeout attribute on the Liveness element"); } if (child.HasAttribute("DeathVoteExpirationTimeout")) { DeathVoteExpirationTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("DeathVoteExpirationTimeout"), "Invalid time value for the DeathVoteExpirationTimeout attribute on the Liveness element"); } if (child.HasAttribute("NumMissedProbesLimit")) { NumMissedProbesLimit = ConfigUtilities.ParseInt(child.GetAttribute("NumMissedProbesLimit"), "Invalid integer value for the NumMissedIAmAlive attribute on the Liveness element"); } if (child.HasAttribute("NumProbedSilos")) { NumProbedSilos = ConfigUtilities.ParseInt(child.GetAttribute("NumProbedSilos"), "Invalid integer value for the NumProbedSilos attribute on the Liveness element"); } if (child.HasAttribute("NumVotesForDeathDeclaration")) { NumVotesForDeathDeclaration = ConfigUtilities.ParseInt(child.GetAttribute("NumVotesForDeathDeclaration"), "Invalid integer value for the NumVotesForDeathDeclaration attribute on the Liveness element"); } if (child.HasAttribute("UseLivenessGossip")) { UseLivenessGossip = ConfigUtilities.ParseBool(child.GetAttribute("UseLivenessGossip"), "Invalid boolean value for the UseLivenessGossip attribute on the Liveness element"); } if (child.HasAttribute("IAmAliveTablePublishTimeout")) { IAmAliveTablePublishTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("IAmAliveTablePublishTimeout"), "Invalid time value for the IAmAliveTablePublishTimeout attribute on the Liveness element"); } if (child.HasAttribute("NumMissedTableIAmAliveLimit")) { NumMissedTableIAmAliveLimit = ConfigUtilities.ParseInt(child.GetAttribute("NumMissedTableIAmAliveLimit"), "Invalid integer value for the NumMissedTableIAmAliveLimit attribute on the Liveness element"); } if (child.HasAttribute("MaxJoinAttemptTime")) { MaxJoinAttemptTime = ConfigUtilities.ParseTimeSpan(child.GetAttribute("MaxJoinAttemptTime"), "Invalid time value for the MaxJoinAttemptTime attribute on the Liveness element"); } if (child.HasAttribute("ExpectedClusterSize")) { int expectedClusterSize = ConfigUtilities.ParseInt(child.GetAttribute("ExpectedClusterSize"), "Invalid integer value for the ExpectedClusterSize attribute on the Liveness element"); ExpectedClusterSizeConfigValue = new ConfigValue <int>(expectedClusterSize, false); } break; case "Azure": case "SystemStore": if (child.LocalName == "Azure") { // Log warning about deprecated <Azure> element, but then continue on to parse it for connection string info logger.Warn(ErrorCode.SiloConfigDeprecated, "The Azure element has been deprecated -- use SystemStore element instead."); } if (child.HasAttribute("SystemStoreType")) { var sst = child.GetAttribute("SystemStoreType"); if (!"None".Equals(sst, StringComparison.InvariantCultureIgnoreCase)) { LivenessType = (LivenessProviderType)Enum.Parse(typeof(LivenessProviderType), sst); SetReminderServiceType((ReminderServiceProviderType)Enum.Parse(typeof(ReminderServiceProviderType), sst)); } } if (child.HasAttribute("ServiceId")) { ServiceId = ConfigUtilities.ParseGuid(child.GetAttribute("ServiceId"), "Invalid Guid value for the ServiceId attribute on the Azure element"); } if (child.HasAttribute("DeploymentId")) { DeploymentId = child.GetAttribute("DeploymentId"); } if (child.HasAttribute(Constants.DATA_CONNECTION_STRING_NAME)) { DataConnectionString = child.GetAttribute(Constants.DATA_CONNECTION_STRING_NAME); if (String.IsNullOrWhiteSpace(DataConnectionString)) { throw new FormatException("SystemStore.DataConnectionString cannot be blank"); } } if (child.HasAttribute("MaxStorageBusyRetries")) { int maxBusyRetries = ConfigUtilities.ParseInt(child.GetAttribute("MaxStorageBusyRetries"), "Invalid integer value for the MaxStorageBusyRetries attribute on the SystemStore element"); AzureTableDefaultPolicies.MaxBusyRetries = maxBusyRetries; } if (child.HasAttribute("UseMockReminderTable")) { MockReminderTableTimeout = ConfigUtilities.ParseTimeSpan(child.GetAttribute("UseMockReminderTable"), "Invalid timeout value"); UseMockReminderTable = true; } break; case "SeedNode": SeedNodes.Add(ConfigUtilities.ParseIPEndPoint(child, Subnet)); break; case "Messaging": base.Load(child); break; case "Application": Application.Load(child, logger); break; case "PlacementStrategy": if (child.HasAttribute("DefaultPlacementStrategy")) { DefaultPlacementStrategy = child.GetAttribute("DefaultPlacementStrategy"); } if (child.HasAttribute("DeploymentLoadPublisherRefreshTime")) { DeploymentLoadPublisherRefreshTime = ConfigUtilities.ParseTimeSpan(child.GetAttribute("DeploymentLoadPublisherRefreshTime"), "Invalid time span value for PlacementStrategy.DeploymentLoadPublisherRefreshTime"); } if (child.HasAttribute("ActivationCountBasedPlacementChooseOutOf")) { ActivationCountBasedPlacementChooseOutOf = ConfigUtilities.ParseInt(child.GetAttribute("ActivationCountBasedPlacementChooseOutOf"), "Invalid ActivationCountBasedPlacementChooseOutOf setting"); } break; case "Caching": if (child.HasAttribute("CacheSize")) { CacheSize = ConfigUtilities.ParseInt(child.GetAttribute("CacheSize"), "Invalid integer value for Caching.CacheSize"); } if (child.HasAttribute("InitialTTL")) { InitialCacheTTL = ConfigUtilities.ParseTimeSpan(child.GetAttribute("InitialTTL"), "Invalid time value for Caching.InitialTTL"); } if (child.HasAttribute("MaximumTTL")) { MaximumCacheTTL = ConfigUtilities.ParseTimeSpan(child.GetAttribute("MaximumTTL"), "Invalid time value for Caching.MaximumTTL"); } if (child.HasAttribute("TTLExtensionFactor")) { CacheTTLExtensionFactor = ConfigUtilities.ParseDouble(child.GetAttribute("TTLExtensionFactor"), "Invalid double value for Caching.TTLExtensionFactor"); } if (CacheTTLExtensionFactor <= 1.0) { throw new FormatException("Caching.TTLExtensionFactor must be greater than 1.0"); } if (child.HasAttribute("DirectoryCachingStrategy")) { DirectoryCachingStrategy = ConfigUtilities.ParseEnum <DirectoryCachingStrategyType>(child.GetAttribute("DirectoryCachingStrategy"), "Invalid value for Caching.Strategy"); } break; case "Directory": if (child.HasAttribute("DirectoryLazyDeregistrationDelay")) { DirectoryLazyDeregistrationDelay = ConfigUtilities.ParseTimeSpan(child.GetAttribute("DirectoryLazyDeregistrationDelay"), "Invalid time span value for Directory.DirectoryLazyDeregistrationDelay"); } break; default: if (child.LocalName.EndsWith("Providers", StringComparison.Ordinal)) { var providerConfig = new ProviderCategoryConfiguration(); providerConfig.Load(child); ProviderConfigurations.Add(providerConfig.Name, providerConfig); } break; } } }
internal void LoadFromXml(XmlElement root) { foreach (XmlNode node in root.ChildNodes) { var child = node as XmlElement; if (child != null) { switch (child.LocalName) { case "Gateway": Gateways.Add(ConfigUtilities.ParseIPEndPoint(child).GetResult()); if (GatewayProvider == GatewayProviderType.None) { GatewayProvider = GatewayProviderType.Config; } break; case "Azure": // Throw exception with explicit deprecation error message throw new OrleansException( "The Azure element has been deprecated -- use SystemStore element instead."); case "SystemStore": if (child.HasAttribute("SystemStoreType")) { var sst = child.GetAttribute("SystemStoreType"); GatewayProvider = (GatewayProviderType)Enum.Parse(typeof(GatewayProviderType), sst); } if (child.HasAttribute("CustomGatewayProviderAssemblyName")) { CustomGatewayProviderAssemblyName = child.GetAttribute("CustomGatewayProviderAssemblyName"); if (CustomGatewayProviderAssemblyName.EndsWith(".dll")) { throw new FormatException("Use fully qualified assembly name for \"CustomGatewayProviderAssemblyName\""); } if (GatewayProvider != GatewayProviderType.Custom) { throw new FormatException("SystemStoreType should be \"Custom\" when CustomGatewayProviderAssemblyName is specified"); } } if (child.HasAttribute("DeploymentId")) { DeploymentId = child.GetAttribute("DeploymentId"); } if (child.HasAttribute(Constants.DATA_CONNECTION_STRING_NAME)) { DataConnectionString = child.GetAttribute(Constants.DATA_CONNECTION_STRING_NAME); if (String.IsNullOrWhiteSpace(DataConnectionString)) { throw new FormatException("SystemStore.DataConnectionString cannot be blank"); } if (GatewayProvider == GatewayProviderType.None) { // Assume the connection string is for Azure storage if not explicitly specified GatewayProvider = GatewayProviderType.AzureTable; } } if (child.HasAttribute(Constants.ADO_INVARIANT_NAME)) { AdoInvariant = child.GetAttribute(Constants.ADO_INVARIANT_NAME); if (String.IsNullOrWhiteSpace(AdoInvariant)) { throw new FormatException("SystemStore.AdoInvariant cannot be blank"); } } break; case "Tracing": ConfigUtilities.ParseTracing(this, child, ClientName); break; case "Statistics": ConfigUtilities.ParseStatistics(this, child, ClientName); break; case "Limits": ConfigUtilities.ParseLimitValues(LimitManager, child, ClientName); break; case "Debug": break; case "Messaging": base.Load(child); break; case "LocalAddress": if (child.HasAttribute("PreferredFamily")) { PreferredFamily = ConfigUtilities.ParseEnum <AddressFamily>(child.GetAttribute("PreferredFamily"), "Invalid address family for the PreferredFamily attribute on the LocalAddress element"); } else { throw new FormatException("Missing PreferredFamily attribute on the LocalAddress element"); } if (child.HasAttribute("Interface")) { NetInterface = child.GetAttribute("Interface"); } if (child.HasAttribute("Port")) { Port = ConfigUtilities.ParseInt(child.GetAttribute("Port"), "Invalid integer value for the Port attribute on the LocalAddress element"); } break; case "Telemetry": ConfigUtilities.ParseTelemetry(child); break; default: if (child.LocalName.EndsWith("Providers", StringComparison.Ordinal)) { var providerCategory = ProviderCategoryConfiguration.Load(child); if (ProviderConfigurations.ContainsKey(providerCategory.Name)) { var existingCategory = ProviderConfigurations[providerCategory.Name]; existingCategory.Merge(providerCategory); } else { ProviderConfigurations.Add(providerCategory.Name, providerCategory); } } break; } } } }
internal void Load(TextReader input) { var xml = new XmlDocument(); var xmlReader = XmlReader.Create(input); xml.Load(xmlReader); var root = xml.DocumentElement; foreach (XmlNode node in root.ChildNodes) { var child = node as XmlElement; if (child != null) { switch (child.LocalName) { case "Gateway": Gateways.Add(ConfigUtilities.ParseIPEndPoint(child)); if (GatewayProvider == GatewayProviderType.None) { GatewayProvider = GatewayProviderType.Config; } break; case "Azure": // Throw exception with explicit deprecation error message throw new OrleansException( "The Azure element has been deprecated -- use SystemStore element instead."); case "SystemStore": if (child.HasAttribute("SystemStoreType")) { var sst = child.GetAttribute("SystemStoreType"); GatewayProvider = (GatewayProviderType)Enum.Parse(typeof(GatewayProviderType), sst); } if (child.HasAttribute("DeploymentId")) { DeploymentId = child.GetAttribute("DeploymentId"); } if (child.HasAttribute(Constants.DATA_CONNECTION_STRING_NAME)) { DataConnectionString = child.GetAttribute(Constants.DATA_CONNECTION_STRING_NAME); if (String.IsNullOrWhiteSpace(DataConnectionString)) { throw new FormatException("SystemStore.DataConnectionString cannot be blank"); } if (GatewayProvider == GatewayProviderType.None) { // Assume the connection string is for Azure storage if not explicitly specified GatewayProvider = GatewayProviderType.AzureTable; } } break; case "Tracing": ConfigUtilities.ParseTracing(this, child, ClientName); break; case "Statistics": ConfigUtilities.ParseStatistics(this, child, ClientName); break; case "Limits": ConfigUtilities.ParseLimitValues(this, child, ClientName); break; case "Debug": break; case "Messaging": base.Load(child); break; case "LocalAddress": if (child.HasAttribute("PreferredFamily")) { PreferredFamily = ConfigUtilities.ParseEnum <AddressFamily>(child.GetAttribute("PreferredFamily"), "Invalid address family for the PreferredFamily attribute on the LocalAddress element"); } else { throw new FormatException("Missing PreferredFamily attribute on the LocalAddress element"); } if (child.HasAttribute("Interface")) { NetInterface = child.GetAttribute("Interface"); } if (child.HasAttribute("Port")) { Port = ConfigUtilities.ParseInt(child.GetAttribute("Port"), "Invalid integer value for the Port attribute on the LocalAddress element"); } break; default: if (child.LocalName.EndsWith("Providers", StringComparison.Ordinal)) { var providerConfig = new ProviderCategoryConfiguration(); providerConfig.Load(child); ProviderConfigurations.Add(providerConfig.Name, providerConfig); } break; } } } }