NAME
Schedule::Load::Schedule - Functions for choosing a host among many
SYNOPSIS
use Schedule::Load::Schedule;
my $scheduler = Schedule::Load::Schedule->fetch();
print "Best host for a new job: ", $scheduler->best();
DESCRIPTION
This package will allow the most lightly loaded host to be choosen for new jobs across many machines across a entire network.
It is also a superclass of Schedule::Load::Hosts, so any functions that work for that module also work here.
METHODS
- best (...)
-
Returns the hostname of the best host in the network for a new job.
- fixed_load (load=>load_value, [pid=>$$], [host=>localhost])
-
Sets the current process and all children as always having at least the load value specified. This prevents undercounting CPU utilization when a large batch job is running which is just paused in the short term to do disk IO or sleep.
- hold_release (hold_key=>key)
-
Releases the temporary hold placed with the best function.
- hosts_of_class (class=>name)
-
Returns
Schedule::Load::Hosts::Host
objects for every host that matches the given class. - jobs (...)
-
Returns the maximum number of jobs suggested for the given scheduling parameters. Presumably this will be used to spawn parallel jobs for one given user, such as the
make -j
command. Jobs() takes the same arguments as best(), in addition to the max_jobs parameter. - release (host=>hostname)
-
Releases the machine from exclusive use of any user. The user doing the release does not have to be the same user that reserved the host.
- reserve (host=>hostname, [comment=>comment])
-
Reserves the machine for exclusive use of the current user. The host choosen must have the reservable flag set.
rschedule hosts
will show the host as reserved, along with the provided comment. - set_stored (host=>hostname, [set_const=>1], [key=>value])
-
Set a key/value parameter on the persistant storage on the remote server, such as if a class is allowed on that host. With const=>1, don't make it persist, but make it look like the deamon was started with that option; when the deamon restarts the information will be lost.
PARAMETERS
Parameters for the new and fetch calls are shown in Schedule::Load::Hosts
.
- allow_none
-
If allow_none is true, if there is less then a free CPU across the entire network, then no cpu will be choosen. This is useful for programs that can dynamically adjust their outstanding job count. (Presumably you would only set allow_none if you already have one job running, or you can get livelocked out of getting anything!)
- classes
-
An array reference of which classes the host must support to allow this job to be run on that host. Defaults to [], which allows any host.
- favor_host
-
The hostname to try and choose if all is equal, under the presumption that there are disk access time benefits to doing so. Defaults to the current host.
- hold_key
-
A hold key will reserve a job slot on the choosen CPU until a release_hold function is called. This prevents overscheduling a host due to the delay between choosing a host with a light load and starting the job on it which rases the CPU load of that choosen host.
- hold_time
-
Number of seconds to allow the hold to remain before being removed automatically.
- hold_load
-
Number of cpu loads the hold_key should reserve, defaults to one.
- match_cb
-
A string containing a subroutine which will be passed a host reference and should return true if this host has the necessary properties. This will be evaluated in a Safe container, and can do only minimal core functions. For example: match_cb=>"sub{return $_[0]->get_undef('memory')>512;}"
- max_jobs
-
Maximum number of jobs that jobs() can return. Negative fraction indicates that percentage of the clump, for example -0.5 will use 50% of free CPUs. Defaults to 20% of the free clump during the day, 100% at night.
- night_hours_cb
-
Reference to Function for determining if this is night time, defaults to M-F 6am-10pm. When it is nighttime hours, every class passed to the best option has a new class with _night appended.
- rating_cb
-
A string containing a subroutine which will be passed a host reference and should return a number that is compared against other hosts' ratings to determine the best host for a new job. A return of zero indicates this host may not be used. Ratings closer to zero are better. Defaults to a function that includes the load_limit and the cpu percentage free. Evaluated in a Safe container, and can do only minimal core functions.
SEE ALSO
Schedule::Load
, Schedule::Load::Hosts
, rschedule
DISTRIBUTION
The latest version is available from CPAN.
AUTHORS
Wilson Snyder <wsnyder@wsnyder.org>