Exemple #1
0
        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 = SchedulingOptions.DEFAULT_MAX_ACTIVE_THREADS;
                        }
                    }
                    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;
                }
            }
        }
Exemple #2
0
        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":
                        if (ConfigUtilities.TryParsePropagateActivityId(child, ClientName, out var propagateActivityId))
                        {
                            this.PropagateActivityId = propagateActivityId;
                        }
                        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, this.TelemetryConfiguration);
                        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;
                    }
                }
            }
        }