public static DecayRpcScheduler.MetricsProxy GetInstance(string @namespace) { lock (typeof(MetricsProxy)) { DecayRpcScheduler.MetricsProxy mp = Instances[@namespace]; if (mp == null) { // We must create one mp = new DecayRpcScheduler.MetricsProxy(@namespace); Instances[@namespace] = mp; } return(mp); } }
/// <summary>Create a decay scheduler.</summary> /// <param name="numQueues">number of queues to schedule for</param> /// <param name="ns"> /// config prefix, so that we can configure multiple schedulers /// in a single instance. /// </param> /// <param name="conf">configuration to use.</param> public DecayRpcScheduler(int numQueues, string ns, Configuration conf) { if (numQueues < 1) { throw new ArgumentException("number of queues must be > 0"); } this.numQueues = numQueues; this.decayFactor = ParseDecayFactor(ns, conf); this.decayPeriodMillis = ParseDecayPeriodMillis(ns, conf); this.identityProvider = this.ParseIdentityProvider(ns, conf); this.thresholds = ParseThresholds(ns, conf, numQueues); // Setup delay timer Timer timer = new Timer(); DecayRpcScheduler.DecayTask task = new DecayRpcScheduler.DecayTask(this, timer); timer.ScheduleAtFixedRate(task, 0, this.decayPeriodMillis); DecayRpcScheduler.MetricsProxy prox = DecayRpcScheduler.MetricsProxy.GetInstance( ns); prox.SetDelegate(this); }