Example #1
0
        public bool CheckStartProcessLimits(InstanceGroupConfig group, bool isForce)
        {
            DateTimeOffset now = DateTimeOffset.Now;

            DxStoreManager.InstanceStartStats instanceStartStats;
            if (!this.instanceStartMap.TryGetValue(group.Identity, out instanceStartStats))
            {
                instanceStartStats = new DxStoreManager.InstanceStartStats();
                this.ResetStartProcessLimit(instanceStartStats, now);
                this.instanceStartMap[group.Identity] = instanceStartStats;
            }
            else
            {
                TimeSpan t  = now - instanceStartStats.FirstStartRequestedTime;
                TimeSpan t2 = now - instanceStartStats.LastStartRequestedTime;
                if (t2 < group.Settings.InstanceStartSilenceDuration)
                {
                    if (instanceStartStats.TotalStartRequestsFromFirstReported > group.Settings.InstanceStartHoldupDurationMaxAllowedStarts)
                    {
                        if (t < group.Settings.InstanceStartHoldUpDuration)
                        {
                            this.EventLogger.LogPeriodic(group.Identity, TimeSpan.FromMinutes(10.0), DxEventSeverity.Warning, 0, "Instance start request exceeded maximum allowed ({3}). (FirstStartTime: {0}, LastStartTime: {1}, TotalRequests: {2}", new object[]
                            {
                                instanceStartStats.FirstStartRequestedTime,
                                instanceStartStats.LastStartRequestedTime,
                                instanceStartStats.TotalStartRequestsFromFirstReported,
                                isForce ? "but allowing due to force flag" : "start rejected"
                            });
                            if (!isForce)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            this.ResetStartProcessLimit(instanceStartStats, now);
                        }
                    }
                    instanceStartStats.LastStartRequestedTime = now;
                    instanceStartStats.TotalStartRequestsFromFirstReported++;
                }
                else
                {
                    this.ResetStartProcessLimit(instanceStartStats, now);
                }
            }
            return(true);
        }
Example #2
0
 public void ResetStartProcessLimit(DxStoreManager.InstanceStartStats stats, DateTimeOffset now)
 {
     stats.LastStartRequestedTime              = now;
     stats.FirstStartRequestedTime             = now;
     stats.TotalStartRequestsFromFirstReported = 1;
 }