internal virtual void Load(XmlElement child) { ResponseTimeout = child.HasAttribute("ResponseTimeout") ? ConfigUtilities.ParseTimeSpan(child.GetAttribute("ResponseTimeout"), "Invalid ResponseTimeout") : Constants.DEFAULT_RESPONSE_TIMEOUT; if (child.HasAttribute("MaxResendCount")) { MaxResendCount = ConfigUtilities.ParseInt(child.GetAttribute("MaxResendCount"), "Invalid integer value for the MaxResendCount attribute on the Messaging element"); } if (child.HasAttribute("ResendOnTimeout")) { ResendOnTimeout = ConfigUtilities.ParseBool(child.GetAttribute("ResendOnTimeout"), "Invalid Boolean value for the ResendOnTimeout attribute on the Messaging element"); } if (child.HasAttribute("MaxSocketAge")) { MaxSocketAge = ConfigUtilities.ParseTimeSpan(child.GetAttribute("MaxSocketAge"), "Invalid time span set for the MaxSocketAge attribute on the Messaging element"); } if (child.HasAttribute("DropExpiredMessages")) { DropExpiredMessages = ConfigUtilities.ParseBool(child.GetAttribute("DropExpiredMessages"), "Invalid integer value for the DropExpiredMessages attribute on the Messaging element"); } //-- if (isSiloConfig) { if (child.HasAttribute("SiloSenderQueues")) { SiloSenderQueues = ConfigUtilities.ParseInt(child.GetAttribute("SiloSenderQueues"), "Invalid integer value for the SiloSenderQueues attribute on the Messaging element"); } if (child.HasAttribute("GatewaySenderQueues")) { GatewaySenderQueues = ConfigUtilities.ParseInt(child.GetAttribute("GatewaySenderQueues"), "Invalid integer value for the GatewaySenderQueues attribute on the Messaging element"); } ClientDropTimeout = child.HasAttribute("ClientDropTimeout") ? ConfigUtilities.ParseTimeSpan(child.GetAttribute("ClientDropTimeout"), "Invalid ClientDropTimeout") : Constants.DEFAULT_CLIENT_DROP_TIMEOUT; } else { if (child.HasAttribute("ClientSenderBuckets")) { ClientSenderBuckets = ConfigUtilities.ParseInt(child.GetAttribute("ClientSenderBuckets"), "Invalid integer value for the ClientSenderBuckets attribute on the Messaging element"); } } //-- if (child.HasAttribute("BufferPoolBufferSize")) { BufferPoolBufferSize = ConfigUtilities.ParseInt(child.GetAttribute("BufferPoolBufferSize"), "Invalid integer value for the BufferPoolBufferSize attribute on the Messaging element"); } if (child.HasAttribute("BufferPoolMaxSize")) { BufferPoolMaxSize = ConfigUtilities.ParseInt(child.GetAttribute("BufferPoolMaxSize"), "Invalid integer value for the BufferPoolMaxSize attribute on the Messaging element"); } if (child.HasAttribute("BufferPoolPreallocationSize")) { BufferPoolPreallocationSize = ConfigUtilities.ParseInt(child.GetAttribute("BufferPoolPreallocationSize"), "Invalid integer value for the BufferPoolPreallocationSize attribute on the Messaging element"); } //-- if (isSiloConfig) { if (child.HasAttribute("MaxForwardCount")) { MaxForwardCount = ConfigUtilities.ParseInt(child.GetAttribute("MaxForwardCount"), "Invalid integer value for the MaxForwardCount attribute on the Messaging element"); } } if (child.HasChildNodes) { var serializerNode = child.ChildNodes.OfType <XmlElement>().FirstOrDefault(n => n.Name == "SerializationProviders"); if (serializerNode != null && serializerNode.HasChildNodes) { var typeNames = serializerNode.ChildNodes.OfType <XmlElement>() .Where(n => n.Name == "Provider") .Select(e => e.Attributes["type"]) .Where(a => a != null) .Select(a => a.Value); var types = typeNames.Select( t => ConfigUtilities.ParseFullyQualifiedType( t, $"The type specification for the 'type' attribute of the Provider element could not be loaded. Type specification: '{t}'.")); foreach (var type in types) { var typeinfo = type.GetTypeInfo(); ConfigUtilities.ValidateSerializationProvider(typeinfo); if (SerializationProviders.Contains(typeinfo) == false) { SerializationProviders.Add(typeinfo); } } } var fallbackSerializerNode = child.ChildNodes.OfType <XmlElement>().FirstOrDefault(n => n.Name == "FallbackSerializationProvider"); if (fallbackSerializerNode != null) { var typeName = fallbackSerializerNode.Attributes["type"]?.Value; if (string.IsNullOrWhiteSpace(typeName)) { var msg = "The FallbackSerializationProvider element requires a 'type' attribute specifying the fully-qualified type name of the serializer."; throw new FormatException(msg); } var type = ConfigUtilities.ParseFullyQualifiedType( typeName, $"The type specification for the 'type' attribute of the FallbackSerializationProvider element could not be loaded. Type specification: '{typeName}'."); this.FallbackSerializationProvider = type.GetTypeInfo(); } } }
/// <summary>Returns a detailed human readable string that represents the current configuration. It does not contain every single configuration knob.</summary> public override string ToString() { var sb = new StringBuilder(); sb.AppendLine("Platform version info:").Append(ConfigUtilities.RuntimeVersionInfo()); sb.Append(" Host: ").AppendLine(Dns.GetHostName()); sb.Append(" Processor Count: ").Append(System.Environment.ProcessorCount).AppendLine(); sb.AppendLine("Client Configuration:"); sb.Append(" Config File Name: ").AppendLine(string.IsNullOrEmpty(SourceFile) ? "" : Path.GetFullPath(SourceFile)); sb.Append(" Start time: ").AppendLine(LogFormatter.PrintDate(DateTime.UtcNow)); sb.Append(" Gateway Provider: ").Append(GatewayProvider); if (GatewayProvider == GatewayProviderType.None) { sb.Append(". Gateway Provider that will be used instead: ").Append(GatewayProviderToUse); } sb.AppendLine(); if (Gateways != null && Gateways.Count > 0) { sb.AppendFormat(" Gateways[{0}]:", Gateways.Count).AppendLine(); foreach (var endpoint in Gateways) { sb.Append(" ").AppendLine(endpoint.ToString()); } } else { sb.Append(" Gateways: ").AppendLine("Unspecified"); } sb.Append(" Preferred Gateway Index: ").AppendLine(PreferedGatewayIndex.ToString()); if (Gateways != null && PreferedGatewayIndex >= 0 && PreferedGatewayIndex < Gateways.Count) { sb.Append(" Preferred Gateway Address: ").AppendLine(Gateways[PreferedGatewayIndex].ToString()); } sb.Append(" GatewayListRefreshPeriod: ").Append(GatewayListRefreshPeriod).AppendLine(); if (!String.IsNullOrEmpty(DeploymentId) || !String.IsNullOrEmpty(DataConnectionString)) { sb.Append(" Azure:").AppendLine(); sb.Append(" DeploymentId: ").Append(DeploymentId).AppendLine(); string dataConnectionInfo = ConfigUtilities.RedactConnectionStringInfo(DataConnectionString); // Don't print Azure account keys in log files sb.Append(" DataConnectionString: ").Append(dataConnectionInfo).AppendLine(); } if (!string.IsNullOrWhiteSpace(NetInterface)) { sb.Append(" Network Interface: ").AppendLine(NetInterface); } if (Port != 0) { sb.Append(" Network Port: ").Append(Port).AppendLine(); } sb.Append(" Preferred Address Family: ").AppendLine(PreferredFamily.ToString()); sb.Append(" DNS Host Name: ").AppendLine(DNSHostName); sb.Append(" Client Name: ").AppendLine(ClientName); sb.Append(ConfigUtilities.TraceConfigurationToString(this)); sb.Append(ConfigUtilities.IStatisticsConfigurationToString(this)); sb.Append(LimitManager); sb.AppendFormat(base.ToString()); #if !NETSTANDARD sb.Append(" .NET: ").AppendLine(); int workerThreads; int completionPortThreads; ThreadPool.GetMinThreads(out workerThreads, out completionPortThreads); sb.AppendFormat(" .NET thread pool sizes - Min: Worker Threads={0} Completion Port Threads={1}", workerThreads, completionPortThreads).AppendLine(); ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads); sb.AppendFormat(" .NET thread pool sizes - Max: Worker Threads={0} Completion Port Threads={1}", workerThreads, completionPortThreads).AppendLine(); #endif sb.AppendFormat(" Providers:").AppendLine(); sb.Append(ProviderConfigurationUtility.PrintProviderConfigurations(ProviderConfigurations)); return(sb.ToString()); }
internal void Load(XmlElement root) { SiloName = root.LocalName.Equals("Override") ? root.GetAttribute("Node") : DEFAULT_NODE_NAME; foreach (XmlNode c in root.ChildNodes) { var child = c as XmlElement; if (child == null) { continue; // Skip comment lines } switch (child.LocalName) { case "Networking": if (child.HasAttribute("Address")) { HostNameOrIPAddress = child.GetAttribute("Address"); } if (child.HasAttribute("Port")) { Port = ConfigUtilities.ParseInt(child.GetAttribute("Port"), "Non-numeric Port attribute value on Networking element for " + SiloName); } if (child.HasAttribute("PreferredFamily")) { AddressType = ConfigUtilities.ParseEnum <AddressFamily>(child.GetAttribute("PreferredFamily"), "Invalid preferred address family on Networking node. Valid choices are 'InterNetwork' and 'InterNetworkV6'"); } break; case "ProxyingGateway": ProxyGatewayEndpoint = ConfigUtilities.ParseIPEndPoint(child, Subnet); break; case "Scheduler": if (child.HasAttribute("MaxActiveThreads")) { MaxActiveThreads = ConfigUtilities.ParseInt(child.GetAttribute("MaxActiveThreads"), "Non-numeric MaxActiveThreads attribute value on Scheduler element for " + SiloName); if (MaxActiveThreads < 1) { MaxActiveThreads = DEFAULT_MAX_ACTIVE_THREADS; } } if (child.HasAttribute("DelayWarningThreshold")) { DelayWarningThreshold = ConfigUtilities.ParseTimeSpan(child.GetAttribute("DelayWarningThreshold"), "Non-numeric DelayWarningThreshold attribute value on Scheduler element for " + SiloName); } if (child.HasAttribute("ActivationSchedulingQuantum")) { ActivationSchedulingQuantum = ConfigUtilities.ParseTimeSpan(child.GetAttribute("ActivationSchedulingQuantum"), "Non-numeric ActivationSchedulingQuantum attribute value on Scheduler element for " + SiloName); } if (child.HasAttribute("TurnWarningLengthThreshold")) { TurnWarningLengthThreshold = ConfigUtilities.ParseTimeSpan(child.GetAttribute("TurnWarningLengthThreshold"), "Non-numeric TurnWarningLengthThreshold attribute value on Scheduler element for " + SiloName); } if (child.HasAttribute("MinDotNetThreadPoolSize")) { MinDotNetThreadPoolSize = ConfigUtilities.ParseInt(child.GetAttribute("MinDotNetThreadPoolSize"), "Invalid ParseInt MinDotNetThreadPoolSize value on Scheduler element for " + SiloName); } if (child.HasAttribute("Expect100Continue")) { Expect100Continue = ConfigUtilities.ParseBool(child.GetAttribute("Expect100Continue"), "Invalid ParseBool Expect100Continue value on Scheduler element for " + SiloName); } if (child.HasAttribute("DefaultConnectionLimit")) { DefaultConnectionLimit = ConfigUtilities.ParseInt(child.GetAttribute("DefaultConnectionLimit"), "Invalid ParseInt DefaultConnectionLimit value on Scheduler element for " + SiloName); } if (child.HasAttribute("UseNagleAlgorithm ")) { UseNagleAlgorithm = ConfigUtilities.ParseBool(child.GetAttribute("UseNagleAlgorithm "), "Invalid ParseBool UseNagleAlgorithm value on Scheduler element for " + SiloName); } break; case "LoadShedding": if (child.HasAttribute("Enabled")) { LoadSheddingEnabled = ConfigUtilities.ParseBool(child.GetAttribute("Enabled"), "Invalid boolean value for Enabled attribute on LoadShedding attribute for " + SiloName); } if (child.HasAttribute("LoadLimit")) { LoadSheddingLimit = ConfigUtilities.ParseInt(child.GetAttribute("LoadLimit"), "Invalid integer value for LoadLimit attribute on LoadShedding attribute for " + SiloName); if (LoadSheddingLimit < 0) { LoadSheddingLimit = 0; } if (LoadSheddingLimit > 100) { LoadSheddingLimit = 100; } } break; case "Tracing": ConfigUtilities.ParseTracing(this, child, SiloName); break; case "Statistics": ConfigUtilities.ParseStatistics(this, child, SiloName); break; case "Limits": ConfigUtilities.ParseLimitValues(this, child, SiloName); 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; } } } }
/// <summary> /// Loads the configuration from the standard paths, looking up the directory hierarchy /// </summary> /// <returns>Client configuration data if a configuration file was found.</returns> /// <exception cref="FileNotFoundException">Thrown if no configuration file could be found in any of the standard locations</exception> public static ClientConfiguration StandardLoad() { var fileName = ConfigUtilities.FindConfigFile(false); // Throws FileNotFoundException return(LoadFromFile(fileName)); }
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"); } if (child.HasAttribute("ClientRegistrationRefresh")) { ClientRegistrationRefresh = ConfigUtilities.ParseTimeSpan(child.GetAttribute("ClientRegistrationRefresh"), "Invalid time span value for Directory.ClientRegistrationRefresh"); } 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; } } }
/// <summary> /// Loads the configuration from the standard paths /// </summary> /// <returns></returns> public void StandardLoad() { string fileName = ConfigUtilities.FindConfigFile(true); // Throws FileNotFoundException LoadFromFile(fileName); }
public override string ToString() { var sb = new StringBuilder(); sb.AppendFormat(" System Ids:").AppendLine(); sb.AppendFormat(" ServiceId: {0}", ServiceId).AppendLine(); sb.AppendFormat(" DeploymentId: {0}", DeploymentId).AppendLine(); sb.Append(" Subnet: ").Append(Subnet == null ? "" : Subnet.ToStrings(x => x.ToString(CultureInfo.InvariantCulture), ".")).AppendLine(); sb.Append(" Seed nodes: "); bool first = true; foreach (IPEndPoint node in SeedNodes) { if (!first) { sb.Append(", "); } sb.Append(node.ToString()); first = false; } sb.AppendLine(); sb.AppendFormat(base.ToString()); sb.AppendFormat(" Liveness:").AppendLine(); sb.AppendFormat(" LivenessEnabled: {0}", LivenessEnabled).AppendLine(); sb.AppendFormat(" LivenessType: {0}", LivenessType).AppendLine(); sb.AppendFormat(" ProbeTimeout: {0}", ProbeTimeout).AppendLine(); sb.AppendFormat(" TableRefreshTimeout: {0}", TableRefreshTimeout).AppendLine(); sb.AppendFormat(" DeathVoteExpirationTimeout: {0}", DeathVoteExpirationTimeout).AppendLine(); sb.AppendFormat(" NumMissedProbesLimit: {0}", NumMissedProbesLimit).AppendLine(); sb.AppendFormat(" NumProbedSilos: {0}", NumProbedSilos).AppendLine(); sb.AppendFormat(" NumVotesForDeathDeclaration: {0}", NumVotesForDeathDeclaration).AppendLine(); sb.AppendFormat(" UseLivenessGossip: {0}", UseLivenessGossip).AppendLine(); sb.AppendFormat(" IAmAliveTablePublishTimeout: {0}", IAmAliveTablePublishTimeout).AppendLine(); sb.AppendFormat(" NumMissedTableIAmAliveLimit: {0}", NumMissedTableIAmAliveLimit).AppendLine(); sb.AppendFormat(" MaxJoinAttemptTime: {0}", MaxJoinAttemptTime).AppendLine(); sb.AppendFormat(" ExpectedClusterSize: {0}", ExpectedClusterSize).AppendLine(); sb.AppendFormat(" SystemStore:").AppendLine(); // Don't print connection credentials in log files, so pass it through redactment filter string connectionStringForLog = ConfigUtilities.RedactConnectionStringInfo(DataConnectionString); sb.AppendFormat(" ConnectionString: {0}", connectionStringForLog).AppendLine(); sb.Append(Application.ToString()).AppendLine(); sb.Append(" PlacementStrategy: ").AppendLine(); sb.Append(" ").Append(" Default Placement Strategy: ").Append(DefaultPlacementStrategy).AppendLine(); sb.Append(" ").Append(" Deployment Load Publisher Refresh Time: ").Append(DeploymentLoadPublisherRefreshTime).AppendLine(); sb.Append(" ").Append(" Activation CountBased Placement Choose Out Of: ").Append(ActivationCountBasedPlacementChooseOutOf).AppendLine(); sb.AppendFormat(" Grain directory cache:").AppendLine(); sb.AppendFormat(" Maximum size: {0} grains", CacheSize).AppendLine(); sb.AppendFormat(" Initial TTL: {0}", InitialCacheTTL).AppendLine(); sb.AppendFormat(" Maximum TTL: {0}", MaximumCacheTTL).AppendLine(); sb.AppendFormat(" TTL extension factor: {0:F2}", CacheTTLExtensionFactor).AppendLine(); sb.AppendFormat(" Directory Caching Strategy: {0}", DirectoryCachingStrategy).AppendLine(); sb.AppendFormat(" Grain directory:").AppendLine(); sb.AppendFormat(" Lazy deregistration delay: {0}", DirectoryLazyDeregistrationDelay).AppendLine(); sb.AppendFormat(" Client registration refresh: {0}", ClientRegistrationRefresh).AppendLine(); sb.AppendFormat(" Reminder Service:").AppendLine(); sb.AppendFormat(" ReminderServiceType: {0}", ReminderServiceType).AppendLine(); if (ReminderServiceType == ReminderServiceProviderType.MockTable) { sb.AppendFormat(" MockReminderTableTimeout: {0}ms", MockReminderTableTimeout.TotalMilliseconds).AppendLine(); } sb.AppendFormat(" Consistent Ring:").AppendLine(); sb.AppendFormat(" Use Virtual Buckets Consistent Ring: {0}", UseVirtualBucketsConsistentRing).AppendLine(); sb.AppendFormat(" Num Virtual Buckets Consistent Ring: {0}", NumVirtualBucketsConsistentRing).AppendLine(); sb.AppendFormat(" Providers:").AppendLine(); sb.Append(ProviderConfigurationUtility.PrintProviderConfigurations(ProviderConfigurations)); return(sb.ToString()); }
internal virtual void Load(XmlElement child) { ResponseTimeout = child.HasAttribute("ResponseTimeout") ? ConfigUtilities.ParseTimeSpan(child.GetAttribute("ResponseTimeout"), "Invalid ResponseTimeout") : Constants.DEFAULT_RESPONSE_TIMEOUT; if (child.HasAttribute("MaxResendCount")) { MaxResendCount = ConfigUtilities.ParseInt(child.GetAttribute("MaxResendCount"), "Invalid integer value for the MaxResendCount attribute on the Messaging element"); } if (child.HasAttribute("ResendOnTimeout")) { ResendOnTimeout = ConfigUtilities.ParseBool(child.GetAttribute("ResendOnTimeout"), "Invalid Boolean value for the ResendOnTimeout attribute on the Messaging element"); } if (child.HasAttribute("MaxSocketAge")) { MaxSocketAge = ConfigUtilities.ParseTimeSpan(child.GetAttribute("MaxSocketAge"), "Invalid time span set for the MaxSocketAge attribute on the Messaging element"); } if (child.HasAttribute("DropExpiredMessages")) { DropExpiredMessages = ConfigUtilities.ParseBool(child.GetAttribute("DropExpiredMessages"), "Invalid integer value for the DropExpiredMessages attribute on the Messaging element"); } //-- if (isSiloConfig) { if (child.HasAttribute("SiloSenderQueues")) { SiloSenderQueues = ConfigUtilities.ParseInt(child.GetAttribute("SiloSenderQueues"), "Invalid integer value for the SiloSenderQueues attribute on the Messaging element"); } if (child.HasAttribute("GatewaySenderQueues")) { GatewaySenderQueues = ConfigUtilities.ParseInt(child.GetAttribute("GatewaySenderQueues"), "Invalid integer value for the GatewaySenderQueues attribute on the Messaging element"); } ClientDropTimeout = child.HasAttribute("ClientDropTimeout") ? ConfigUtilities.ParseTimeSpan(child.GetAttribute("ClientDropTimeout"), "Invalid ClientDropTimeout") : Constants.DEFAULT_CLIENT_DROP_TIMEOUT; } else { if (child.HasAttribute("ClientSenderBuckets")) { ClientSenderBuckets = ConfigUtilities.ParseInt(child.GetAttribute("ClientSenderBuckets"), "Invalid integer value for the ClientSenderBuckets attribute on the Messaging element"); } } if (child.HasAttribute("UseStandardSerializer")) { UseStandardSerializer = ConfigUtilities.ParseBool(child.GetAttribute("UseStandardSerializer"), "invalid boolean value for the UseStandardSerializer attribute on the Messaging element"); } if (child.HasAttribute("UseJsonFallbackSerializer")) { UseJsonFallbackSerializer = ConfigUtilities.ParseBool(child.GetAttribute("UseJsonFallbackSerializer"), "invalid boolean value for the UseJsonFallbackSerializer attribute on the Messaging element"); } //-- if (child.HasAttribute("BufferPoolBufferSize")) { BufferPoolBufferSize = ConfigUtilities.ParseInt(child.GetAttribute("BufferPoolBufferSize"), "Invalid integer value for the BufferPoolBufferSize attribute on the Messaging element"); } if (child.HasAttribute("BufferPoolMaxSize")) { BufferPoolMaxSize = ConfigUtilities.ParseInt(child.GetAttribute("BufferPoolMaxSize"), "Invalid integer value for the BufferPoolMaxSize attribute on the Messaging element"); } if (child.HasAttribute("BufferPoolPreallocationSize")) { BufferPoolPreallocationSize = ConfigUtilities.ParseInt(child.GetAttribute("BufferPoolPreallocationSize"), "Invalid integer value for the BufferPoolPreallocationSize attribute on the Messaging element"); } if (child.HasAttribute("UseMessageBatching")) { UseMessageBatching = ConfigUtilities.ParseBool(child.GetAttribute("UseMessageBatching"), "Invalid boolean value for the UseMessageBatching attribute on the Messaging element"); } if (child.HasAttribute("MaxMessageBatchingSize")) { MaxMessageBatchingSize = ConfigUtilities.ParseInt(child.GetAttribute("MaxMessageBatchingSize"), "Invalid integer value for the MaxMessageBatchingSize attribute on the Messaging element"); } //-- if (isSiloConfig) { if (child.HasAttribute("MaxForwardCount")) { MaxForwardCount = ConfigUtilities.ParseInt(child.GetAttribute("MaxForwardCount"), "Invalid integer value for the MaxForwardCount attribute on the Messaging element"); } } if (child.HasChildNodes) { var serializerNode = child.ChildNodes.Cast <XmlElement>().FirstOrDefault(n => n.Name == "SerializationProviders"); if (serializerNode != null && serializerNode.HasChildNodes) { var typeNames = serializerNode.ChildNodes.Cast <XmlElement>() .Where(n => n.Name == "Provider") .Select(e => e.Attributes["type"]) .Where(a => a != null) .Select(a => a.Value); var types = typeNames.Select(t => ConfigUtilities.ParseFullyQualifiedType(t, "The type specification for the 'type' attribute of the Provider element could not be loaded")); foreach (var type in types) { ConfigUtilities.ValidateSerializationProvider(type); var typeinfo = type.GetTypeInfo(); if (SerializationProviders.Contains(typeinfo) == false) { SerializationProviders.Add(typeinfo); } } } } }
internal void Load(XmlElement root) { this.SiloName = root.LocalName.Equals("Override") ? root.GetAttribute("Node") : DEFAULT_NODE_NAME; foreach (XmlNode c in root.ChildNodes) { var child = c as XmlElement; if (child == null) { continue; // Skip comment lines } switch (child.LocalName) { case "Networking": if (child.HasAttribute("Address")) { this.HostNameOrIPAddress = child.GetAttribute("Address"); } if (child.HasAttribute("Port")) { this.Port = ConfigUtilities.ParseInt(child.GetAttribute("Port"), "Non-numeric Port attribute value on Networking element for " + this.SiloName); } if (child.HasAttribute("PreferredFamily")) { this.AddressType = ConfigUtilities.ParseEnum <AddressFamily>(child.GetAttribute("PreferredFamily"), "Invalid preferred address family on Networking node. Valid choices are 'InterNetwork' and 'InterNetworkV6'"); } break; case "ProxyingGateway": this.ProxyGatewayEndpoint = ConfigUtilities.ParseIPEndPoint(child, this.Subnet).GetResult(); break; case "Scheduler": if (child.HasAttribute("MaxActiveThreads")) { this.MaxActiveThreads = ConfigUtilities.ParseInt(child.GetAttribute("MaxActiveThreads"), "Non-numeric MaxActiveThreads attribute value on Scheduler element for " + this.SiloName); if (this.MaxActiveThreads < 1) { this.MaxActiveThreads = Math.Max(4, System.Environment.ProcessorCount); } } if (child.HasAttribute("DelayWarningThreshold")) { this.DelayWarningThreshold = ConfigUtilities.ParseTimeSpan(child.GetAttribute("DelayWarningThreshold"), "Non-numeric DelayWarningThreshold attribute value on Scheduler element for " + this.SiloName); } if (child.HasAttribute("ActivationSchedulingQuantum")) { this.ActivationSchedulingQuantum = ConfigUtilities.ParseTimeSpan(child.GetAttribute("ActivationSchedulingQuantum"), "Non-numeric ActivationSchedulingQuantum attribute value on Scheduler element for " + this.SiloName); } if (child.HasAttribute("TurnWarningLengthThreshold")) { this.TurnWarningLengthThreshold = ConfigUtilities.ParseTimeSpan(child.GetAttribute("TurnWarningLengthThreshold"), "Non-numeric TurnWarningLengthThreshold attribute value on Scheduler element for " + this.SiloName); } if (child.HasAttribute("MinDotNetThreadPoolSize")) { this.MinDotNetThreadPoolSize = ConfigUtilities.ParseInt(child.GetAttribute("MinDotNetThreadPoolSize"), "Invalid ParseInt MinDotNetThreadPoolSize value on Scheduler element for " + this.SiloName); } if (child.HasAttribute("Expect100Continue")) { this.Expect100Continue = ConfigUtilities.ParseBool(child.GetAttribute("Expect100Continue"), "Invalid ParseBool Expect100Continue value on Scheduler element for " + this.SiloName); } if (child.HasAttribute("DefaultConnectionLimit")) { this.DefaultConnectionLimit = ConfigUtilities.ParseInt(child.GetAttribute("DefaultConnectionLimit"), "Invalid ParseInt DefaultConnectionLimit value on Scheduler element for " + this.SiloName); } if (child.HasAttribute("UseNagleAlgorithm ")) { this.UseNagleAlgorithm = ConfigUtilities.ParseBool(child.GetAttribute("UseNagleAlgorithm "), "Invalid ParseBool UseNagleAlgorithm value on Scheduler element for " + this.SiloName); } break; case "LoadShedding": if (child.HasAttribute("Enabled")) { this.LoadSheddingEnabled = ConfigUtilities.ParseBool(child.GetAttribute("Enabled"), "Invalid boolean value for Enabled attribute on LoadShedding attribute for " + this.SiloName); } if (child.HasAttribute("LoadLimit")) { this.LoadSheddingLimit = ConfigUtilities.ParseInt(child.GetAttribute("LoadLimit"), "Invalid integer value for LoadLimit attribute on LoadShedding attribute for " + this.SiloName); if (this.LoadSheddingLimit < 0) { this.LoadSheddingLimit = 0; } if (this.LoadSheddingLimit > 100) { this.LoadSheddingLimit = 100; } } break; case "Tracing": if (ConfigUtilities.TryParsePropagateActivityId(child, this.siloName, out var propagateActivityId)) { this.PropagateActivityId = propagateActivityId; } break; case "Statistics": ConfigUtilities.ParseStatistics(this, child, this.SiloName); break; case "Limits": ConfigUtilities.ParseLimitValues(this.LimitManager, child, this.SiloName); break; case "Startup": if (child.HasAttribute("Type")) { this.StartupTypeName = child.GetAttribute("Type"); } break; case "Telemetry": ConfigUtilities.ParseTelemetry(child, this.TelemetryConfiguration); break; case "AdditionalAssemblyDirectories": ConfigUtilities.ParseAdditionalAssemblyDirectories(this.AdditionalAssemblyDirectories, child); 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; } } } }
internal virtual void Load(XmlElement child) { ResponseTimeout = child.HasAttribute("ResponseTimeout") ? ConfigUtilities.ParseTimeSpan(child.GetAttribute("ResponseTimeout"), "Invalid ResponseTimeout") : Constants.DEFAULT_RESPONSE_TIMEOUT; if (child.HasAttribute("MaxResendCount")) { MaxResendCount = ConfigUtilities.ParseInt(child.GetAttribute("MaxResendCount"), "Invalid integer value for the MaxResendCount attribute on the Messaging element"); } if (child.HasAttribute("ResendOnTimeout")) { ResendOnTimeout = ConfigUtilities.ParseBool(child.GetAttribute("ResendOnTimeout"), "Invalid Boolean value for the ResendOnTimeout attribute on the Messaging element"); } if (child.HasAttribute("MaxSocketAge")) { MaxSocketAge = ConfigUtilities.ParseTimeSpan(child.GetAttribute("MaxSocketAge"), "Invalid time span set for the MaxSocketAge attribute on the Messaging element"); } if (child.HasAttribute("DropExpiredMessages")) { DropExpiredMessages = ConfigUtilities.ParseBool(child.GetAttribute("DropExpiredMessages"), "Invalid integer value for the DropExpiredMessages attribute on the Messaging element"); } //-- if (isSiloConfig) { if (child.HasAttribute("SiloSenderQueues")) { SiloSenderQueues = ConfigUtilities.ParseInt(child.GetAttribute("SiloSenderQueues"), "Invalid integer value for the SiloSenderQueues attribute on the Messaging element"); } if (child.HasAttribute("GatewaySenderQueues")) { GatewaySenderQueues = ConfigUtilities.ParseInt(child.GetAttribute("GatewaySenderQueues"), "Invalid integer value for the GatewaySenderQueues attribute on the Messaging element"); } } else { if (child.HasAttribute("ClientSenderBuckets")) { ClientSenderBuckets = ConfigUtilities.ParseInt(child.GetAttribute("ClientSenderBuckets"), "Invalid integer value for the ClientSenderBuckets attribute on the Messaging element"); } } if (child.HasAttribute("UseStandardSerializer")) { UseStandardSerializer = ConfigUtilities.ParseBool(child.GetAttribute("UseStandardSerializer"), "invalid boolean value for the UseStandardSerializer attribute on the Messaging element"); } //-- if (child.HasAttribute("BufferPoolBufferSize")) { BufferPoolBufferSize = ConfigUtilities.ParseInt(child.GetAttribute("BufferPoolBufferSize"), "Invalid integer value for the BufferPoolBufferSize attribute on the Messaging element"); } if (child.HasAttribute("BufferPoolMaxSize")) { BufferPoolMaxSize = ConfigUtilities.ParseInt(child.GetAttribute("BufferPoolMaxSize"), "Invalid integer value for the BufferPoolMaxSize attribute on the Messaging element"); } if (child.HasAttribute("BufferPoolPreallocationSize")) { BufferPoolPreallocationSize = ConfigUtilities.ParseInt(child.GetAttribute("BufferPoolPreallocationSize"), "Invalid integer value for the BufferPoolPreallocationSize attribute on the Messaging element"); } if (child.HasAttribute("UseMessageBatching")) { UseMessageBatching = ConfigUtilities.ParseBool(child.GetAttribute("UseMessageBatching"), "Invalid boolean value for the UseMessageBatching attribute on the Messaging element"); } if (child.HasAttribute("MaxMessageBatchingSize")) { MaxMessageBatchingSize = ConfigUtilities.ParseInt(child.GetAttribute("MaxMessageBatchingSize"), "Invalid integer value for the MaxMessageBatchingSize attribute on the Messaging element"); } //-- if (isSiloConfig) { if (child.HasAttribute("MaxForwardCount")) { MaxForwardCount = ConfigUtilities.ParseInt(child.GetAttribute("MaxForwardCount"), "Invalid integer value for the MaxForwardCount attribute on the Messaging element"); } } }