/[storm]/storm/doc/pegboard/storm_with_tapestry--hemppah/peg.rst
ViewVC logotype

Diff of /storm/doc/pegboard/storm_with_tapestry--hemppah/peg.rst

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by hemppah, Fri Jul 4 12:25:19 2003 UTC revision 1.5 by hemppah, Mon Jul 7 07:38:04 2003 UTC
# Line 152  Using Tapestry with Storm Line 152  Using Tapestry with Storm
152  - For finding Storm blocks in a Tapestry overlay, we must create:  - For finding Storm blocks in a Tapestry overlay, we must create:
153    
154    
155     - BlockIDTag class for Storm blocks' IDs (ostore.tapestry.api.TapestryTag)     - BlockIDTag class for Storm blocks' IDs (implements
156         ostore.tapestry.api.TapestryTag)
157    
158     - BlockIDQuery (implements ostore.tapestry.api.TapestryQuery) class is     - BlockIDQuery (implements ostore.tapestry.api.TapestryQuery) class is
159       used in a StormLocateMsg class (and in ostore.tapestry.api.TapestryLocateMsg)       used in a StormLocateMsg class (and in ostore.tapestry.api.TapestryLocateMsg)
160       to find objects identified by a BlockIDTag       to find objects identified by a BlockIDTag
161            
162     - StormLocateMsg class (extends ostore.tapestry.api.TapestryLocateMsg)     - StormQueryMsg class (extends ostore.tapestry.api.TapestryLocateMsg)
163      
164       - StormResponseMsg class
165    
166  - For interacting Storm's storage model with Tapestry:  - For interacting Storm's storage model with Tapestry:
167    
168     - StormTapestryManager class which     - StormTapestryManager class which
169       - registers Storm to handle Storm-related Tapestry events       - registers Storm to handle Storm-related Tapestry events
170       - dispatches and handles Storm-related Tapestry events       - dispatches and handles Storm-related Tapestry events
171        
172        
173     PSEUDOCODE for Storm
174    
175            class StormTapestryManager implements EventHandlerIF {
176            
177                    // dispatcher which dispatch all items
178                    // to target peer
179                    method dispatch (QueueElementIF item) {
180                            //try do dispatch an item
181                            try {
182                                    classifier.dispatch(item);
183                            } catch (expection) {
184                                    error("Could not dispatch item!")
185                            }
186                    }
187    
188                    // general initialization method
189                    // that handles subscribes this stage
190                    // to listen certain events and messages
191                    method init (ConfigDataIF config) {
192    
193                    // find our NodeId
194                    self_node_id = new NodeId
195                    
196                    // initialize the appropriate
197                    // instance of the Classifier. The Classifier handles the
198                    // publish/subscribe mechanism used for
199                    // event dispatch between stages.
200                    
201                    classifier = Classifier.getClassifier(self_node_id = new NodeId)
202                    
203                    // create peer ID based on peer's public key
204                     _peer = new SHA1Hash (pkey);
205                    
206                     // the *events* which we want to listen
207    
208                     array event_types = {
209                     "seda.sandStorm.api.StormFooSignal1",
210                     "seda.sandStorm.api.StormFooSignal2"            
211                    }
212                    
213                    for (From i = 0 To numberOf(event_types)) {
214                            classifier.subscribe (event_type[i])
215                     }
216                    
217                    // the *messages* we want receive through Tapestry
218    
219                    array message_types = {
220                    "ostore.apps.test.StormQueryMsg",
221                    "ostore.apps.test.StormResponseMsg"
222                    }
223                    
224                    for (From i = 0 To numberOf(message_types)) {
225                
226                       // First, register messages we intend to
227                       // receive
228                      
229                       TypeTable.register_type(messages_types[i])
230                      
231                       // Second, we require that inbound field is
232                       // set to true.  Otherwise, we will see the messages that we
233                       // send as well
234    
235                       classifier.subscribe (message_type[i], verifyInbound);
236                    }
237    
238                    }
239                    
240                    // handles *all* events which stage is listening
241                     method handleEvents(QueueElementIF array items)
242                     throws EventHandlerException {
243                    
244                     for (from i=0 to length(items)
245                            handleEvent(items[i])                  
246                     }
247                    
248                    // handles single event for this stage. handleEvents
249                    // method gives an item this method
250                    method handleEvent(QueueElementIF item) {
251                    
252                            if (item instanceof StormQueryMsg) {
253                                    handleStormQueryMsg(item)
254    
255                            } else if (item instanceof StormResponseMsg) {
256                                    handleStormResponseMsg(item)
257                            } else {
258                                    handleOtherMsg(item)            
259                            }
260                                    
261                    }
262                    
263                    // handles a certain type of event(StormQueryMsg)
264                    method handleStormQueryMsg(item){
265                            results = performLocalSearch()
266                            dispatch(results)              
267                    }
268                    
269                    // handles a certain type of event(StormResponseMsg)
270                    method handleStormResponseMsg(item){
271                            response = createResponse()
272                            dispatch(response)              
273                    }
274                    
275                    // createa a Storm query to a network
276                    // Query tag is Storm block's GUID
277                    method query(){
278                            blockTag = new BlockIDTag(blockGUID)
279                            q = new StormQuery()
280                            queryMsg=  new StormQueryMsg(blockTag, q)
281                            dispatch(queryMsg)
282                    }
283        }
284            
285  .. more to come  .. more to come
286    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26