Exemplo n.º 1
0
 public static FairCallQueue.MetricsProxy GetInstance(string @namespace)
 {
     lock (typeof(MetricsProxy))
     {
         FairCallQueue.MetricsProxy mp = Instances[@namespace];
         if (mp == null)
         {
             // We must create one
             mp = new FairCallQueue.MetricsProxy(@namespace);
             Instances[@namespace] = mp;
         }
         return(mp);
     }
 }
Exemplo n.º 2
0
        /// <summary>Create a FairCallQueue.</summary>
        /// <param name="capacity">the maximum size of each sub-queue</param>
        /// <param name="ns">the prefix to use for configuration</param>
        /// <param name="conf">
        /// the configuration to read from
        /// Notes: the FairCallQueue has no fixed capacity. Rather, it has a minimum
        /// capacity of `capacity` and a maximum capacity of `capacity * number_queues`
        /// </param>
        public FairCallQueue(int capacity, string ns, Configuration conf)
        {
            /* Scheduler picks which queue to place in */
            /* Multiplexer picks which queue to draw from */
            /* Statistic tracking */
            int numQueues = ParseNumQueues(ns, conf);

            Log.Info("FairCallQueue is in use with " + numQueues + " queues.");
            this.queues          = new AList <BlockingQueue <E> >(numQueues);
            this.overflowedCalls = new AList <AtomicLong>(numQueues);
            for (int i = 0; i < numQueues; i++)
            {
                this.queues.AddItem(new LinkedBlockingQueue <E>(capacity));
                this.overflowedCalls.AddItem(new AtomicLong(0));
            }
            this.scheduler   = new DecayRpcScheduler(numQueues, ns, conf);
            this.multiplexer = new WeightedRoundRobinMultiplexer(numQueues, ns, conf);
            // Make this the active source of metrics
            FairCallQueue.MetricsProxy mp = FairCallQueue.MetricsProxy.GetInstance(ns);
            mp.SetDelegate(this);
        }