// collectGeneralThrottleMetrics reads the once-per-sec metrics, and stores them onto this.migrationContext
collectGeneralThrottleMetrics reads the once-per-sec metrics, and stores them onto this.migrationContext
// collectGeneralThrottleMetrics reads the once - per - sec metrics and stores them onto this . migrationContext
func (this *Throttler) collectGeneralThrottleMetrics() error {
	setThrottle := func(throttle bool, reason string) error {
		this.migrationContext.SetThrottleGeneralCheckResult(base.NewThrottleCheckResult(throttle, reason))
		return nil
	}
	if this.migrationContext.PanicFlagFile != "" {
		if base.FileExists(this.migrationContext.PanicFlagFile) {
			this.panicAbort <- fmt.Errorf("Found panic-file %s. Aborting without cleanup", this.migrationContext.PanicFlagFile)
		}
	}
	criticalLoad := this.migrationContext.GetCriticalLoad()
	for variableName, threshold := range criticalLoad {
		value, err := this.applier.ShowStatusVariable(variableName)
		if err != nil {
			return setThrottle(true, fmt.Sprintf("%s %s", variableName, err))
		}
		if value >= threshold {
			this.panicAbort <- fmt.Errorf("critical-load met: %s=%d, >=%d", variableName, value, threshold)
		}
	}
	if atomic.LoadInt64(&this.migrationContext.ThrottleCommandedByUser) > 0 {
		return setThrottle(true, "commanded by user")
	}
	if this.migrationContext.ThrottleFlagFile != "" {
		if base.FileExists(this.migrationContext.ThrottleFlagFile) {
			return setThrottle(true, "flag-file")
		}
	}
	if this.migrationContext.ThrottleAdditionalFlagFile != "" {
		if base.FileExists(this.migrationContext.ThrottleAdditionalFlagFile) {
			return setThrottle(true, "flag-file")
		}
	}
	maxLoad := this.migrationContext.GetMaxLoad()
	for variableName, threshold := range maxLoad {
		value, err := this.applier.ShowStatusVariable(variableName)
		if err != nil {
			return setThrottle(true, fmt.Sprintf("%s %s", variableName, err))
		}
		if value >= threshold {
			return setThrottle(true, fmt.Sprintf("max-load %s=%d >= %d", variableName, value, threshold))
		}
	}
	if this.migrationContext.GetThrottleQuery() != "" {
		if res, _ := this.applier.ExecuteThrottleQuery(); res > 0 {
			return setThrottle(true, "throttle-query")
		}
	}
	return setThrottle(false, "")
}
func ( this * Throttler ) collectGeneralThrottleMetrics ( ) error { setThrottle := func ( throttle bool , reason string ) error { this . migrationContext . SetThrottleGeneralCheckResult ( base . NewThrottleCheckResult ( throttle , reason ) ) return nil } if this . migrationContext . PanicFlagFile != " " { if base . FileExists ( this . migrationContext . PanicFlagFile ) { this . panicAbort <- fmt . Errorf ( " " , this . migrationContext . PanicFlagFile ) } } criticalLoad := this . migrationContext . GetCriticalLoad ( ) for variableName , threshold := range criticalLoad { value , err := this . applier . ShowStatusVariable ( variableName ) if err != nil { return setThrottle ( true , fmt . Sprintf ( " " , variableName , err ) ) } if value >= threshold { this . panicAbort <- fmt . Errorf ( " " , variableName , value , threshold ) } } if atomic . LoadInt64 ( & this . migrationContext . ThrottleCommandedByUser ) > 0 { return setThrottle ( true , " " ) } if this . migrationContext . ThrottleFlagFile != " " { if base . FileExists ( this . migrationContext . ThrottleFlagFile ) { return setThrottle ( true , " " ) } } if this . migrationContext . ThrottleAdditionalFlagFile != " " { if base . FileExists ( this . migrationContext . ThrottleAdditionalFlagFile ) { return setThrottle ( true , " " ) } } maxLoad := this . migrationContext . GetMaxLoad ( ) for variableName , threshold := range maxLoad { value , err := this . applier . ShowStatusVariable ( variableName ) if err != nil { return setThrottle ( true , fmt . Sprintf ( " " , variableName , err ) ) } if value >= threshold { return setThrottle ( true , fmt . Sprintf ( " " , variableName , value , threshold ) ) } } if this . migrationContext . GetThrottleQuery ( ) != " " { if res , _ := this . applier . ExecuteThrottleQuery ( ) ; res > 0 { return setThrottle ( true , " " ) } } return setThrottle ( false , " " ) }
collectGeneralThrottleMetrics reads the once-per-sec metrics, and stores them onto this.migrationContext
collectGeneralThrottleMetrics reads the once - per - sec metrics and stores them onto this . migrationContext
// Regardless of throttle, we take opportunity to check for panic-abort // Back to throttle considerations // User-based throttle // Throttle file defined and exists! // 2nd Throttle file defined and exists!