~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/psvp/fx_service/temp_fx.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # temp_fx.tcl --
  2 #
  3 #       FIXME: This file needs a description here.
  4 #
  5 # Copyright (c) 1999-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 import Application
 32 
 33 Class TempFXApp -superclass Application
 34 
 35 TempFXApp instproc init {args} {
 36     $self next temp_fx_app
 37 
 38     $self init_resources
 39 
 40     eval [$self options] parse_args $args;
 41 
 42     if {[$self get_option subprogram] == ""} {
 43         puts stderr "Must specify subprogram";
 44         exit;
 45     }
 46 
 47     $self instvar my_addr_ node_spec_ ts_pid_ ti_pid_ proc_pids_ my_port_
 48 
 49     set my_addr_ [string trim [exec hostname]];
 50     set habbr [lindex [split $my_addr_ .] 0];
 51     set my_port_ [$self get_option glurun_client_port];
 52 
 53     set server_fd_ [socket -server "$self handle_client_registration" $my_port_];
 54     set my_port_ [lindex [fconfigure $server_fd_ -sockname] 2];
 55 
 56     set node_spec_ all-${habbr}-clump0-clump1-clump2-clump3
 57     global env
 58     set env(GLUNIX_NODES) $node_spec_
 59 
 60     set ts_pid_ [$self StartProc [$self get_option ts_prog] -cntrl_spec [$self get_option cntrl_spec]]
 61     set ti_pid_ [$self StartProc [$self get_option ti_prog] -cntrl_spec [$self get_option cntrl_spec]]
 62 
 63     for {set p 0} {$p < [$self get_option num_nodes]} {incr p} {
 64         set proc_pids_($p) [$self StartProc [$self get_option proc_prog] -subprogram [$self get_option subprogram] -reg_comm_spec [$self get_option cntrl_spec]];
 65     }
 66 
 67     # Create AS Service communication object.
 68 
 69     $self instvar service_al_;
 70 
 71     set service_al_ [new AnnounceListenManager/AS/Service/TempFXService $self [$self get_option as_spec] [$self get_option as_bw] [$self get_option serv_inst]];
 72 }
 73 
 74 TempFXApp instproc handle_client_registration {sfd addr port} {
 75     $self instvar client_sock_fd_;
 76 
 77     set client_sock_fd_ $sfd;
 78 }
 79 
 80 TempFXApp instproc init_resources {} {
 81 
 82     $self add_option num_nodes 4
 83     $self add_option subprogram ""
 84     $self add_option cntrl_spec 224.3.2.1/22334/16
 85     $self add_option as_spec 224.4.5.24/50000/16
 86     $self add_option smash_bin /home/cs/kpatel/mash-code/production/smash
 87     $self add_option ts_prog /home/cs/kpatel/mash-code/production/tcl/psvp/test2/fx_tselect.tcl
 88     $self add_option ti_prog /home/cs/kpatel/mash-code/production/tcl/psvp/test2/fx_tinter.tcl
 89     $self add_option proc_prog /home/cs/kpatel/mash-code/production/tcl/psvp/test2/fx_proc.tcl
 90     $self add_option glurun_client_port 0
 91     $self add_option glurun_client /home/cs/kpatel/mash-code/production/tcl/psvp/demos/glurun-client.tcl
 92     $self add_option as_bw 20000
 93     $self add_option serv_inst temp_fx_app
 94 
 95     [$self options] register_option -num_nodes num_nodes
 96     [$self options] register_option -subprogram subprogram
 97     [$self options] register_option -cntrl_spec cntrl_spec
 98     [$self options] register_option -as_spec as_spec
 99     [$self options] register_option -smash_bin smash_bin
100     [$self options] register_option -ts_prog ts_prog
101     [$self options] register_option -ti_prog ti_prog
102     [$self options] register_option -proc_prog proc_prog
103     [$self options] register_option -glurun_client_port glurun_client_port
104     [$self options] register_option -as_bw as_bw
105     [$self options] register_option -serv_inst serv_inst
106     [$self options] register_option -megactrl as_spec
107 }
108 
109 TempFXApp instproc exit {} {
110     $self instvar ts_pid_ ti_pid_ proc_pids_ pid_map_;
111 
112     catch "puts $pid_map_($ts_pid_) {exit}"
113     catch "flush $pid_map_($ts_pid_)";
114     catch "close $pid_map_($ts_pid_)";
115 
116     catch "puts $pid_map_($ti_pid_) {exit}"
117     catch "flush $pid_map_($ti_pid_)";
118     catch "close $pid_map_($ti_pid_)";
119 
120     foreach i [array names proc_pids_] {
121         catch "puts $pid_map_($proc_pids_($i)) {exit}"
122         catch "flush $pid_map_($proc_pids_($i))";
123         catch "close $pid_map_($proc_pids_($i))";
124     }
125 
126     exit;
127 }
128 
129 TempFXApp instproc StartProc {cmd args} {
130     $self instvar client_sock_fd_ my_addr_ my_port_
131 
132     set client_sock_fd_ "";
133 
134     set pid [eval exec glurun [$self get_option smash_bin] [$self get_option glurun_client] $my_addr_ $my_port_ $cmd $args &];
135 
136     while {$client_sock_fd_ == ""} {
137         update;
138     }
139 
140     set client_host [gets $client_sock_fd_]
141 
142     $self instvar node_spec_
143 
144     set node_spec_ "$node_spec_-${client_host}"
145     global env
146     set env(GLUNIX_NODES) $node_spec_
147 
148     $self instvar pid_map_
149 
150     set pid_map_($pid) $client_sock_fd_;
151 
152     return $pid;
153 }
154 
155 #############################
156 # Under here is our subclass of AnnounceListenManager/AS/Service
157 # which registers us with the host manager and all that. The important
158 # routine is unregister which tells us we can kill ourself.
159 #
160 
161 import AnnounceListenManager/AS/Service
162 
163 Class AnnounceListenManager/AS/Service/TempFXService -superclass AnnounceListenManager/AS/Service
164 
165 AnnounceListenManager/AS/Service/TempFXService instproc unregister { atype aspec addr \
166                 srv_name srv_inst msg } {
167         $self instvar agentbytype_ srv_inst_ agenttab_
168 
169         # If we are alive and a client with a different SID died --
170         # no need to check.
171         if { $atype != "client" || $srv_inst != $srv_inst_ } {
172                 return
173         }
174         foreach aspec $agentbytype_(client) {
175                 set sid [lindex $agenttab_($aspec) 4]
176                 if { $sid == $srv_inst_ } {
177                         # Still have a client
178                         return
179                 }
180         }
181         # No clients with our SID, exit
182 
183         puts stderr "no more clients -- exiting"
184 
185         $self instvar agent_
186 
187         $agent_ exit;
188 }
189 
190 AnnounceListenManager/AS/Service/TempFXService instproc service_name {} {
191     return "FXTemp"
192 }
193 
194 AnnounceListenManager/AS/Service/TempFXService instproc send_announcement {} {
195     puts "TempFXService sending announcement"
196     $self next
197 }
198 
199 AnnounceListenManager/AS/Service/TempFXService instproc recv_mesg {args} {
200 
201     puts "TempFXService recv_mesg: $args"
202     eval $self next $args
203 }
204 
205 
206 #############################
207 
208 set app [new TempFXApp $argv];
209 
210 puts "Started"
211 
212 if {![info exists tk_version]} {
213     vwait forever;
214 }
215 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.