hypercast.MonitorAndControl
Class Portal

java.lang.Object
  |
  +--hypercast.MonitorAndControl.Portal
All Implemented Interfaces:
hypercast.MonitorAndControl.I_MCRaw_Callback, I_Portal, I_Stats

public class Portal
extends java.lang.Object
implements I_Portal, hypercast.MonitorAndControl.I_MCRaw_Callback

A Portal runs an overlay socket such that the Monitor can establish communication with the Portal through the overlay network. An advertising protocol is run between Monitor and Portal for them to discover each other. A Portal provides the way to access an local I_Stats object from the remote Monitor. Portal accepts query message from the Monitor and replies. The query message coming from a Monitor can have one of the following purposes: 1. Read a list of statistics values of the I_Stats object. 2. Set a list of statistics values of the I_Stats object. 3. Get the schema of a list of readable statistics of the I_Stats object. 4. Get the schema of a list of writable statistics of the I_Stats object.


Constructor Summary
Portal(hypercast.HyperCastConfig config, hypercast.I_Stats applicationStats, java.lang.String applicationStatsRootName)
           
 
Method Summary
 void closePortal()
          Closes the portal.
 org.w3c.dom.Element[] getReadSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          I_Stats#getReadSchema
 org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          I_Stats#getStats
 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)
          I_Stats#getWriteSchema
 void openPortal()
          Opens the Portal.
 void receiveMCRawMessage(hypercast.MonitorAndControl.MCRawMessage message)
          Receives an MC Raw message.
 void setSilentOff()
          Causes a Portal to begin sending MonitorAdvertise messages to a Monitor
 void setSilentOn()
          Causes a Portal to cease sending MonitorAdvertise messages to a Monitor
 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 startTranscript(java.lang.String filename)
          Causes MCMessages to be recorded in a transcript file.
 void stopTranscript()
          Stops transcripting.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Portal

public Portal(hypercast.HyperCastConfig config,
              hypercast.I_Stats applicationStats,
              java.lang.String applicationStatsRootName)
Parameters:
config - Used to initialized various components of the Portal.
applicationStats - statistics object for statistics of the Portal application
applicationStatsRootName - name of the root of the application statistics, ex. "Appl" or "Socket" The user of the Monitor trying to access the statistics on the Portal should write the XPath query String like: "/Stats/Appl/...". To access NumSockets statistic in RunServer use this XPath string: "/Stats/Appl/NumOfSockets To access the logical address statistic of the second Socket statistic in RunServer use this XPath string: "/Stats/Appl/Socket[2]/Node/LogicalAddress To access the logical address statistic of a Portal's Socket use this XPath string: "/Stats/Portal/Socket/Node/LogicalAddress Assuming that the RunServer used "Appl" as the name of the root of its stats. "Stats" is fixed by the implementation.
Method Detail

startTranscript

public void startTranscript(java.lang.String filename)
                     throws java.io.FileNotFoundException,
                            java.lang.IllegalStateException,
                            HyperCastWarningRuntimeException
Description copied from interface: I_Portal
Causes MCMessages to be recorded in a transcript file. Depending on the options present in the configuration file either messages that are sent, received, or both will be recorded.

Specified by:
startTranscript in interface I_Portal
Parameters:
filename - The name of the transcript file.
Throws:
HyperCastWarningRuntimeException - If the configuration specifies that neither sent nor received messsages should be recorded.
java.io.FileNotFoundException - If the specified file cannot be accessed
java.lang.IllegalStateException - If a transcript is already started
See Also:
I_Portal.startTranscript(String)

stopTranscript

public void stopTranscript()
                    throws java.lang.IllegalStateException,
                           HyperCastWarningRuntimeException
Description copied from interface: I_Portal
Stops transcripting.

Specified by:
stopTranscript in interface I_Portal
Throws:
java.lang.IllegalStateException - If no transcript is active.
HyperCastWarningRuntimeException
See Also:
I_Portal.stopTranscript()

openPortal

public void openPortal()
Description copied from interface: I_Portal
Opens the Portal. This causes the PortalAdvertiser thread to unblock so that MCAdvertiseMessages begin to flow from the Portal to the Monitor. A Portal cannot be used until it is opened.

Specified by:
openPortal in interface I_Portal
See Also:
I_Portal.openPortal()

closePortal

public void closePortal()
Description copied from interface: I_Portal
Closes the portal. This causes the PortalAdvertiser thread to block so that MCAdvertiseMessages cease to flow from the Portal to the Monitor.

Specified by:
closePortal in interface I_Portal
See Also:
I_Portal.closePortal()

setSilentOn

public void setSilentOn()
Description copied from interface: I_Portal
Causes a Portal to cease sending MonitorAdvertise messages to a Monitor

Specified by:
setSilentOn in interface I_Portal
See Also:
I_Portal.setSilentOff()

setSilentOff

public void setSilentOff()
Description copied from interface: I_Portal
Causes a Portal to begin sending MonitorAdvertise messages to a Monitor

Specified by:
setSilentOff in interface I_Portal
See Also:
I_Portal.setSilentOff()

receiveMCRawMessage

public void receiveMCRawMessage(hypercast.MonitorAndControl.MCRawMessage message)
Description copied from interface: hypercast.MonitorAndControl.I_MCRaw_Callback
Receives an MC Raw message.

Specified by:
receiveMCRawMessage in interface hypercast.MonitorAndControl.I_MCRaw_Callback
Parameters:
message - Raw message that is passed to the callback

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(java.lang.String)

getStats

public org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc,
                                      org.apache.xpath.XPath xpath)
                               throws HyperCastStatsException
I_Stats#getStats

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.

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
I_Stats#getReadSchema

Specified by:
getReadSchema in interface I_Stats
Throws:
HyperCastStatsException - If some part of the specified subtree does not correctly implement this interface method.

getWriteSchema

public org.w3c.dom.Element[] getWriteSchema(org.w3c.dom.Document doc,
                                            org.apache.xpath.XPath xpath)
                                     throws HyperCastStatsException
I_Stats#getWriteSchema

Specified by:
getWriteSchema in interface I_Stats
Throws:
HyperCastStatsException - If some part of the specified subtree does not correctly implement this interface method.