demo.howto
Class DDHowto

java.lang.Object
  |
  +--ostore.util.StandardStage
        |
        +--demo.howto.DDHowto
All Implemented Interfaces:
EventHandlerIF, SingleThreadedEventHandlerIF

public class DDHowto
extends StandardStage
implements SingleThreadedEventHandlerIF

A simple example of how to write your own DD client and message types. The example is as follows. We bring up two machines, a sender and a receiver. The sender sends a DDHowto.Ping message to the receiver, which the receiver acknowledges with a DDHowto.Pong. This happens a number of times, and then the test exits. It's simple, but it covers most of the things you need to know to do more complicated things. Please just read the source, it's well commented.

First off, this class is going to be a SEDA/Sandstorm stage, so it has to inherit from SingleThreadedEventHandlerIF.

Version:
$Id: DDHowto.java,v 1.3 2004/05/19 06:33:43 hweather Exp $
Author:
Sean C. Rhea

Nested Class Summary
static class DDHowto.Ping
          One of two DD messages used in this test.
static class DDHowto.Pong
          This class is identical in all by type from the DDHowto.Ping class, so I'm not going to comment it further.
 
Field Summary
 
Fields inherited from class ostore.util.StandardStage
classifier, DEBUG, event_types, inb_msg_types, logger, my_node_id, my_sink, outb_msg_types, resender, resender_tokens, serializable_types, sim_running, tag
 
Constructor Summary
DDHowto()
          Constructor: Creates a new DDHowto stage.
 
Method Summary
 void handleEvent(QueueElementIF item)
          This is the function that will be called when a stage dispatches a message that we've subscribed to.
 void init(ConfigDataIF config)
          Specified by seda.sandStorm.api.EventHandlerIF Initializes the stage once Sandstorm is up and running or more likely DustDevil (a.k.a. a Little SandStorm [lss]) You'll notice that most stages won't have constructors.
 
Methods inherited from class ostore.util.StandardStage
BUG, BUG, BUG, destroy, dispatch, enqueue, handleEvents, now_ms, now_us
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DDHowto

public DDHowto()
        throws Exception
Constructor: Creates a new DDHowto stage.

Method Detail

init

public void init(ConfigDataIF config)
          throws Exception
Specified by seda.sandStorm.api.EventHandlerIF Initializes the stage once Sandstorm is up and running or more likely DustDevil (a.k.a. a Little SandStorm [lss])

You'll notice that most stages won't have constructors. The reason is that all initialization can take place here, where you have the information from your stage's config file to help you. I'll detail the important things you want to do in this function below.

Specified by:
init in interface EventHandlerIF
Overrides:
init in class StandardStage
Exception

handleEvent

public void handleEvent(QueueElementIF item)
                 throws EventHandlerException
This is the function that will be called when a stage dispatches a message that we've subscribed to.

Specified by:
handleEvent in interface EventHandlerIF
EventHandlerException