hypercast
Class MessageStore

java.lang.Object
  |
  +--hypercast.MessageStore
All Implemented Interfaces:
I_Stats

public class MessageStore
extends java.lang.Object
implements I_Stats

A buffer that holds messages and allows messages, or types of messages, to have finite state machines associated with them. It is through these finite state machine that interesting services can be created. Finite state machines are created by extending the I_MessageStoreFSM interface.


Field Summary
static short FSM_BEST_EFFORT_ORDERING
           
static short FSM_DUPLICATE_ELIMINATION
           
static short FSM_E2E_ACK
           
static short FSM_H2H_ACK
           
static short FSM_INCAST
           
static short FSM_NAMING
           
static short FSM_NO_SERVICE
          Finite state machine identifiers
static short FSM_SYNCHRONIZATION
           
static short MESSAGESTORE_MESSAGE
           
static short OTHER_MESSAGE
           
static short STREAM_MESSAGE
          Message type conatsnts.
 
Constructor Summary
MessageStore(hypercast.OL_Socket socket, hypercast.HyperCastConfig config)
          Constructs a MessageStore object with HyperCastConfig and OL_Socket.
 
Method Summary
 void clearTimer(hypercast.I_MessageStoreFSM fsm, int index)
          Clear the timer
 void clearTimer(hypercast.I_MessageStoreFSM fsm, java.lang.Object obj)
          Clear the timer
 void createFSMPool()
          Create a pool to store pre-allocated FSM instances based on the configuration file.
 hypercast.I_MessageStoreFSM get(byte[] messageid)
          Get the message in the hashtable
static short getMsgType(short serviceNumber)
          Returns the message type given a service identifier.
 org.w3c.dom.Element[] getReadSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          Dynamically generates a subtree of the Readable Schema rooted at the path specified by the xpath.
 org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          Gets statistics information from an object which implements this interface.
 java.lang.String getStatsName()
          Gets the element name of this I_Stats instance.
 long getTimer(hypercast.I_MessageStoreFSM fsm, int index)
          Get the timer
 org.w3c.dom.Element[] getWriteSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          Return the schema element which represents the root of the sub-tree, specified by the given xpath, in write schema tree.
static boolean isValidServiceNumber(short serviceNumber)
          Test if a service is supported by the MessageStore
 void put(byte[] messageid, hypercast.I_MessageStoreFSM fsm)
          Store the message in the hashtable
 void remove(byte[] messageid)
          Remove the message in the hashtable
 void setNotificationHandler(hypercast.NotificationHandler notificationHandler)
          Sets the notification handler that is used to pass events from the message store to an application.
 org.w3c.dom.Element[] setStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath, org.w3c.dom.Element newValue)
          Sets statistics information for an object which implements this interface.
 void setStatsName(java.lang.String name)
          Assigns a name to this I_Stats instance.
 void setTimer(hypercast.I_MessageStoreFSM fsm, int index, long delay_ms)
          Set the timer
 void setTimer(hypercast.I_MessageStoreFSM fsm, java.lang.Object obj, long delay_ms)
          Set the timer
 void start()
          Start the timer thread in the message store The code here are copied from adpter class
 void stop()
          Stop the thread
 void timerExpired(java.lang.Object timestamp)
          Sync the message store periodically
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FSM_NO_SERVICE

public static final short FSM_NO_SERVICE
Finite state machine identifiers

See Also:
Constant Field Values

FSM_H2H_ACK

public static final short FSM_H2H_ACK
See Also:
Constant Field Values

FSM_E2E_ACK

public static final short FSM_E2E_ACK
See Also:
Constant Field Values

FSM_DUPLICATE_ELIMINATION

public static final short FSM_DUPLICATE_ELIMINATION
See Also:
Constant Field Values

FSM_SYNCHRONIZATION

public static final short FSM_SYNCHRONIZATION
See Also:
Constant Field Values

FSM_INCAST

public static final short FSM_INCAST
See Also:
Constant Field Values

FSM_BEST_EFFORT_ORDERING

public static final short FSM_BEST_EFFORT_ORDERING
See Also:
Constant Field Values

FSM_NAMING

public static final short FSM_NAMING
See Also:
Constant Field Values

STREAM_MESSAGE

public static final short STREAM_MESSAGE
Message type conatsnts. The Finite state machine identifiers are grouped into message types.

See Also:
Constant Field Values

MESSAGESTORE_MESSAGE

public static final short MESSAGESTORE_MESSAGE
See Also:
Constant Field Values

OTHER_MESSAGE

public static final short OTHER_MESSAGE
See Also:
Constant Field Values
Constructor Detail

MessageStore

public MessageStore(hypercast.OL_Socket socket,
                    hypercast.HyperCastConfig config)
Constructs a MessageStore object with HyperCastConfig and OL_Socket.

Parameters:
config - HyperCastConfig
socket - OL_Socket
Method Detail

createFSMPool

public void createFSMPool()
Create a pool to store pre-allocated FSM instances based on the configuration file.


start

public void start()
Start the timer thread in the message store The code here are copied from adpter class


stop

public void stop()
Stop the thread


isValidServiceNumber

public static boolean isValidServiceNumber(short serviceNumber)
Test if a service is supported by the MessageStore

Parameters:
serviceNumber - service number
Returns:
true/false

getMsgType

public static short getMsgType(short serviceNumber)
Returns the message type given a service identifier.

Parameters:
serviceNumber - service number
Returns:
message type

setNotificationHandler

public void setNotificationHandler(hypercast.NotificationHandler notificationHandler)
Sets the notification handler that is used to pass events from the message store to an application.


put

public void put(byte[] messageid,
                hypercast.I_MessageStoreFSM fsm)
Store the message in the hashtable

Parameters:
messageid - UniqueID
fsm - I_MessageStoreFSM

get

public hypercast.I_MessageStoreFSM get(byte[] messageid)
Get the message in the hashtable

Parameters:
messageid - UniqueID
Returns:
I_MessageStoreFSM

remove

public void remove(byte[] messageid)
Remove the message in the hashtable

Parameters:
messageid - UniqueID

setTimer

public void setTimer(hypercast.I_MessageStoreFSM fsm,
                     int index,
                     long delay_ms)
Set the timer

Parameters:
fsm - I_MessageStoreFSM
index - timestampID
delay_ms - time of delay

setTimer

public void setTimer(hypercast.I_MessageStoreFSM fsm,
                     java.lang.Object obj,
                     long delay_ms)
Set the timer

Parameters:
fsm - I_MessageStoreFSM
obj - Object that will be returned when the timer expires
delay_ms - time of delay

clearTimer

public void clearTimer(hypercast.I_MessageStoreFSM fsm,
                       int index)
Clear the timer

Parameters:
fsm - I_MessageStoreFSM
index - timestampID

clearTimer

public void clearTimer(hypercast.I_MessageStoreFSM fsm,
                       java.lang.Object obj)
Clear the timer

Parameters:
fsm - I_MessageStoreFSM
obj - Object attached to the timer

getTimer

public long getTimer(hypercast.I_MessageStoreFSM fsm,
                     int index)
Get the timer

Parameters:
fsm - I_MessageStoreFSM
index - timestampID returns the delay

timerExpired

public void timerExpired(java.lang.Object timestamp)
Sync the message store periodically

Parameters:
timestamp - integer

getStatsName

public java.lang.String getStatsName()
Description copied from interface: I_Stats
Gets the element name of this I_Stats instance. The element name is originally assigned from the attribute StstsName in the configuration file, and can be changed by this method.

Specified by:
getStatsName in interface I_Stats
See Also:
I_Stats.getStatsName()

setStatsName

public void setStatsName(java.lang.String name)
Description copied from interface: I_Stats
Assigns a name to this I_Stats instance. The assigned name becomes the tag of the element associated to this I_Stats instance on the statistics tree.

Specified by:
setStatsName in interface I_Stats
Parameters:
name - the name assigned to the I_Stats instance.
See Also:
I_Stats.setStatsName(String)

getStats

public org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc,
                                      org.apache.xpath.XPath xpath)
                               throws HyperCastStatsException
Description copied from interface: I_Stats
Gets statistics information from an object which implements this interface. Statistics are arranged in a tree structure. This method has the ability to query an arbitrary subtree.

Specified by:
getStats in interface I_Stats
Parameters:
xpath - Specifies the statistic subtree to query.
doc - The document is used as a factory to create XML objects such as Nodes and Elements as needed. TODO: describe how the XML document in the doc is used.
Throws:
HyperCastStatsException - If the xpath does not specify a valid subtree.
See Also:
I_Stats.getStats(org.w3c.dom.Document, org.apache.xpath.XPath)

setStats

public org.w3c.dom.Element[] setStats(org.w3c.dom.Document doc,
                                      org.apache.xpath.XPath xpath,
                                      org.w3c.dom.Element newValue)
                               throws HyperCastStatsException
Description copied from interface: I_Stats
Sets statistics information for an object which implements this interface. Statistics are arranged in a tree structure. This method has the ability to set an arbitrary subtree of statistics.

Specified by:
setStats in interface I_Stats
Parameters:
xpath - Specifies the statistic subtree to use when updating values.
doc - The document is used as a factory to create XML objects such as Nodes and Elements as needed. TODO: describe how the XML document in the doc is used.
Throws:
HyperCastStatsException - If the xpath does not specify a valid subtree or if any part of the the subtree is read-only, or if the newValue does not conform with the expected format.
See Also:
I_Stats.setStats(org.w3c.dom.Document, org.apache.xpath.XPath, org.w3c.dom.Element)

getReadSchema

public org.w3c.dom.Element[] getReadSchema(org.w3c.dom.Document doc,
                                           org.apache.xpath.XPath xpath)
                                    throws HyperCastStatsException
Description copied from interface: I_Stats
Dynamically generates a subtree of the Readable Schema rooted at the path specified by the xpath. The Readable Schema is distrubuted among the componenets of hypercast. Each component knows how to generate its portion of the Readable Schema. If a component has sub-components, it calls getReadSchema recursively. Note that the Readable Schema is disjoint from the Writable Schema. The Readable Schema is not modeled as a subset of the Writable Schema.

Specified by:
getReadSchema in interface I_Stats
Throws:
HyperCastStatsException - If some part of the specified subtree does not correctly implement this interface method.
See Also:
I_Stats.getReadSchema(org.w3c.dom.Document, org.apache.xpath.XPath)

getWriteSchema

public org.w3c.dom.Element[] getWriteSchema(org.w3c.dom.Document doc,
                                            org.apache.xpath.XPath xpath)
                                     throws HyperCastStatsException
Return the schema element which represents the root of the sub-tree, specified by the given xpath, in write schema tree.

Specified by:
getWriteSchema in interface I_Stats
Parameters:
doc - Document used for create new elements or nodes.
xpath - XPath instance representing the statistics which is the root of the sub-tree to be queried.
Throws:
HyperCastStatsException - If some part of the specified subtree does not correctly implement this interface method.
See Also:
I_Stats.getWriteSchema(Document, XPath)