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

Open Mash Cross Reference
mash/tcl/psvp/fx_forward/front_end.tcl

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

  1 # front_end.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 RTPApplication
 32 import GraphComm
 33 import FAgent
 34 
 35 Class FXForwardFrontEnd -superclass RTPApplication
 36 
 37 FXForwardFrontEnd instproc init {args} {
 38     $self next fx_forw_front_end
 39 
 40     $self init_resources
 41 
 42     puts "Args = $args"
 43     eval [$self options] parse_args $args;
 44 
 45     $self instvar service_al_;
 46 
 47     set service_al_ [new AnnounceListenManager/AS/Service/FrontEnd $self [$self get_option as_spec] [$self get_option as_bw] [$self get_option serv_inst]];
 48 
 49 
 50     $self instvar from_cntrl_obj_
 51     $self instvar to_cntrl_obj_
 52 
 53     set from_cntrl_spec [split [$self get_option from_cntrl] "/"]
 54     set from_addr [lindex $from_cntrl_spec 0];
 55     set from_port [lindex $from_cntrl_spec 1];
 56     set from_ttl [lindex $from_cntrl_spec 2];
 57 
 58     set from_cntrl_obj_ [new GraphComm/Front/From $self [$self get_option comm_id] $from_addr $from_port $from_ttl];
 59 
 60     set to_cntrl_spec [split [$self GenerateNewTunnelSpec]/16 "/"]
 61     set to_addr [lindex $to_cntrl_spec 0];
 62     set to_port [lindex $to_cntrl_spec 1];
 63     set to_ttl [lindex $to_cntrl_spec 2];
 64 
 65     $self instvar back_host_;
 66     set back_host_ ""
 67 
 68     set to_cntrl_obj_ [new GraphComm/Front/To $self [$self get_option comm_id] $to_addr $to_port $to_ttl];
 69 
 70     $from_cntrl_obj_ install $to_cntrl_obj_
 71     $to_cntrl_obj_ install $from_cntrl_obj_
 72 
 73     $self instvar back_end_starter_conn_
 74 
 75     set back_end_starter_conn_ [socket [$self get_option back_end_starter_addr] [$self get_option back_end_starter_port]];
 76 
 77     puts $back_end_starter_conn_ "start -num_nodes [$self get_option num_nodes] -subprogram [$self get_option subprogram] -from_cntrl ${to_addr}/${to_port} "
 78     flush $back_end_starter_conn_
 79     puts "here"
 80 
 81 }
 82 
 83 FXForwardFrontEnd instproc back_host {} {
 84     $self instvar back_host_;
 85 
 86     return $back_host_;
 87 }
 88 
 89 FXForwardFrontEnd instproc set_back_host {host} {
 90     $self instvar back_host_;
 91 
 92     set back_host_ $host;
 93 }
 94 
 95 FXForwardFrontEnd instproc init_resources {} {
 96     $self add_option num_nodes 4
 97     $self add_option subprogram ""
 98     $self add_option from_cntrl 224.3.2.1/22334/16
 99     $self add_option as_spec 224.4.5.24/50000/16
100     $self add_option as_bw 20000
101     $self add_option serv_inst temp_fx_app
102     $self add_option network ip
103     $self add_option mtu 1024
104     $self add_option defaultTTL 32
105     $self add_option sessionType rtpv2
106     $self add_option maxVideoSessionBW 30000000
107     $self add_option back_end_starter_addr u4
108     $self add_option back_end_starter_port 20004
109 
110     set hname [exec hostname];
111     set pid [pid];
112 
113     $self add_option comm_id ${hname}.${pid};
114 
115     [$self options] register_option -from_cntrl from_cntrl
116     [$self options] register_option -num_nodes num_nodes
117     [$self options] register_option -subprogram subprogram
118     [$self options] register_option -cntrl_spec from_cntrl
119     [$self options] register_option -as_spec as_spec
120     [$self options] register_option -as_bw as_bw
121     [$self options] register_option -serv_inst serv_inst
122     [$self options] register_option -megactrl as_spec
123     [$self options] register_option -back_end_addr back_end_starter_addr
124     [$self options] register_option -back_end_port back_end_starter_port
125 
126 }
127 
128 FXForwardFrontEnd instproc exit {} {
129     $self instvar back_end_starter_conn_
130 
131     close $back_end_starter_conn_
132     puts "Need to cleanup and exit!"
133 }
134 
135 FXForwardFrontEnd instproc GenerateNewTunnelSpec {} {
136     $self instvar used_ports_;
137 
138     set new_port [expr (int(rand() * 10000)*2) + 5000];
139     while {[info exists used_ports_($new_port)]} {
140         set new_port [expr (int(rand() * 10000)*2) + 5000];
141     }
142     set used_ports_($new_port) 1;
143     return "[exec hostname]/$new_port"
144 }
145 
146 
147 Class GraphComm/Front -superclass GraphComm
148 
149 GraphComm/Front instproc init {app id addr port ttl} {
150     $self next $id $addr $port
151 
152     $self instvar app_
153 
154     set app_ $app;
155 
156     $self instvar dest_;
157 
158     set dest_ ""
159 }
160 
161 GraphComm/Front instproc install {dest} {
162     $self instvar dest_;
163 
164     set dest_ $dest;
165 }
166 
167 GraphComm/Front instproc recv_trigger_command {cmd} {
168     $self instvar dest_;
169 
170     if {$dest_ == ""} {
171         return;
172     }
173 
174     $dest_ send_trigger_command $cmd
175 }
176 
177 GraphComm/Front instproc recv_misc {cmd} {
178     $self instvar dest_;
179 
180     if {$dest_ == ""} {
181         return;
182     }
183 
184     $dest_ send_misc $cmd
185 }
186 
187 GraphComm/Front instproc recv_debug {data} {
188     $self instvar dest_;
189 
190     if {$dest_ == ""} {
191         return;
192     }
193 
194     $dest_ send_debug $data
195 }
196 
197 GraphComm/Front instproc new_input {new_name} {
198     $self instvar dest_;
199 
200     if {$dest_ == ""} {
201         return;
202     }
203     $self next $new_name
204 
205     $dest_ create_input $new_name
206 }
207 
208 GraphComm/Front instproc new_output {new_name} {
209     $self instvar dest_;
210 
211     if {$dest_ == ""} {
212         return;
213     }
214     $self next $new_name
215 
216     $dest_ create_output $new_name
217 }
218 
219 GraphComm/Front instproc new_parameter {new_name} {
220     $self instvar dest_;
221 
222     if {$dest_ == ""} {
223         return;
224     }
225     $self next $new_name
226 
227     $dest_ create_parameter $new_name
228 }
229 
230 GraphComm/Front instproc new_input_attribute {input_name attr_name} {
231     $self instvar dest_;
232 
233     if {$dest_ == ""} {
234         return;
235     }
236     $self next $input_name $attr_name
237 
238     $dest_ create_input_attr $input_name $attr_name
239 }
240 
241 GraphComm/Front instproc new_output_attribute {output_name attr_name} {
242     $self instvar dest_;
243 
244     if {$dest_ == ""} {
245         return;
246     }
247     $self next $output_name $attr_name
248 
249     $dest_ create_output_attr $output_name $attr_name
250 }
251 
252 GraphComm/Front instproc new_parameter_attribute {parameter_name attr_name} {
253     $self instvar dest_;
254 
255     if {$dest_ == ""} {
256         return;
257     }
258     $self next $parameter_name $attr_name
259 
260     $dest_ create_parameter_attr $parameter_name $attr_name
261 }
262 
263 GraphComm/Front instproc update_input_attr_value {input_name attr_name value} {
264     $self instvar dest_;
265 
266     if {$dest_ == ""} {
267         return;
268     }
269     $self next $input_name $attr_name $value
270 
271     $dest_ set_input_attr $input_name $attr_name $value
272 }
273 
274 GraphComm/Front instproc update_output_attr_value {output_name attr_name value} {
275     $self instvar dest_;
276 
277     if {$dest_ == ""} {
278         return;
279     }
280     $self next $output_name $attr_name $value
281 
282     $dest_ set_output_attr $output_name $attr_name $value
283 }
284 
285 GraphComm/Front instproc update_parameter_attr_value {parameter_name attr_name value} {
286     $self instvar dest_;
287 
288     if {$dest_ == ""} {
289         return;
290     }
291     $self next $parameter_name $attr_name $value
292 
293     $dest_ set_parameter_attr $parameter_name $attr_name $value
294 }
295 
296 GraphComm/Front instproc set_input_attr {input_name attr_name value} {
297     $self create_input $input_name
298     $self create_input_attr $input_name $attr_name
299     $self next $input_name $attr_name $value
300 }
301 
302 GraphComm/Front instproc set_output_attr {output_name attr_name value} {
303     $self create_output $output_name
304     $self create_output_attr $output_name $attr_name
305     $self next $output_name $attr_name $value
306 }
307 
308 GraphComm/Front instproc set_parameter_attr {parameter_name attr_name value} {
309     $self create_parameter $parameter_name
310     $self create_parameter_attr $parameter_name $attr_name
311     $self next $parameter_name $attr_name $value
312 }
313 
314 Class GraphComm/Front/From -superclass GraphComm/Front
315 
316 GraphComm/Front/From instproc update_input_attr_value {input_name attr_name value} {
317     $self instvar dest_;
318 
319     if {$dest_ == ""} {
320         return;
321     }
322 
323     $self instvar app_
324 
325     if {[$app_ back_host] == ""} {
326         return;
327     }
328 
329     if {$attr_name == "spec"} {
330         set split_spec [split $value "/"];
331         set addr [lindex $split_spec 0];
332         set port [lindex $split_spec 1];
333         set srcid [lindex $split_spec 2];
334 
335         $self instvar tunnels_
336         if {[info exists tunnels_($addr,$port)]} {
337             set fagent $tunnels_($addr,$port);
338             set tunnel_spec $tunnel_specs_($addr,$port);
339         } else {
340             set tunnel_spec [$app_ GenerateNewTunnelSpec];
341             set tunnel_port [lindex [split $tunnel_spec "/"] 1]
342             set fagent [new FAgent $app_ "${addr}/${port}" [$app_ back_host]/$tunnel_port];
343             set tunnels_($addr,$port) $fagent;
344             set tunnel_specs_($addr,$port) $tunnel_spec;
345         }
346         if {$srcid != "*"} {
347             $fagent install_src_callback $srcid "$self complete_input_setup $srcid $fagent $input_name $tunnel_spec"
348             return;
349         } else {
350             set value "${tunnel_spec}/*";
351         }
352     }
353     $self next $input_name $attr_name $value;
354 }
355 
356 GraphComm/Front/From instproc complete_input_setup {srcid fagent input_name tunnel_spec} {
357     set new_id [$fagent translate_srcid $srcid];
358 
359     $self instvar dest_;
360 
361     $dest_ set_input_attr $input_name spec "${tunnel_spec}/${new_id}"
362 }
363 
364 GraphComm/Front/From instproc update_output_attr_value {output_name attr_name value} {
365     $self instvar dest_;
366 
367     if {$dest_ == ""} {
368         return;
369     }
370 
371     $self instvar app_
372 
373     if {$attr_name == "spec"} {
374         $self instvar out_tunnels_
375         $self instvar out_tunnel_specs_
376 
377         if {[info exists out_tunnels_($value)]} {
378             set fagent $out_tunnels_($value);
379             set tunnel_spec $out_tunnel_specs_($value);
380         } else {
381             set tunnel_spec [$app_ GenerateNewTunnelSpec];
382             set fagent [new FAgent $app_ $tunnel_spec $value];
383             set out_tunnels_($value) $fagent;
384             set out_tunnel_specs_($value) $tunnel_spec;
385         }
386         set value $tunnel_spec
387     }
388     $self next $output_name $attr_name $value;
389 }
390 
391 
392 Class GraphComm/Front/To -superclass GraphComm/Front
393 
394 GraphComm/Front/To instproc recv_misc {cmd} {
395     if {[lindex $cmd 0] == "set_back_host"} {
396         $self instvar app_;
397 
398         $app_ set_back_host [lindex $cmd 1];
399     } else {
400         $self next $cmd;
401     }
402 }
403 
404 import AnnounceListenManager/AS/Service
405 
406 Class AnnounceListenManager/AS/Service/FrontEnd -superclass AnnounceListenManager/AS/Service
407 
408 AnnounceListenManager/AS/Service/FrontEnd instproc unregister { atype aspec addr srv_name srv_inst msg } {
409         $self instvar agentbytype_ srv_inst_ agenttab_
410 
411         # If we are alive and a client with a different SID died --
412         # no need to check.
413         if { $atype != "client" || $srv_inst != $srv_inst_ } {
414                 return
415         }
416         foreach aspec $agentbytype_(client) {
417                 set sid [lindex $agenttab_($aspec) 4]
418                 if { $sid == $srv_inst_ } {
419                         # Still have a client
420                         return
421                 }
422         }
423         # No clients with our SID, exit
424 
425         puts stderr "no more clients -- exiting"
426 
427         $self instvar agent_
428 
429         $agent_ exit;
430 }
431 
432 AnnounceListenManager/AS/Service/FrontEnd instproc service_name {} {
433     return "FXForwardFrontEnd"
434 }
435 
436 AnnounceListenManager/AS/Service/FrontEnd instproc send_announcement {} {
437     puts "FrontEnd sending announcement"
438     $self next
439 }
440 
441 AnnounceListenManager/AS/Service/FrontEnd instproc recv_mesg {args} {
442 
443     puts "FrontEnd recv_mesg: $args"
444     eval $self next $args
445 }
446 
447 set app [new FXForwardFrontEnd $argv];
448 
449 puts "Started"
450 
451 if {![info exists tk_version]} {
452     vwait forever;
453 }
454 
455 

~ [ 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.