Esempio n. 1
0
        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).GetResult();
                    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(LimitManager, child, SiloName);
                    break;

                case "Startup":
                    if (child.HasAttribute("Type"))
                    {
                        StartupTypeName = child.GetAttribute("Type");
                    }
                    break;

                case "Telemetry":
                    ConfigUtilities.ParseTelemetry(child);
                    break;
                }
            }
        }
Esempio n. 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":
                        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;
                    }
                }
            }
        }
Esempio n. 3
0
        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;
                    }
                }
            }
        }