Exemple #1
0
        internal MQChannelDefinition SelectChannelEntry(MQChannelDefinition cd, MQThreadChannelEntry threadChlEntry)
        {
            uint method = 0x29;

            this.TrEntry(method, new object[] { cd, threadChlEntry });
            MQChannelEntry thisWeightedEntry = null;

            try
            {
                if (cd != null)
                {
                    thisWeightedEntry = this.SelectNamedEntry(cd);
                }
                else if (threadChlEntry.ThisWeightedEntry != null)
                {
                    threadChlEntry.ThisWeightedEntry = threadChlEntry.ThisWeightedEntry.Next;
                    if (threadChlEntry.ThisWeightedEntry != threadChlEntry.FirstWeightedEntry)
                    {
                        thisWeightedEntry = threadChlEntry.ThisWeightedEntry;
                    }
                }
                else
                {
                    if (threadChlEntry.ThisAlphaEntry != null)
                    {
                        threadChlEntry.ThisAlphaEntry = threadChlEntry.ThisAlphaEntry.Next;
                    }
                    else
                    {
                        threadChlEntry.ThisAlphaEntry = this.thisAlphaEntry;
                    }
                    if (threadChlEntry.ThisAlphaEntry != null)
                    {
                        thisWeightedEntry = threadChlEntry.ThisAlphaEntry;
                    }
                    else if (this.thisWeightedEntry != null)
                    {
                        if (this.thisWeightedEntry.Channel.ConnectionAffinity == 1)
                        {
                            thisWeightedEntry = this.thisWeightedEntry;
                        }
                        else
                        {
                            thisWeightedEntry = this.SelectRandomEntry(threadChlEntry);
                        }
                        threadChlEntry.FirstWeightedEntry = thisWeightedEntry;
                        threadChlEntry.ThisWeightedEntry  = thisWeightedEntry;
                    }
                }
            }
            finally
            {
                base.TrExit(method);
            }
            return((thisWeightedEntry == null) ? null : thisWeightedEntry.Channel);
        }
Exemple #2
0
        private MQChannelEntry SelectRandomEntry(MQThreadChannelEntry threadChlEntry)
        {
            uint method = 0x2b;

            this.TrEntry(method, new object[] { threadChlEntry });
            MQChannelEntry weightedEntry = null;
            Random         random        = null;
            int            num2          = 0;
            int            num3          = 0;

            try
            {
                if (threadChlEntry.Seed == 0)
                {
                    DateTime now = DateTime.Now;
                    threadChlEntry.Seed = (int)now.Ticks;
                }
                random        = new Random(threadChlEntry.Seed);
                num2          = random.Next() % this.totalWeight;
                weightedEntry = this.weightedEntry;
                weightedEntry = this.weightedEntry;
                while (weightedEntry != null)
                {
                    num3 += weightedEntry.Channel.ClientChannelWeight;
                    if (num3 > num2)
                    {
                        return(weightedEntry);
                    }
                    weightedEntry = weightedEntry.Next;
                }
            }
            finally
            {
                base.TrExit(method);
            }
            return(weightedEntry);
        }