private void UpdateMethodStats(RPCMethodConfig method)
 {
     this.m_data.Stats.MethodCount += 1u;
     if (method.HasServiceName)
     {
         this.m_data.Stats.ServiceNameCount += 1u;
     }
     if (method.HasMethodName)
     {
         this.m_data.Stats.MethodNameCount += 1u;
     }
     if (method.HasFixedCallCost)
     {
         this.m_data.Stats.FixedCalledCostCount += 1u;
     }
     if (method.HasFixedPacketSize)
     {
         this.m_data.Stats.FixedPacketSizeCount += 1u;
     }
     if (method.HasVariableMultiplier)
     {
         this.m_data.Stats.VariableMultiplierCount += 1u;
     }
     if (method.HasMultiplier)
     {
         this.m_data.Stats.MultiplierCount += 1u;
     }
     if (method.HasRateLimitCount)
     {
         this.m_data.Stats.RateLimitCountCount           += 1u;
         this.m_data.Stats.AggregatedRateLimitCountCount += method.RateLimitCount;
     }
     if (method.HasRateLimitSeconds)
     {
         this.m_data.Stats.RateLimitSecondsCount += 1u;
     }
     if (method.HasMaxPacketSize)
     {
         this.m_data.Stats.MaxPacketSizeCount += 1u;
     }
     if (method.HasMaxEncodedSize)
     {
         this.m_data.Stats.MaxEncodedSizeCount += 1u;
     }
     if (method.HasTimeout)
     {
         this.m_data.Stats.TimeoutCount += 1u;
     }
 }
Exemplo n.º 2
0
    private bool UpdateConfigStats(RPCMeterConfig config)
    {
        int methodCount = config.MethodCount;

        for (int i = 0; i < methodCount; i++)
        {
            RPCMethodConfig method = config.Method[i];
            this.UpdateMethodStats(method);
        }
        Stats stats = this.m_data.Stats;

        this.m_log.LogDebug("Config Stats:");
        object[] args = new object[] { stats.MethodCount };
        this.m_log.LogDebug("  MethodCount={0}", args);
        object[] objArray2 = new object[] { stats.ServiceNameCount };
        this.m_log.LogDebug("  ServiceNameCount={0}", objArray2);
        object[] objArray3 = new object[] { stats.MethodNameCount };
        this.m_log.LogDebug("  MethodNameCount={0}", objArray3);
        object[] objArray4 = new object[] { stats.FixedCalledCostCount };
        this.m_log.LogDebug("  FixedCalledCostCount={0}", objArray4);
        object[] objArray5 = new object[] { stats.FixedPacketSizeCount };
        this.m_log.LogDebug("  FixedPacketSizeCount={0}", objArray5);
        object[] objArray6 = new object[] { stats.VariableMultiplierCount };
        this.m_log.LogDebug("  VariableMultiplierCount={0}", objArray6);
        object[] objArray7 = new object[] { stats.MultiplierCount };
        this.m_log.LogDebug("  MultiplierCount={0}", objArray7);
        object[] objArray8 = new object[] { stats.RateLimitCountCount };
        this.m_log.LogDebug("  RateLimitCountCount={0}", objArray8);
        object[] objArray9 = new object[] { stats.RateLimitSecondsCount };
        this.m_log.LogDebug("  RateLimitSecondsCount={0}", objArray9);
        object[] objArray10 = new object[] { stats.MaxPacketSizeCount };
        this.m_log.LogDebug("  MaxPacketSizeCount={0}", objArray10);
        object[] objArray11 = new object[] { stats.MaxEncodedSizeCount };
        this.m_log.LogDebug("  MaxEncodedSizeCount={0}", objArray11);
        object[] objArray12 = new object[] { stats.TimeoutCount };
        this.m_log.LogDebug("  TimeoutCount={0}", objArray12);
        object[] objArray13 = new object[] { stats.AggregatedRateLimitCountCount };
        this.m_log.LogDebug("  AggregatedRateLimitCountCount={0}", objArray13);
        return(true);
    }
 public void FromProtocol(RPCMethodConfig method)
 {
     if (method.HasServiceName)
     {
         this.ServiceName = method.ServiceName;
     }
     if (method.HasMethodName)
     {
         this.MethodName = method.MethodName;
     }
     if (method.HasFixedCallCost)
     {
         this.FixedCallCost = method.FixedCallCost;
     }
     if (method.HasRateLimitCount)
     {
         this.RateLimitCount = method.RateLimitCount;
     }
     if (method.HasRateLimitSeconds)
     {
         this.RateLimitSeconds = method.RateLimitSeconds;
     }
 }
Exemplo n.º 4
0
        public static RPCMethodConfig ParseMethod(Tokenizer tokenizer)
        {
            RPCMethodConfig rpcmethodConfig = new RPCMethodConfig();

            tokenizer.NextOpenBracket();
            for (;;)
            {
                string text = tokenizer.NextString();
                if (text == null)
                {
                    break;
                }
                if (text == "}")
                {
                    return(rpcmethodConfig);
                }
                if (text == null)
                {
                    goto IL_1E7;
                }
                if (RPCMeterConfigParser.< > f__switch$map1 == null)
                {
                    RPCMeterConfigParser.< > f__switch$map1 = new Dictionary <string, int>(11)
                    {
                        {
                            "service_name:",
                            0
                        },
                        {
                            "method_name:",
                            1
                        },
                        {
                            "fixed_call_cost:",
                            2
                        },
                        {
                            "fixed_packet_size:",
                            3
                        },
                        {
                            "variable_multiplier:",
                            4
                        },
                        {
                            "multiplier:",
                            5
                        },
                        {
                            "rate_limit_count:",
                            6
                        },
                        {
                            "rate_limit_seconds:",
                            7
                        },
                        {
                            "max_packet_size:",
                            8
                        },
                        {
                            "max_encoded_size:",
                            9
                        },
                        {
                            "timeout:",
                            10
                        }
                    };
                }
                int num;
                if (!RPCMeterConfigParser.< > f__switch$map1.TryGetValue(text, out num))
                {
                    goto IL_1E7;
                }
                switch (num)
                {
                case 0:
                    rpcmethodConfig.ServiceName = tokenizer.NextQuotedString();
                    break;

                case 1:
                    rpcmethodConfig.MethodName = tokenizer.NextQuotedString();
                    break;

                case 2:
                    rpcmethodConfig.FixedCallCost = tokenizer.NextUInt32();
                    break;

                case 3:
                    rpcmethodConfig.FixedPacketSize = tokenizer.NextUInt32();
                    break;

                case 4:
                    rpcmethodConfig.VariableMultiplier = tokenizer.NextUInt32();
                    break;

                case 5:
                    rpcmethodConfig.Multiplier = tokenizer.NextFloat();
                    break;

                case 6:
                    rpcmethodConfig.RateLimitCount = tokenizer.NextUInt32();
                    break;

                case 7:
                    rpcmethodConfig.RateLimitSeconds = tokenizer.NextUInt32();
                    break;

                case 8:
                    rpcmethodConfig.MaxPacketSize = tokenizer.NextUInt32();
                    break;

                case 9:
                    rpcmethodConfig.MaxEncodedSize = tokenizer.NextUInt32();
                    break;

                case 10:
                    rpcmethodConfig.Timeout = tokenizer.NextFloat();
                    break;

                case 11:
                    goto IL_1E7;

                default:
                    goto IL_1E7;
                }
                continue;
IL_1E7:
                tokenizer.SkipUnknownToken();
            }
            throw new Exception("Parsing ended with unfinished RPCMethodConfig");
        }
        private bool UpdateConfigStats(RPCMeterConfig config)
        {
            int methodCount = config.MethodCount;

            for (int i = 0; i < methodCount; i++)
            {
                RPCMethodConfig method = config.Method[i];
                this.UpdateMethodStats(method);
            }
            RPCConnectionMetering.Stats stats = this.m_data.Stats;
            this.m_log.LogDebug("Config Stats:");
            this.m_log.LogDebug("  MethodCount={0}", new object[]
            {
                stats.MethodCount
            });
            this.m_log.LogDebug("  ServiceNameCount={0}", new object[]
            {
                stats.ServiceNameCount
            });
            this.m_log.LogDebug("  MethodNameCount={0}", new object[]
            {
                stats.MethodNameCount
            });
            this.m_log.LogDebug("  FixedCalledCostCount={0}", new object[]
            {
                stats.FixedCalledCostCount
            });
            this.m_log.LogDebug("  FixedPacketSizeCount={0}", new object[]
            {
                stats.FixedPacketSizeCount
            });
            this.m_log.LogDebug("  VariableMultiplierCount={0}", new object[]
            {
                stats.VariableMultiplierCount
            });
            this.m_log.LogDebug("  MultiplierCount={0}", new object[]
            {
                stats.MultiplierCount
            });
            this.m_log.LogDebug("  RateLimitCountCount={0}", new object[]
            {
                stats.RateLimitCountCount
            });
            this.m_log.LogDebug("  RateLimitSecondsCount={0}", new object[]
            {
                stats.RateLimitSecondsCount
            });
            this.m_log.LogDebug("  MaxPacketSizeCount={0}", new object[]
            {
                stats.MaxPacketSizeCount
            });
            this.m_log.LogDebug("  MaxEncodedSizeCount={0}", new object[]
            {
                stats.MaxEncodedSizeCount
            });
            this.m_log.LogDebug("  TimeoutCount={0}", new object[]
            {
                stats.TimeoutCount
            });
            this.m_log.LogDebug("  AggregatedRateLimitCountCount={0}", new object[]
            {
                stats.AggregatedRateLimitCountCount
            });
            return(true);
        }
        private void InitializeInternalState(RPCMeterConfig config, ServiceCollectionHelper serviceHelper)
        {
            List <string> list        = new List <string>();
            List <string> list2       = new List <string>();
            int           methodCount = config.MethodCount;

            for (int i = 0; i < methodCount; i++)
            {
                RPCMethodConfig rpcmethodConfig             = config.Method[i];
                RPCConnectionMetering.StaticData staticData = new RPCConnectionMetering.StaticData();
                staticData.FromProtocol(rpcmethodConfig);
                if (!rpcmethodConfig.HasServiceName)
                {
                    if (this.m_data.GlobalDefault == null)
                    {
                        this.m_data.GlobalDefault = staticData;
                        this.m_log.LogDebug("Adding global default {0}", new object[]
                        {
                            staticData
                        });
                    }
                    else
                    {
                        this.m_log.LogWarning("Static data has two defaults, ignoring additional ones.");
                    }
                }
                else
                {
                    string            serviceName           = rpcmethodConfig.ServiceName;
                    ServiceDescriptor importedServiceByName = serviceHelper.GetImportedServiceByName(serviceName);
                    if (importedServiceByName == null)
                    {
                        if (!list2.Contains(serviceName))
                        {
                            this.m_log.LogDebug("Ignoring not imported service {0}", new object[]
                            {
                                serviceName
                            });
                            list2.Add(serviceName);
                        }
                    }
                    else
                    {
                        staticData.ServiceId = importedServiceByName.Id;
                        if (rpcmethodConfig.HasMethodName)
                        {
                            string           methodName             = rpcmethodConfig.MethodName;
                            string           text                   = string.Format("{0}.{1}", serviceName, methodName);
                            MethodDescriptor methodDescriptorByName = importedServiceByName.GetMethodDescriptorByName(text);
                            if (methodDescriptorByName == null)
                            {
                                this.m_log.LogDebug("Configuration specifies an unused method {0}, ignoring.", new object[]
                                {
                                    methodName
                                });
                                goto IL_231;
                            }
                            if (this.m_data.MethodDefaults.ContainsKey(text))
                            {
                                this.m_log.LogWarning("Default for method {0} already exists, ignoring extras.", new object[]
                                {
                                    text
                                });
                                goto IL_231;
                            }
                            staticData.MethodId = methodDescriptorByName.Id;
                            this.m_data.MethodDefaults[text] = staticData;
                            this.m_log.LogDebug("Adding Method default {0}", new object[]
                            {
                                staticData
                            });
                        }
                        else
                        {
                            if (this.m_data.ServiceDefaults.ContainsKey(serviceName))
                            {
                                this.m_log.LogWarning("Default for service {0} already exists, ignoring extras.", new object[]
                                {
                                    serviceName
                                });
                                goto IL_231;
                            }
                            this.m_data.ServiceDefaults[serviceName] = staticData;
                            this.m_log.LogDebug("Adding Service default {0}", new object[]
                            {
                                staticData
                            });
                        }
                        list.Add(serviceName);
                    }
                }
                IL_231 :;
            }
            foreach (KeyValuePair <uint, ServiceDescriptor> keyValuePair in serviceHelper.ImportedServices)
            {
                if (!list.Contains(keyValuePair.Value.Name) && this.m_data.GlobalDefault == null)
                {
                    this.m_log.LogDebug("Configuration for service {0} was not found and will not be metered.", new object[]
                    {
                        keyValuePair.Value.Name
                    });
                }
            }
        }
Exemplo n.º 7
0
        public static RPCMethodConfig ParseMethod(Tokenizer tokenizer)
        {
            RPCMethodConfig rPCMethodConfig = new RPCMethodConfig();

            tokenizer.NextOpenBracket();
            while (true)
            {
                string text = tokenizer.NextString();
                if (text == null)
                {
                    break;
                }
                if (text == "}")
                {
                    return(rPCMethodConfig);
                }
                string text2 = text;
                if (text2 == null)
                {
                    goto IL_1E6;
                }
                if (RPCMeterConfigParser.< > f__switch$mapC == null)
                {
                    Dictionary <string, int> dictionary = new Dictionary <string, int>(11);
                    dictionary.Add("service_name:", 0);
                    dictionary.Add("method_name:", 1);
                    dictionary.Add("fixed_call_cost:", 2);
                    dictionary.Add("fixed_packet_size:", 3);
                    dictionary.Add("variable_multiplier:", 4);
                    dictionary.Add("multiplier:", 5);
                    dictionary.Add("rate_limit_count:", 6);
                    dictionary.Add("rate_limit_seconds:", 7);
                    dictionary.Add("max_packet_size:", 8);
                    dictionary.Add("max_encoded_size:", 9);
                    dictionary.Add("timeout:", 10);
                    RPCMeterConfigParser.< > f__switch$mapC = dictionary;
                }
                int num;
                if (!RPCMeterConfigParser.< > f__switch$mapC.TryGetValue(text2, ref num))
                {
                    goto IL_1E6;
                }
                switch (num)
                {
                case 0:
                    rPCMethodConfig.ServiceName = tokenizer.NextQuotedString();
                    break;

                case 1:
                    rPCMethodConfig.MethodName = tokenizer.NextQuotedString();
                    break;

                case 2:
                    rPCMethodConfig.FixedCallCost = tokenizer.NextUInt32();
                    break;

                case 3:
                    rPCMethodConfig.FixedPacketSize = tokenizer.NextUInt32();
                    break;

                case 4:
                    rPCMethodConfig.VariableMultiplier = tokenizer.NextUInt32();
                    break;

                case 5:
                    rPCMethodConfig.Multiplier = tokenizer.NextFloat();
                    break;

                case 6:
                    rPCMethodConfig.RateLimitCount = tokenizer.NextUInt32();
                    break;

                case 7:
                    rPCMethodConfig.RateLimitSeconds = tokenizer.NextUInt32();
                    break;

                case 8:
                    rPCMethodConfig.MaxPacketSize = tokenizer.NextUInt32();
                    break;

                case 9:
                    rPCMethodConfig.MaxEncodedSize = tokenizer.NextUInt32();
                    break;

                case 10:
                    rPCMethodConfig.Timeout = tokenizer.NextFloat();
                    break;

                default:
                    goto IL_1E6;
                }
                continue;
IL_1E6:
                tokenizer.SkipUnknownToken();
            }
            throw new Exception("Parsing ended with unfinished RPCMethodConfig");
        }
 private void UpdateMethodStats(RPCMethodConfig method)
 {
     RPCConnectionMetering.Stats stats = this.m_data.Stats;
     stats.MethodCount = stats.MethodCount + 1;
     if (method.HasServiceName)
     {
         RPCConnectionMetering.Stats serviceNameCount = this.m_data.Stats;
         serviceNameCount.ServiceNameCount = serviceNameCount.ServiceNameCount + 1;
     }
     if (method.HasMethodName)
     {
         RPCConnectionMetering.Stats methodNameCount = this.m_data.Stats;
         methodNameCount.MethodNameCount = methodNameCount.MethodNameCount + 1;
     }
     if (method.HasFixedCallCost)
     {
         RPCConnectionMetering.Stats fixedCalledCostCount = this.m_data.Stats;
         fixedCalledCostCount.FixedCalledCostCount = fixedCalledCostCount.FixedCalledCostCount + 1;
     }
     if (method.HasFixedPacketSize)
     {
         RPCConnectionMetering.Stats fixedPacketSizeCount = this.m_data.Stats;
         fixedPacketSizeCount.FixedPacketSizeCount = fixedPacketSizeCount.FixedPacketSizeCount + 1;
     }
     if (method.HasVariableMultiplier)
     {
         RPCConnectionMetering.Stats variableMultiplierCount = this.m_data.Stats;
         variableMultiplierCount.VariableMultiplierCount = variableMultiplierCount.VariableMultiplierCount + 1;
     }
     if (method.HasMultiplier)
     {
         RPCConnectionMetering.Stats multiplierCount = this.m_data.Stats;
         multiplierCount.MultiplierCount = multiplierCount.MultiplierCount + 1;
     }
     if (method.HasRateLimitCount)
     {
         RPCConnectionMetering.Stats rateLimitCountCount = this.m_data.Stats;
         rateLimitCountCount.RateLimitCountCount = rateLimitCountCount.RateLimitCountCount + 1;
         RPCConnectionMetering.Stats aggregatedRateLimitCountCount = this.m_data.Stats;
         aggregatedRateLimitCountCount.AggregatedRateLimitCountCount = aggregatedRateLimitCountCount.AggregatedRateLimitCountCount + method.RateLimitCount;
     }
     if (method.HasRateLimitSeconds)
     {
         RPCConnectionMetering.Stats rateLimitSecondsCount = this.m_data.Stats;
         rateLimitSecondsCount.RateLimitSecondsCount = rateLimitSecondsCount.RateLimitSecondsCount + 1;
     }
     if (method.HasMaxPacketSize)
     {
         RPCConnectionMetering.Stats maxPacketSizeCount = this.m_data.Stats;
         maxPacketSizeCount.MaxPacketSizeCount = maxPacketSizeCount.MaxPacketSizeCount + 1;
     }
     if (method.HasMaxEncodedSize)
     {
         RPCConnectionMetering.Stats maxEncodedSizeCount = this.m_data.Stats;
         maxEncodedSizeCount.MaxEncodedSizeCount = maxEncodedSizeCount.MaxEncodedSizeCount + 1;
     }
     if (method.HasTimeout)
     {
         RPCConnectionMetering.Stats timeoutCount = this.m_data.Stats;
         timeoutCount.TimeoutCount = timeoutCount.TimeoutCount + 1;
     }
 }
        private void InitializeInternalState(RPCMeterConfig config, ServiceCollectionHelper serviceHelper)
        {
            string        serviceName;
            string        str;
            List <string> strs        = new List <string>();
            List <string> strs1       = new List <string>();
            int           methodCount = config.MethodCount;

            for (int i = 0; i < methodCount; i++)
            {
                RPCMethodConfig item = config.Method[i];
                RPCConnectionMetering.StaticData staticDatum = new RPCConnectionMetering.StaticData();
                staticDatum.FromProtocol(item);
                if (item.HasServiceName)
                {
                    serviceName = item.ServiceName;
                    ServiceDescriptor importedServiceByName = serviceHelper.GetImportedServiceByName(serviceName);
                    if (importedServiceByName != null)
                    {
                        staticDatum.ServiceId = importedServiceByName.Id;
                        if (!item.HasMethodName)
                        {
                            if (this.m_data.ServiceDefaults.ContainsKey(serviceName))
                            {
                                goto Label1;
                            }
                            this.m_data.ServiceDefaults[serviceName] = staticDatum;
                            this.m_log.LogDebug("Adding Service default {0}", new object[] { staticDatum });
                        }
                        else
                        {
                            string methodName = item.MethodName;
                            str = string.Format("{0}.{1}", serviceName, methodName);
                            MethodDescriptor methodDescriptorByName = importedServiceByName.GetMethodDescriptorByName(str);
                            if (methodDescriptorByName != null)
                            {
                                if (this.m_data.MethodDefaults.ContainsKey(str))
                                {
                                    goto Label2;
                                }
                                staticDatum.MethodId            = methodDescriptorByName.Id;
                                this.m_data.MethodDefaults[str] = staticDatum;
                                this.m_log.LogDebug("Adding Method default {0}", new object[] { staticDatum });
                            }
                            else
                            {
                                this.m_log.LogDebug("Configuration specifies an unused method {0}, ignoring.", new object[] { methodName });
                                goto Label0;
                            }
                        }
                        strs.Add(serviceName);
                    }
                    else if (!strs1.Contains(serviceName))
                    {
                        this.m_log.LogDebug("Ignoring not imported service {0}", new object[] { serviceName });
                        strs1.Add(serviceName);
                    }
                }
                else if (this.m_data.GlobalDefault != null)
                {
                    this.m_log.LogWarning("Static data has two defaults, ignoring additional ones.");
                }
                else
                {
                    this.m_data.GlobalDefault = staticDatum;
                    this.m_log.LogDebug("Adding global default {0}", new object[] { staticDatum });
                }
Label0:
            }
            foreach (KeyValuePair <uint, ServiceDescriptor> importedService in serviceHelper.ImportedServices)
            {
                if (strs.Contains(importedService.Value.Name) || this.m_data.GlobalDefault != null)
                {
                    continue;
                }
                this.m_log.LogDebug("Configuration for service {0} was not found and will not be metered.", new object[] { importedService.Value.Name });
            }
            return;

Label1:
            BattleNetLogSource mLog = this.m_log;

            mLog.LogWarning("Default for service {0} already exists, ignoring extras.", new object[] { serviceName });
            goto Label0;
Label2:
            BattleNetLogSource battleNetLogSource = this.m_log;

            battleNetLogSource.LogWarning("Default for method {0} already exists, ignoring extras.", new object[] { str });
            goto Label0;
        }
Exemplo n.º 10
0
        public static RPCMethodConfig ParseMethod(Tokenizer tokenizer)
        {
            int             num;
            RPCMethodConfig rPCMethodConfig = new RPCMethodConfig();

            tokenizer.NextOpenBracket();
            while (true)
            {
Label2:
                string str = tokenizer.NextString();
                if (str == null)
                {
                    throw new Exception("Parsing ended with unfinished RPCMethodConfig");
                }
                if (str == "}")
                {
                    break;
                }
                if (str != null)
                {
                    if (RPCMeterConfigParser.< > f__switch$map1 == null)
                    {
                        Dictionary <string, int> strs = new Dictionary <string, int>(11)
                        {
                            { "service_name:", 0 },
                            { "method_name:", 1 },
                            { "fixed_call_cost:", 2 },
                            { "fixed_packet_size:", 3 },
                            { "variable_multiplier:", 4 },
                            { "multiplier:", 5 },
                            { "rate_limit_count:", 6 },
                            { "rate_limit_seconds:", 7 },
                            { "max_packet_size:", 8 },
                            { "max_encoded_size:", 9 },
                            { "timeout:", 10 }
                        };
                        RPCMeterConfigParser.< > f__switch$map1 = strs;
                    }
                    if (RPCMeterConfigParser.< > f__switch$map1.TryGetValue(str, out num))
                    {
                        switch (num)
                        {
                        case 0:
                        {
                            rPCMethodConfig.ServiceName = tokenizer.NextQuotedString();
                            break;
                        }

                        case 1:
                        {
                            rPCMethodConfig.MethodName = tokenizer.NextQuotedString();
                            break;
                        }

                        case 2:
                        {
                            rPCMethodConfig.FixedCallCost = tokenizer.NextUInt32();
                            break;
                        }

                        case 3:
                        {
                            rPCMethodConfig.FixedPacketSize = tokenizer.NextUInt32();
                            break;
                        }

                        case 4:
                        {
                            rPCMethodConfig.VariableMultiplier = (float)((float)tokenizer.NextUInt32());
                            break;
                        }

                        case 5:
                        {
                            rPCMethodConfig.Multiplier = tokenizer.NextFloat();
                            break;
                        }

                        case 6:
                        {
                            rPCMethodConfig.RateLimitCount = tokenizer.NextUInt32();
                            break;
                        }

                        case 7:
                        {
                            rPCMethodConfig.RateLimitSeconds = tokenizer.NextUInt32();
                            break;
                        }

                        case 8:
                        {
                            rPCMethodConfig.MaxPacketSize = tokenizer.NextUInt32();
                            break;
                        }

                        case 9:
                        {
                            rPCMethodConfig.MaxEncodedSize = tokenizer.NextUInt32();
                            break;
                        }

                        case 10:
                        {
                            rPCMethodConfig.Timeout = tokenizer.NextFloat();
                            break;
                        }

                        default:
                        {
                            goto Label1;
                        }
                        }
                    }
                    else
                    {
                        goto Label1;
                    }
                }
Exemplo n.º 11
0
    private void UpdateMethodStats(RPCMethodConfig method)
    {
        Stats stats = this.m_data.Stats;

        stats.MethodCount++;
        if (method.HasServiceName)
        {
            Stats stats2 = this.m_data.Stats;
            stats2.ServiceNameCount++;
        }
        if (method.HasMethodName)
        {
            Stats stats3 = this.m_data.Stats;
            stats3.MethodNameCount++;
        }
        if (method.HasFixedCallCost)
        {
            Stats stats4 = this.m_data.Stats;
            stats4.FixedCalledCostCount++;
        }
        if (method.HasFixedPacketSize)
        {
            Stats stats5 = this.m_data.Stats;
            stats5.FixedPacketSizeCount++;
        }
        if (method.HasVariableMultiplier)
        {
            Stats stats6 = this.m_data.Stats;
            stats6.VariableMultiplierCount++;
        }
        if (method.HasMultiplier)
        {
            Stats stats7 = this.m_data.Stats;
            stats7.MultiplierCount++;
        }
        if (method.HasRateLimitCount)
        {
            Stats stats8 = this.m_data.Stats;
            stats8.RateLimitCountCount++;
            Stats stats9 = this.m_data.Stats;
            stats9.AggregatedRateLimitCountCount += method.RateLimitCount;
        }
        if (method.HasRateLimitSeconds)
        {
            Stats stats10 = this.m_data.Stats;
            stats10.RateLimitSecondsCount++;
        }
        if (method.HasMaxPacketSize)
        {
            Stats stats11 = this.m_data.Stats;
            stats11.MaxPacketSizeCount++;
        }
        if (method.HasMaxEncodedSize)
        {
            Stats stats12 = this.m_data.Stats;
            stats12.MaxEncodedSizeCount++;
        }
        if (method.HasTimeout)
        {
            Stats stats13 = this.m_data.Stats;
            stats13.TimeoutCount++;
        }
    }
Exemplo n.º 12
0
    private void InitializeInternalState(RPCMeterConfig config, ServiceCollectionHelper serviceHelper)
    {
        List <string> list        = new List <string>();
        List <string> list2       = new List <string>();
        int           methodCount = config.MethodCount;

        for (int i = 0; i < methodCount; i++)
        {
            RPCMethodConfig method = config.Method[i];
            StaticData      data   = new StaticData();
            data.FromProtocol(method);
            if (!method.HasServiceName)
            {
                if (this.m_data.GlobalDefault == null)
                {
                    this.m_data.GlobalDefault = data;
                    object[] args = new object[] { data };
                    this.m_log.LogDebug("Adding global default {0}", args);
                }
                else
                {
                    this.m_log.LogWarning("Static data has two defaults, ignoring additional ones.");
                }
            }
            else
            {
                string            serviceName           = method.ServiceName;
                ServiceDescriptor importedServiceByName = serviceHelper.GetImportedServiceByName(serviceName);
                if (importedServiceByName == null)
                {
                    if (!list2.Contains(serviceName))
                    {
                        object[] objArray2 = new object[] { serviceName };
                        this.m_log.LogDebug("Ignoring not imported service {0}", objArray2);
                        list2.Add(serviceName);
                    }
                }
                else
                {
                    data.ServiceId = importedServiceByName.Id;
                    if (method.HasMethodName)
                    {
                        string           methodName             = method.MethodName;
                        string           name                   = string.Format("{0}.{1}", serviceName, methodName);
                        MethodDescriptor methodDescriptorByName = importedServiceByName.GetMethodDescriptorByName(name);
                        if (methodDescriptorByName == null)
                        {
                            object[] objArray3 = new object[] { methodName };
                            this.m_log.LogDebug("Configuration specifies an unused method {0}, ignoring.", objArray3);
                            goto Label_0231;
                        }
                        if (this.m_data.MethodDefaults.ContainsKey(name))
                        {
                            object[] objArray4 = new object[] { name };
                            this.m_log.LogWarning("Default for method {0} already exists, ignoring extras.", objArray4);
                            goto Label_0231;
                        }
                        data.MethodId = methodDescriptorByName.Id;
                        this.m_data.MethodDefaults[name] = data;
                        object[] objArray5 = new object[] { data };
                        this.m_log.LogDebug("Adding Method default {0}", objArray5);
                    }
                    else
                    {
                        if (this.m_data.ServiceDefaults.ContainsKey(serviceName))
                        {
                            object[] objArray6 = new object[] { serviceName };
                            this.m_log.LogWarning("Default for service {0} already exists, ignoring extras.", objArray6);
                            goto Label_0231;
                        }
                        this.m_data.ServiceDefaults[serviceName] = data;
                        object[] objArray7 = new object[] { data };
                        this.m_log.LogDebug("Adding Service default {0}", objArray7);
                    }
                    list.Add(serviceName);
                    Label_0231 :;
                }
            }
        }
        foreach (KeyValuePair <uint, ServiceDescriptor> pair in serviceHelper.ImportedServices)
        {
            if (!list.Contains(pair.Value.Name) && (this.m_data.GlobalDefault == null))
            {
                object[] objArray8 = new object[] { pair.Value.Name };
                this.m_log.LogDebug("Configuration for service {0} was not found and will not be metered.", objArray8);
            }
        }
    }