|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The Monitor
class provides the API used to access
remote Portals
. This class can be seen as the
combination of PortalListManager
and
MCSocket
with a few extra services.
Remote Portals
are addressed using integer
indices. Once an index is assigned to a Portal
, that
index is bound to that Portal
for the duration of the
existence of the Monitor
, i.e. indices are never
reassigned (unless compactPortalList()
or
clearPortalList()
is called).
Responsible for: - ensuring uniqueness of message ids - registering
callbacks for message receipt and timeouts - delegating calls to
MCSocket
and PortalListManager
Method Summary | |
void |
clearPortalList()
Clear the portal list. |
void |
closeMonitor()
explicitly close monitor |
void |
compactPortalList()
Compact the portal list Remove all inactive portals from Monitor data structures. |
hypercast.MonitorAndControl.MonMessage |
createGetRequest()
create a GetRequest message "GetRequest" message is used to query for one or more statistics on a Portal. |
hypercast.MonitorAndControl.MonMessage |
createReadSchemaRequest()
create a ReadSchema request "ReadSchema" message is used to query the schemas of a list of the readable statistics on a Portal. |
hypercast.MonitorAndControl.MonMessage |
createSetRequest()
create a SetRequest message "SetRequest" message is used to set the values of a list of statistics on a Portal. |
hypercast.MonitorAndControl.MonMessage |
createWriteSchemaRequest()
create a WriteSchema request "WriteSchema" message is used to query the schemas of a list of the writable statistics on a Portal. |
int[] |
getActivePortalIndices()
Get an integer array containing the indices of active portals. |
int[] |
getAllPortalIndices()
Get An integer array containing the indexes of all. |
int[] |
getInactivePortalIndices()
Get an integer array containing the indices of inactive portals. |
hypercast.I_LogicalAddress |
getPortalAddress(int portalIndex)
Get the logical address of a Portal |
int |
indexOfPortal(hypercast.I_LogicalAddress portalLogicalAddress)
Get the index of a portal by its logical address. |
boolean |
isPortalActive(int portalIndex)
Check if a portal is still active |
void |
openMonitor()
Explicitly open monitor. |
void |
sendTo(int portalIndex,
hypercast.MonitorAndControl.MonMessage message,
hypercast.MonitorAndControl.I_ReceiveCallback receiveCallback,
hypercast.MonitorAndControl.I_TimeoutCallback timeoutCallback)
Sends an MonMessage to a single
Portal . |
void |
sendToAll(hypercast.MonitorAndControl.MonMessage message,
hypercast.MonitorAndControl.I_ReceiveCallback receiveCallback,
hypercast.MonitorAndControl.I_TimeoutCallback timeoutCallback)
Send a MC message to all portals by multicast. |
void |
setSilentOff()
Causes a Monitor to begin sending MonitorAdvertise messages to Portals |
void |
setSilentOn()
Causes a Monitor to cease sending MonitorAdvertise messages to Portals |
void |
startTranscript(java.lang.String filename)
Causes MCMessages to be recorded in a transcript
file. |
void |
stopTranscript()
Stops transcripting. |
Methods inherited from interface hypercast.I_Stats |
getReadSchema, getStats, getStatsName, getWriteSchema, setStats, setStatsName |
Method Detail |
public int[] getActivePortalIndices()
null
. The length of this array is at most
the number of Portals.public int[] getInactivePortalIndices()
null
. The length of this array is at most
the number of Portals.public int[] getAllPortalIndices()
null
. The length of this array is the number
of Portals.public boolean isPortalActive(int portalIndex) throws NoSuchPortalException
portalIndex
- the index of the portal
NoSuchPortalException
- if this portal doesn't exist.public void clearPortalList()
public void compactPortalList()
public void sendTo(int portalIndex, hypercast.MonitorAndControl.MonMessage message, hypercast.MonitorAndControl.I_ReceiveCallback receiveCallback, hypercast.MonitorAndControl.I_TimeoutCallback timeoutCallback) throws NoSuchPortalException
MonMessage
to a single
Portal
. A reply message from the
Portal
having the same message ID as the request
message sent from the Monitor
will be the
parameter of the receiveCallback
for handling by
the application. The application need not provide a
receiveCallback
(can be null) if it is
uninterested in the response. If no reply is received during
the timeout time (configured in the config file), the
timeoutCallback
will be invoked with the request
message as a parameter (a copy of the request message is made
by the Monitor to ensure that the original request message is
given to the caller in the timeoutCallback
, this
is because a caller is free to use a message object many times,
possibly changing the contents between uses). A
timeoutCallback
need not be specified if the
application is not interested in timeouts (in this case no copy
of the original message is made).
Note that a caller may use the same message object again and
again as a parameter to this method and each invocation will be
interpreted as a new request so long as the message id field
is cleared before each call of this method
In the case of a timeoutCallback
invocation, an
application that wants to retransmit a request can call
sendTo()
again with the message reference that is
passed via the timeoutCallback
(this reference
points to a copy of the original message that was made when it
was sent). Doing this invokes a retransmission using the same
message id as the original transmission. Do not clear the
message id before calling sendTo()
for
retransmission.The subsequent call to sendTo()
will detect that the message was aready sent and not assign a
new message id to the request.
Be careful not to change the state of the message after calling
sendTo()
for a retransmission because in that
situation the Monitor implementation and the application both
have a pointer to the same data structure. Remember the the
Monitor made a copy of the message on the first send so that it
could give a pointer to the copy to the application on a
timeout. By calling sendTo()
with this reference
you are simply passing a pointer to an object that should be
considered internal state of the Monitor.
portalIndex
- index of destination portalmessage
- message to send, cannot be nullreceiveCallback
- callback object handling the reply message, can be nulltimeoutCallback
- callback to handle the timeout event, can be null
java.lang.NullPointerException
- if message is null
NoSuchPortalException
public void sendToAll(hypercast.MonitorAndControl.MonMessage message, hypercast.MonitorAndControl.I_ReceiveCallback receiveCallback, hypercast.MonitorAndControl.I_TimeoutCallback timeoutCallback)
message
- message to send, cannot be nullreceiveCallback
- callback to handle reply messagetimeoutCallback
- callback to handle situation when no portal replies
java.lang.NullPointerException
- if message is nullpublic int indexOfPortal(hypercast.I_LogicalAddress portalLogicalAddress) throws NoSuchPortalException
portalLogicalAddress
- the logical address of the portal
NoSuchPortalException
- if no portal exists with that logical addresspublic hypercast.I_LogicalAddress getPortalAddress(int portalIndex) throws NoSuchPortalException
portalIndex
- The index of the Portal.
NoSuchPortalException
- If the portal doesn't exist.public hypercast.MonitorAndControl.MonMessage createGetRequest()
public hypercast.MonitorAndControl.MonMessage createSetRequest()
public hypercast.MonitorAndControl.MonMessage createReadSchemaRequest()
public hypercast.MonitorAndControl.MonMessage createWriteSchemaRequest()
public void startTranscript(java.lang.String filename) throws java.io.FileNotFoundException, java.lang.IllegalStateException, HyperCastWarningRuntimeException
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.
filename
- The name of the transcript file.
HyperCastWarningRuntimeException
- If the header cannot be written to the transcript file.
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 startedpublic void stopTranscript() throws java.lang.IllegalStateException, HyperCastWarningRuntimeException
java.lang.IllegalStateException
- If no transcript is active.
HyperCastWarningRuntimeException
public void openMonitor()
public void closeMonitor()
public void setSilentOn()
public void setSilentOff()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |