1 # al-server-ssac.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1998-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/ssac/al-server-ssac.tcl,v 1.12 2002/02/03 04:30:10 lim Exp $
32
33
34 import AnnounceListenManager/AS/Service SSACServer
35
36 # Mars is the MASH Archive Service. The Mars archive server runs on the
37 # AS1 active service framework, and uses the SSAC protocol for
38 # communication with clients (currently, the client application is
39 # called rover). This class handles the announce/listen operation of
40 # SSAC. The SSACServer class handles the usage of the protocol.
41 # <p> Status: alpha <p> Author: Angela Schuett
42
43 Class AnnounceListenManager/AS/Service/Mars -superclass AnnounceListenManager/AS/Service
44
45
46 # On receipt of the first announcement, create a SSACServer object, pass
47 # it the first SSAC message. The SSAC protocol is carried in the SSD field
48 # of AS1 announcements.
49 AnnounceListenManager/AS/Service/Mars public init {argv} {
50
51 $self instvar ssac_ timemap_ lastseqno_ ssd_ serv_inst_
52
53 #puts "***********************"
54 #puts "$argv"
55 #puts "***********************"
56
57 set ssd [lindex $argv 0]
58 set serv_inst_ [lindex $argv 1]
59 set uniqport [lindex $argv 2]
60 set megactrl [lindex $argv 4]
61
62 $self next $self $megactrl 20000 $serv_inst_
63
64 # Initialize agent-data
65
66 set ssd_(filename) ""
67 set ssd_(duration) ""
68 set ssd_(sesslist) ""
69
70 set lastseqno_ 0
71 set ssac_ [new SSACServer $self $ssd $uniqport $megactrl]
72 }
73
74 #
75 AnnounceListenManager/AS/Service/Mars public service_name {} {
76 return Mars
77 }
78
79
80
81 # Recv a message, check if it's for us, and check if the seqno has incremented
82 # If not, then it's a keep alive message, and we can ignore it. If so, then
83 # pass the message in to the archive agent
84 AnnounceListenManager/AS/Service/Mars public recv_msg {atype aspec addr srv_name srv_loc srv_inst ssg_port ssd} {
85
86 $self instvar ssac_ lastseqno_ serv_inst_
87
88 if { $srv_name == "DEATH" } {
89 puts stderr "Received death packet from $aspec at $addr - exiting."
90 $self announce_death
91 exit 0
92 }
93 $self next $atype $aspec $addr $srv_name $srv_loc $srv_inst $ssg_port $ssd
94
95 if {$serv_inst_ != $srv_inst} {
96 return
97 }
98
99 set seqno [lindex [split [lindex [split $ssd "\n"] 0]] 1]
100 #puts "Seqno $seqno"
101 if {$seqno > $lastseqno_} {
102 $ssac_ recv_msg $ssd
103 # Since we know the agent has incremented the seqno,
104 # we incr the lastseqno as well. Should prob get the
105 # new seqno from the agent instead.
106 incr seqno
107 set lastseqno_ $seqno
108 }
109
110
111 }
112
113 #
114 AnnounceListenManager/AS/Service/Mars public set_agent_data {newmsg} {
115
116 $self instvar ssd_out_
117
118 set ssd_out_ $newmsg
119
120 }
121
122 #
123 AnnounceListenManager/AS/Service/Mars public set_filename {filename} {
124 $self instvar ssd_
125
126 set ssd_(filename) $filename
127 }
128
129 #
130 AnnounceListenManager/AS/Service/Mars public set_duration {duration} {
131 $self instvar ssd_
132
133 set ssd_(duration) $duration
134 }
135
136 #
137 AnnounceListenManager/AS/Service/Mars public add_sessinfo {sessname sessaddr lsrcid} {
138 $self instvar ssd_
139
140 lappend ssd_(sesslist) $sessname
141
142 set ssd_($sessname,Address) $sessaddr
143 set ssd_($sessname,SrcIDs) $lsrcid
144 }
145
146 #
147 AnnounceListenManager/AS/Service/Mars public set_seqno {seqno} {
148 $self instvar ssd_
149
150 set ssd_(seqno) $seqno
151 }
152
153 # SSACServer sets the agent-data for the return messages
154 AnnounceListenManager/AS/Service/Mars public agent_data {} {
155 $self instvar ssd_ ssac_
156
157 set aa "Seqno $ssd_(seqno)"
158 set a "PSID $ssd_(filename)"
159 set c "Duration $ssd_(duration)"
160 set cc "Current [$ssac_ get_mapping]"
161 set d ""
162 foreach sess $ssd_(sesslist) {
163 set d "$d\nSName $sess\nAddress $ssd_($sess,Address) $ssd_($sess,SrcIDs)"
164 }
165
166 set response "$aa\n$a\n$c\n$cc$d\n"
167
168 # puts "respone - $response"
169
170 if {$ssd_(seqno) > 0 } {
171 return $response
172 } else {
173 return ""
174 }
175
176
177
178 }
179
180
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.