home OpenMash Documentations
Class Index Method Index Class Hierarchy

TCL CLASS

HMAgent

Host Manager Agent, part of the AS1 framework

SUPERCLASSES

Timer

SUBCLASSES

HMSimAgent

MEMBERS

cbchannel_, minport_, portmap_, app_, hmhosts_, creators_, tid_, al_, scriptfiles_, maxports_, scripturls, launched_, logfd_, uniqport_, uniqid_

cbchannel_

Channel ID for coordination bus.

minport_

Minimum port number to assign to services.

portmap_

This array maintains used port number so that we can generate an unused/unique port number.

app_

The HM Application.

hmhosts_

A list of other hosts eligible to run hm.

creators_

An array of ServiceCreator object for various services. FIXME: we should not hardcode available services in hm. It should be discovered dynamically.

tid_

An array of timers indexed by service instance.

al_

An array of announce/listen manager.

scriptfiles_

An array that caches service location to filenames of previously retrieve scripts.

maxports_

Maximum port number to assign to services.

scripturls

Predefined URL prefix for downloading scripts of type "urn:"

launched_

An array of services launched, indexed by service instance.

logfd_

File descriptor for a log file. The log file is created by the application.

uniqport_

Last unique port number assigned to a service.

uniqid_

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.

METHODS

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

init_scripturls

HMAgent instproc init_scripturls { }

Initialize scripturls to some predefined URLs.

parse_conffile

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.

target_check

HMAgent instproc target_check { }

Checks if the total number of hm meets the desired number.

doexit

HMAgent instproc doexit { }

Tell everyone we are quiting, and then quit.

log

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.

pid

HMAgent instproc pid { }

Returns the process id of this process.

destroy

HMAgent instproc destroy { }

Removes the announce listen manager stored in array al_.

uniqport

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*

pick_mcastaddr

HMAgent public pick_mcastaddr { }

Return a random multicast address.

launch

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

?

get_script

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: http: urn:.

unregister

HMAgent instproc unregister { aspec msg }

Remove a handler.

msg

Ununsed junk.

aspec

"@", this uniquely identifies a handler.

pending_timer

HMAgent instproc pending_timer { tid }

Check if there is a timer with id == $tid pending.

tid

ID of the timer to check.

pending_launches

HMAgent instproc pending_launches { }

Return the number of launches pending.

cancel_timer

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.

sched_launch

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.

uniform_timer

HMAgent proc uniform_timer { T }

Uniformly pick a random integer between 0 and T and return it.

T

upper bound for the random number.

suppress_timer

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.

open_cb

close_cb

HMAgent instproc open_cb { handler }

HMAgent instproc close_cb { cb }

Open and close a coordination bus.

handler

Unused junk.

cb

Coordination bus to close.

read_hmhosts

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_.

init_load_check

HMAgent instproc init_load_check { }

Create a time to call method load_check{ } periodically.

load_check

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?).

get_load

HMAgent proc get_load { }

Call uptime and return the current load on this machine.

spawn

HMAgent instproc spawn { }

Spawn a copy of hm on another random host.

dospawn

HMAgent private dospawn { shost }

Called by spawn{}, spawn a copy of hm on $shost.

shed_load

HMAgent instproc shed_load { }

Randomly kills of servents.

die

HMAgent instproc die { }

Schedule a callback to kill self.

really_die

HMAgent instproc really_die { }

Really kill self.

recv_death

HMAgent instproc recv_death { }

If someone has already kill itself, it is possible that we do not have to kill ourself. Recheck.

init

HMAgent instproc init { app logfd }

INHERITED METHODS

randomize, sched, msched, do_timeout, is_sched, cancel

FILENAME

tcl/hm/agent-hm.tcl


Generated on Mon Apr 12 04:04:28 PDT 2004