|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--hypercast.NotificationHandler
This class implements a notification mechanism for applications so
that applications can capture asynchronous events that happen in
the system. To receive notification of events the application
extends the NotificationHandler class. When an interesting event
occurs, the application is notified.
As events occur they are placed into a queue and sent to the
application in FIFO order. Applications may block a thread on an
event. Each event type has a lock object for this
purpose. Application may also choose to extend the default
asynchronous handler for an event type. If an application does
both, it will receive an event twice.
When blocking a thread on an event type, a boolean value can be
specified that determines whether or not an event that occurred
before the blocking call took place will cause the blocking thread
to unblock. For example if a node generates an NODE_ISSTABLE event
only once, but the application calls waitUntil_NODE_ISSTABLE
*after* this event occurs, it will never see the event unless it
asks to see any prior, unconsumed event. Note that only one prior
event is accessible, in general events do not queue if nobody is
listening for them.
A third way in which applications may receive notification of event
is by overriding the method of this class that dispatches
individual event handlers: handler
.
To add a new event search this file for TEMPLATE and copy and paste
templates doing a query/replace for the event type name.
Also, update the HyperCastAppl.java file.
Although this class is designed to be extended, it is not
abstract. This is because certain mechanisms, such as the naming
system, need to use the notification mechanism even when the
application does not.
Constructor Summary | |
NotificationHandler()
Construction of NotificationHandler causes a new
thread to be created and started. |
|
NotificationHandler(java.lang.String threadName)
|
Method Summary | |
void |
addNotificationHandler(hypercast.NotificationHandler nh)
Add notification handler to share the event source. |
void |
eventOccurred(hypercast.events.NOTIFICATION_EVENT event)
Called by the components which support notification function, method is final so that user cannot extend this method and write code that blocks indefinitely when an event occurs. |
void |
handle_E2EACK_RECEIVED(hypercast.events.E2EACK_RECEIVED event)
|
void |
handle_E2EPARTIALACK_RECEIVED(hypercast.events.E2EPARTIALACK_RECEIVED event)
|
void |
handle_MSG_WITH_E2EACK_SENT(hypercast.events.MSG_WITH_E2EACK_SENT event)
|
void |
handle_NAMING_EVENT(hypercast.events.NAMING_EVENT event)
|
void |
handle_NEWSTREAM_ARRIVED_EVENT(hypercast.events.NEWSTREAM_ARRIVED_EVENT event)
|
void |
handle_NODE_ISSTABLE(hypercast.events.NODE_ISSTABLE event)
|
void |
handle_NODE_LEAVEGROUP(hypercast.events.NODE_LEAVEOVERLAY event)
|
void |
handle_NODE_LEAVEOVERLAY(hypercast.events.NODE_LEAVEOVERLAY event)
|
void |
handle_NODE_LOGICALADDRESSCHANGED(hypercast.events.NODE_LOGICALADDRESSCHANGED event)
|
void |
handle_NODE_NEIGHBORHOODCHANGED(hypercast.events.NODE_NEIGHBORHOODCHANGED event)
|
void |
handler(hypercast.events.NOTIFICATION_EVENT event)
Determines the type of notification and dispatches the proper handler. |
void |
removeNotificationHandler(hypercast.NotificationHandler nh)
Remove a handler from the chain |
void |
stop()
This stops the notification handler. |
hypercast.events.E2EACK_RECEIVED |
waitUntil_E2EACK_RECEIVED()
|
hypercast.events.E2EACK_RECEIVED |
waitUntil_E2EACK_RECEIVED(long timeout)
|
hypercast.events.E2EPARTIALACK_RECEIVED |
waitUntil_E2EPARTIALACK_RECEIVED()
|
hypercast.events.E2EPARTIALACK_RECEIVED |
waitUntil_E2EPARTIALACK_RECEIVED(long timeout)
|
hypercast.events.MSG_WITH_E2EACK_SENT |
waitUntil_MSG_WITH_E2EACK_SENT()
|
hypercast.events.MSG_WITH_E2EACK_SENT |
waitUntil_MSG_WITH_E2EACK_SENT(long timeout)
|
hypercast.events.NAMING_EVENT |
waitUntil_NAMING_EVENT()
|
hypercast.events.NAMING_EVENT |
waitUntil_NAMING_EVENT(long timeout)
|
hypercast.events.NEWSTREAM_ARRIVED_EVENT |
waitUntil_NEWSTREAM_ARRIVED_EVENT()
|
hypercast.events.NEWSTREAM_ARRIVED_EVENT |
waitUntil_NEWSTREAM_ARRIVED_EVENT(long timeout)
|
hypercast.events.NODE_ISSTABLE |
waitUntil_NODE_ISSTABLE()
|
hypercast.events.NODE_ISSTABLE |
waitUntil_NODE_ISSTABLE(long timeout)
|
hypercast.events.NODE_LEAVEOVERLAY |
waitUntil_NODE_LEAVEGROUP()
|
hypercast.events.NODE_LEAVEOVERLAY |
waitUntil_NODE_LEAVEGROUP(long timeout)
|
hypercast.events.NODE_LEAVEOVERLAY |
waitUntil_NODE_LEAVEOVERLAY()
|
hypercast.events.NODE_LEAVEOVERLAY |
waitUntil_NODE_LEAVEOVERLAY(long timeout)
|
hypercast.events.NODE_LOGICALADDRESSCHANGED |
waitUntil_NODE_LOGICALADDRESSCHANGED()
|
hypercast.events.NODE_LOGICALADDRESSCHANGED |
waitUntil_NODE_LOGICALADDRESSCHANGED(long timeout)
|
hypercast.events.NODE_NEIGHBORHOODCHANGED |
waitUntil_NODE_NEIGHBORHOODCHANGED()
|
hypercast.events.NODE_NEIGHBORHOODCHANGED |
waitUntil_NODE_NEIGHBORHOODCHANGED(long timeout)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public NotificationHandler()
NotificationHandler
causes a new
thread to be created and started. This thread serves
notification events that appear in the
eventQueue
. Having a separate thread ensures that
the "internal" HyperCast threads (i.e. the adapter threads)
will not block due to application code.
public NotificationHandler(java.lang.String threadName)
Method Detail |
public void stop()
public final void addNotificationHandler(hypercast.NotificationHandler nh)
nh
- public final void removeNotificationHandler(hypercast.NotificationHandler nh)
nh
- addNotificationHandler(NotificationHandler)
public final void eventOccurred(hypercast.events.NOTIFICATION_EVENT event)
public void handler(hypercast.events.NOTIFICATION_EVENT event)
public void handler (final NOTIFICATION_EVENT event)
{
event.handle (this);
}
Each event could then call the appropriate method of the
notification handler from within its handle method. For example
for event type FOO:
public void handle (NotificationHandler notificationHandler)
{
notificationHandler.handle_FOO (this);
}
In this way, Java's virtual method dispatch would do the
dispatching.
This method is designed to be overriden by application code
that wants to have more control over event handling.
public void handle_NAMING_EVENT(hypercast.events.NAMING_EVENT event)
public final hypercast.events.NAMING_EVENT waitUntil_NAMING_EVENT()
public final hypercast.events.NAMING_EVENT waitUntil_NAMING_EVENT(long timeout)
public void handle_NODE_ISSTABLE(hypercast.events.NODE_ISSTABLE event)
public final hypercast.events.NODE_ISSTABLE waitUntil_NODE_ISSTABLE()
public final hypercast.events.NODE_ISSTABLE waitUntil_NODE_ISSTABLE(long timeout)
public void handle_E2EACK_RECEIVED(hypercast.events.E2EACK_RECEIVED event)
public final hypercast.events.E2EACK_RECEIVED waitUntil_E2EACK_RECEIVED()
public final hypercast.events.E2EACK_RECEIVED waitUntil_E2EACK_RECEIVED(long timeout)
public void handle_E2EPARTIALACK_RECEIVED(hypercast.events.E2EPARTIALACK_RECEIVED event)
public final hypercast.events.E2EPARTIALACK_RECEIVED waitUntil_E2EPARTIALACK_RECEIVED()
public final hypercast.events.E2EPARTIALACK_RECEIVED waitUntil_E2EPARTIALACK_RECEIVED(long timeout)
public void handle_MSG_WITH_E2EACK_SENT(hypercast.events.MSG_WITH_E2EACK_SENT event)
public final hypercast.events.MSG_WITH_E2EACK_SENT waitUntil_MSG_WITH_E2EACK_SENT()
public final hypercast.events.MSG_WITH_E2EACK_SENT waitUntil_MSG_WITH_E2EACK_SENT(long timeout)
public void handle_NEWSTREAM_ARRIVED_EVENT(hypercast.events.NEWSTREAM_ARRIVED_EVENT event)
public final hypercast.events.NEWSTREAM_ARRIVED_EVENT waitUntil_NEWSTREAM_ARRIVED_EVENT()
public final hypercast.events.NEWSTREAM_ARRIVED_EVENT waitUntil_NEWSTREAM_ARRIVED_EVENT(long timeout)
public void handle_NODE_LEAVEGROUP(hypercast.events.NODE_LEAVEOVERLAY event)
public final hypercast.events.NODE_LEAVEOVERLAY waitUntil_NODE_LEAVEGROUP()
public final hypercast.events.NODE_LEAVEOVERLAY waitUntil_NODE_LEAVEGROUP(long timeout)
public void handle_NODE_LEAVEOVERLAY(hypercast.events.NODE_LEAVEOVERLAY event)
public final hypercast.events.NODE_LEAVEOVERLAY waitUntil_NODE_LEAVEOVERLAY()
public final hypercast.events.NODE_LEAVEOVERLAY waitUntil_NODE_LEAVEOVERLAY(long timeout)
public void handle_NODE_LOGICALADDRESSCHANGED(hypercast.events.NODE_LOGICALADDRESSCHANGED event)
public final hypercast.events.NODE_LOGICALADDRESSCHANGED waitUntil_NODE_LOGICALADDRESSCHANGED()
public final hypercast.events.NODE_LOGICALADDRESSCHANGED waitUntil_NODE_LOGICALADDRESSCHANGED(long timeout)
public void handle_NODE_NEIGHBORHOODCHANGED(hypercast.events.NODE_NEIGHBORHOODCHANGED event)
public final hypercast.events.NODE_NEIGHBORHOODCHANGED waitUntil_NODE_NEIGHBORHOODCHANGED()
public final hypercast.events.NODE_NEIGHBORHOODCHANGED waitUntil_NODE_NEIGHBORHOODCHANGED(long timeout)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |