Exemplo 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;
                }
            }
        }
Exemplo n.º 2
0
        internal virtual void Load(XmlElement child)
        {
            ResponseTimeout = child.HasAttribute("ResponseTimeout")
                                      ? ConfigUtilities.ParseTimeSpan(child.GetAttribute("ResponseTimeout"),
                                                                      "Invalid ResponseTimeout")
                                      : MessagingOptions.DEFAULT_RESPONSE_TIMEOUT;

            if (child.HasAttribute("LargeMessageWarningThreshold"))
            {
                LargeMessageWarningThreshold = ConfigUtilities.ParseInt(child.GetAttribute("LargeMessageWarningThreshold"),
                                                                        "Invalid boolean value for LargeMessageWarningThresholdattribute");
            }

            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();
                }
            }
        }
Exemplo n.º 3
0
        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.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"));
                    foreach (var type in types)
                    {
                        var typeinfo = type.GetTypeInfo();
                        ConfigUtilities.ValidateSerializationProvider(typeinfo);
                        if (SerializationProviders.Contains(typeinfo) == false)
                        {
                            SerializationProviders.Add(typeinfo);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
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 = 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;
                }
            }
        }
Exemplo n.º 5
0
        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;
                }
            }
        }
Exemplo n.º 6
0
        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");
                }
            }
        }