![]() |
OpenMash Documentations | Class Index | Method Index | Class Hierarchy |
TCL CLASS
HMAgent
Host Manager Agent, part of the AS1 framework
cbchannel_, minport_, portmap_, app_, hmhosts_, creators_, tid_, al_, scriptfiles_, maxports_, scripturls, launched_, logfd_, uniqport_, uniqid_
Channel ID for coordination bus.
Minimum port number to assign to services.
This array maintains used port number so that we can generate an unused/unique port number.
The HM Application.
A list of other hosts eligible to run hm.
An array of ServiceCreator object for various services. FIXME: we should not hardcode available services in hm. It should be discovered dynamically.
An array of timers indexed by service instance.
An array of announce/listen manager.
An array that caches service location to filenames of previously retrieve scripts.
Maximum port number to assign to services.
Predefined URL prefix for downloading scripts of type "urn:"
An array of services launched, indexed by service instance.
File descriptor for a log file. The log file is created by the application.
Last unique port number assigned to a service.
A unique id used to create temporary filename for downloaded servlets. Initialized to 0 and is incremented by 1 everytime a temp file is created.
init_scripturls, parse_conffile, target_check, doexit, log, pid, destroy, uniqport, pick_mcastaddr, launch, get_script, unregister, pending_timer, pending_launches, cancel_timer, sched_launch, uniform_timer, suppress_timer, open_cb, close_cb, read_hmhosts, init_load_check, load_check, get_load, spawn, dospawn, shed_load, die, really_die, recv_death, init
HMAgent instproc init_scripturls { }
Initialize scripturls to some predefined URLs.
HMAgent instproc parse_conffile { f }
Read the configuration file. The configuration file specifies how this hm is connected to the other hms. (Host manager can be chained)
f
filename of the configuration file.
HMAgent instproc target_check { }
Checks if the total number of hm meets the desired number.
HMAgent instproc doexit { }
Tell everyone we are quiting, and then quit.
HMAgent instproc log { msg }
Print a log message to logfd_. The input message $msg is prefixed with process id and current time.
msg
message to be printed.
HMAgent instproc pid { }
Returns the process id of this process.
HMAgent instproc destroy { }
Removes the announce listen manager stored in array al_.
HMAgent instproc uniqport { }
Return a unique port number that hasn't been returned before. We keep the list of previously available port number in portmap_. FIXME: portmap_ is not updated! *BUG*
HMAgent public pick_mcastaddr { }
Return a random multicast address.
HMAgent private launch { srv_name srv_loc srv_inst msg }
Launch a service. A service is launch only if (1) the number of current pending launches is less than maximum allowable pending launches (configurable through maxPending), (2) current CPU load is less than maximum allowable CPU load (configurable through highLoad). This method is an "after" callback scheduled by schedule_launch {} method.
srv_name
Name of the service to launch.
srv_loc
Location of the service's executable.
msg
?
srv_inst
?
HMAgent instproc get_script { srv_name srv_loc }
Return a filename on local disk that corresponds to the executable for service specified by $name and $srv_loc. Retrieve the script from an HTTP server and stored it as temporary file if have to. Previously retrieve scripts are cached in array scriptfiles_.
srv_name
Name of the service.
srv_loc
Location of the service's executable. Format is
static:
HMAgent instproc unregister { aspec msg }
Remove a handler.
msg
Ununsed junk.
aspec
"
HMAgent instproc pending_timer { tid }
Check if there is a timer with id == $tid pending.
tid
ID of the timer to check.
HMAgent instproc pending_launches { }
Return the number of launches pending.
HMAgent instproc cancel_timer { tid }
Remove the "after" callback and information regarding a scheduled launched identified by $tid.
tid
ID of the timer to cancel.
HMAgent public sched_launch { srv_name srv_loc srv_inst msg }
Schedule a launch by creating an "after" callback. The timeout period for launching is randomly, uniformly chosen from [0, 2000*N], where N is the estimate number of host manager currently running.
msg
Data for the service.
srv_name
Name of the service to launch.
srv_inst
A unique ID to the service.
srv_loc
Where to find the executable of the service.
HMAgent proc uniform_timer { T }
Uniformly pick a random integer between 0 and T and return it.
T
upper bound for the random number.
HMAgent public suppress_timer { tid }
Cancel our own launch, because someone else has already launch the same service.
tid
ID to the service to cancel.
HMAgent instproc open_cb { handler }
HMAgent instproc close_cb { cb }
Open and close a coordination bus.
handler
Unused junk.
cb
Coordination bus to close.
HMAgent instproc read_hmhosts { }
Read a file called "hmhosts", which contains a list of hosts hm can run on. The list of hosts are stored into a list called hmhosts_.
HMAgent instproc init_load_check { }
Create a time to call method load_check{ } periodically.
HMAgent instproc load_check { }
Checks the current load on this machine. If the load is too high, Sheds some load by randomly killing of servents (see shed_load{}). If the load is too low, kill self. (Huh?).
HMAgent proc get_load { }
Call uptime and return the current load on this machine.
HMAgent instproc spawn { }
Spawn a copy of hm on another random host.
HMAgent private dospawn { shost }
Called by spawn{}, spawn a copy of hm on $shost.
HMAgent instproc shed_load { }
Randomly kills of servents.
HMAgent instproc die { }
Schedule a callback to kill self.
HMAgent instproc really_die { }
Really kill self.
HMAgent instproc recv_death { }
If someone has already kill itself, it is possible that we do not have to kill ourself. Recheck.
HMAgent instproc init { app logfd }
randomize, sched, msched, do_timeout, is_sched, cancel
Generated on Mon Apr 12 04:04:28 PDT 2004