|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--hypercast.MessageBuffer
This class provides a buffer which handles all the functionality for the producer/consumer problem. It assumes that there can be multiple producers and consumers. This is a FIFO style Buffer.
Field Summary | |
static int |
SOCKET_TIMEOUT_INFINITY
|
Constructor Summary | |
MessageBuffer(hypercast.HyperCastConfig config,
int queueSize)
|
|
MessageBuffer(hypercast.HyperCastConfig config,
int queueSize,
int socketTimeout)
Constructs the MessageBuffer with a config file and a size. |
|
MessageBuffer(hypercast.HyperCastConfig config,
int queueSize,
java.lang.String name)
Constructs the MessageBuffer with a config file and a size. |
Method Summary | |
boolean |
available()
Checks if there is any messages available in the queue. |
void |
blockingWrite(hypercast.I_Message msg)
Writes a message to the BoundedBuffer |
org.w3c.dom.Element[] |
getReadSchema(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 read schema tree. |
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. |
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. |
void |
nonblockingWrite(hypercast.I_Message msg)
Writes a message to the DropTailMessageBuffer |
int |
numInQueue()
Returns the number of messages in the queue. |
hypercast.I_Message |
peek()
Peeks the message at the head of the queue |
hypercast.I_Message |
read()
Reads a message from the BoundedBuffer. |
org.w3c.dom.Element[] |
setStats(org.w3c.dom.Document doc,
org.apache.xpath.XPath xpath,
org.w3c.dom.Element newValue)
Set the statistics specified by the given xpath. |
void |
setStatsName(java.lang.String name)
Assigns a name to this I_Stats instance. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SOCKET_TIMEOUT_INFINITY
Constructor Detail |
public MessageBuffer(hypercast.HyperCastConfig config, int queueSize, java.lang.String name)
config
- The configuration object.queueSize
- The size of the buffer (number of messages)public MessageBuffer(hypercast.HyperCastConfig config, int queueSize)
public MessageBuffer(hypercast.HyperCastConfig config, int queueSize, int socketTimeout)
config
- The configuration object.queueSize
- The size of the buffer (number of messages)socketTimeout
- The amount of time (in milliseconds) to wait before giving up on a read operation.Method Detail |
public hypercast.I_Message read() throws java.lang.InterruptedException
Algorithm:
1. Waits till the queue is non-empty
2. Copies first element in the queue
3. Increments the start pointer modulo queue length
4. Decreases size of the queue
5. Notifies any other process waiting
6. Returns the copied element
java.lang.InterruptedException
public void nonblockingWrite(hypercast.I_Message msg)
Algorithm:
1. checks if queue is full
2. Places New packet at the end of the queue
3. Increments number of elements
4. Notifies all threads waiting
msg
- a message to be added into the queuepublic void blockingWrite(hypercast.I_Message msg) throws java.lang.InterruptedException
Algorithm:
1. checks if queue is full
2. Places New packet at the end of the queue
3. Increments number of elements
4. Notifies all threads waiting
msg
- a message to be added into the queue
java.lang.InterruptedException
public hypercast.I_Message peek()
Algorithm:
If queue is empty return null, else return the packet at the head of the queue
public boolean available()
public int numInQueue()
public java.lang.String getStatsName()
I_Stats
getStatsName
in interface I_Stats
I_Stats.getStatsName()
public void setStatsName(java.lang.String name)
I_Stats
setStatsName
in interface I_Stats
name
- the name assigned to the I_Stats instance.I_Stats.setStatsName(String)
public org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath) throws HyperCastStatsException
I_Stats
getStats
in interface I_Stats
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.
HyperCastStatsException
- If the xpath does not specify a valid subtree.I_Stats.getStats(Document, XPath)
public org.w3c.dom.Element[] setStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath, org.w3c.dom.Element newValue) throws HyperCastStatsException
setStats
in interface I_Stats
doc
- Document used for create new elements or nodes.xpath
- XPath instance represents the statistics to be queried.newValue
- Element representing the value or sub-tree to be set.
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.I_Stats.setStats(org.w3c.dom.Document, org.apache.xpath.XPath, org.w3c.dom.Element)
public org.w3c.dom.Element[] getReadSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath) throws HyperCastStatsException
getReadSchema
in interface I_Stats
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.
HyperCastStatsException
- If some part of the specified
subtree does not correctly implement this interface method.I_Stats.getReadSchema(Document, XPath)
public org.w3c.dom.Element[] getWriteSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath) throws HyperCastStatsException
getWriteSchema
in interface I_Stats
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.
HyperCastStatsException
- If some part of the specified
subtree does not correctly implement this interface method.I_Stats.getWriteSchema(Document, XPath)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |