1 # application-hm.tcl --
2 #
3 # Application object for Host Manager (hm)
4 #
5 # Copyright (c) 1997-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #
31 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/hm/application-hm.tcl,v 1.52 2002/02/03 04:27:05 lim Exp $
32
33
34 import Application HMAgent
35
36 #-
37 # Class:
38 # HMApplication
39 # Description:
40 # Main application object for host manager (hm). It is responsible
41 # for parsing command lines arguments, initializing user-defined
42 # resources and commands, and creating an HMAgent. The intelligence
43 # of the application lies in HMAgent.
44 # See Also:
45 # HMAgent
46 #-
47 Class HMApplication -superclass Application
48
49 #-
50 # Method:
51 # HMApplication init
52 # Description:
53 # Initialize default values for command line arguments, parse
54 # command line arguments, and load user hooks. Finally, create
55 # an HM agent and run user hooks.
56 #-
57 HMApplication public init argv {
58 $self next hm
59 set o [$self options]
60 $self init_args $o
61 $self init_resources $o
62 $o parse_args $argv
63
64 # Source the user's hook file if it exists. The function
65 # user_hook, which may be defined in this file, will be
66 # called at the end of init.
67 if {[$o get_option userhookFile] != ""} {
68 if {[file isfile [$o get_option userhookFile]] && \
69 [file readable [$o get_option userhookFile]]} {
70 source [$o get_option userhookFile]
71 } else {
72 puts stderr "Unable to source \"[$o get_option userhookFile]\". Not a file or not readable."
73 }
74 }
75
76 $self init_local
77
78 # FIXME closing stdout causes any puts statements to crash
79 # hm if it's started in fork mode.
80 if { [$self get_option doFork] != "" } {
81 close stdout
82 close stdin
83 close stderr
84 fork
85 set logfd [open [$self get_option logFile] a+]
86 } else {
87 set logfd stdout
88 }
89 $self add_option execArgs $argv
90 new HMAgent $self $logfd
91
92 $self user_hook
93 }
94
95
96 HMApplication private init_args o {
97 $o register_option -u userhookFile
98
99 $o register_boolean_option -lb loadBalance
100 $o register_boolean_option -fork doFork
101 $o register_boolean_option -glunix glunix
102 $o register_boolean_option -noload noLoad
103 $o register_boolean_option -nolog noLog
104
105 $o register_option -target targetNum
106 $o register_option -int checkInterval
107 $o register_option -path execPath
108 $o register_option -log logFile
109 $o register_option -rcmd execCmd
110 $o register_option -conffile megaConfFile
111 $o register_option -megactrl megaCtrl
112 $o register_option -scriptdir scriptDir
113 }
114
115
116 HMApplication private init_resources o {
117
118 $o add_default megaCtrl 224.4.5.24/50000/31
119 $o add_default megaCtrlBW 20000
120 # 60 seconds max startup wait for first message
121 $o add_default megaStartupWait 60
122 $o add_default scriptDir /var/tmp
123
124 $o add_default unicastOutput 1
125
126 $o add_default lambda 5.0
127 $o add_default maxWait 15000
128 $o add_default maxPending 5
129
130 $o add_default minPort 10000
131 $o add_default maxPorts 10000
132
133 $o add_default checkFactor 2
134
135 $o add_default checkInterval 20000
136 $o add_default deathInterval 10000
137 $o add_default minDeathWait 60000
138
139 $o add_default highLoad 1.00
140 $o add_default lowLoad 0.05
141 $o add_default noLoad yes
142 $o add_default execPath [pwd]
143 $o add_default execCmd "ssh -n"
144 $o add_default minHmNum 1
145 $o add_default loadSamples 2
146 $o add_default logFile /tmp/hmlog
147 $o add_default megaConfFile mega.conf
148 $o add_default link no
149
150 $o add_default allow_distrib no
151 $o add_default glob_chan 224.4.5.28/55000/15
152 }
153
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.