ganeti

Safe HaskellSafe-Infered

Ganeti.JQScheduler.ReasonRateLimiting

Description

Ad-hoc rate limiting for the JQScheduler based on reason trails.

Synopsis

Documentation

type AdHocReasonKey = StringSource

parseReasonRateLimit :: Monad m => String -> m (String, Int)Source

Parses an ad-hoc rate limit from a reason trail, as defined under Ad-Hoc Rate Limiting in `doc/design-optables.rst`.

The parse succeeds only on reasons of form `rate-limit:n:REASONSTRING` where n is a positive integer and REASONSTRING is an arbitrary string (may include spaces).

countMapFromJob :: QueuedJob -> CountMap AdHocReasonKeySource

Computes the bucket slots required by a job.

slotMapFromJobs :: [QueuedJob] -> SlotMap AdHocReasonKeySource

Map of how many slots are in use for a given bucket, for a list of jobs. The slot limits are taken from the ad-hoc reason rate limiting strings.

reasonRateLimit :: Queue -> [JobWithStat] -> [JobWithStat]Source

Implements ad-hoc rate limiting using the reason trail as specified in `doc/design-optables.rst`.

Reasons of form `rate-limit:n:REASONSTRING` define buckets that limit how many jobs with that reason can be running at the same time to a positive integer n of available slots.

The used buckets map is currently not cached across selectJobsToRun invocations because the number of running jobs is typically small (< 100).