org.apache.catalina.tribes.group
public class GroupChannel extends ChannelInterceptorBase implements ManagedChannel
Version: $Revision: 568742 $, $Date: 2007-08-22 22:19:54 +0200 (Wed, 22 Aug 2007) $
| Nested Class Summary | |
|---|---|
| static class | GroupChannel.HeartbeatThread Title: Internal heartbeat thread Description: if |
| static class | GroupChannel.InterceptorIterator Title: Interceptor Iterator Description: An iterator to loop through the interceptors in a channel |
| Field Summary | |
|---|---|
| protected ArrayList | channelListeners
A list of channel listeners that subscribe to incoming messages |
| protected ChannelCoordinator | coordinator
The ChannelCoordinator coordinates the bottom layer components:- MembershipService - ChannelSender - ChannelReceiver |
| protected GroupChannel.HeartbeatThread | hbthread
Internal heartbeat thread |
| protected boolean | heartbeat
Flag to determine if the channel manages its own heartbeat
If set to true, the channel will start a local thread for the heart beat. |
| protected long | heartbeatSleeptime
If heartbeat == true then how often do we want this
heartbeat to run. default is one minute |
| protected ChannelInterceptor | interceptors
The first interceptor in the inteceptor stack.
|
| protected ArrayList | membershipListeners
A list of membership listeners that subscribe to membership announcements |
| protected boolean | optionCheck
If set to true, the GroupChannel will check to make sure that |
| Constructor Summary | |
|---|---|
| GroupChannel()
Creates a GroupChannel. | |
| Method Summary | |
|---|---|
| void | addChannelListener(ChannelListener channelListener)
Adds a channel listener to the channel. Channel listeners are uniquely identified using the equals(Object) method |
| void | addInterceptor(ChannelInterceptor interceptor)
Adds an interceptor to the stack for message processing Interceptors are ordered in the way they are added. channel.addInterceptor(A);channel.addInterceptor(C);channel.addInterceptor(B);Will result in a interceptor stack like this: A -> C -> BThe complete stack will look like this: Channel -> A -> C -> B -> ChannelCoordinator |
| void | addMembershipListener(MembershipListener membershipListener)
Adds a membership listener to the channel. Membership listeners are uniquely identified using the equals(Object) method |
| protected void | checkOptionFlags()
Validates the option flags that each interceptor is using and reports
an error if two interceptor share the same flag. |
| ChannelReceiver | getChannelReceiver()
Returns the channel receiver component |
| ChannelSender | getChannelSender()
Returns the channel sender component |
| ChannelInterceptor | getFirstInterceptor()
Returns the first interceptor of the stack. |
| boolean | getHeartbeat() |
| long | getHeartbeatSleeptime()
Returns the sleep time in milliseconds that the internal heartbeat will
sleep in between invokations of Channel.heartbeat() |
| Iterator | getInterceptors()
Returns an iterator of all the interceptors in this stack |
| MembershipService | getMembershipService()
Returns the membership service component |
| boolean | getOptionCheck() |
| void | heartbeat()
Sends a heartbeat through the interceptor stack. Invoke this method from the application on a periodic basis if you have turned off internal heartbeats channel.setHeartbeat(false) |
| void | memberAdded(Member member)
memberAdded gets invoked by the interceptor below the channel
and the channel will broadcast it to the membership listeners |
| void | memberDisappeared(Member member)
memberDisappeared gets invoked by the interceptor below the channel
and the channel will broadcast it to the membership listeners |
| void | messageReceived(ChannelMessage msg)
Callback from the interceptor stack. |
| void | removeChannelListener(ChannelListener channelListener)
Removes a channel listener from the channel. Channel listeners are uniquely identified using the equals(Object) method |
| void | removeMembershipListener(MembershipListener membershipListener)
Removes a membership listener from the channel. Membership listeners are uniquely identified using the equals(Object) method |
| UniqueId | send(Member[] destination, Serializable msg, int options)
Send a message to the destinations specified |
| UniqueId | send(Member[] destination, Serializable msg, int options, ErrorHandler handler) |
| protected void | sendNoRpcChannelReply(RpcMessage msg, Member destination)
Sends a NoRpcChannelReply message to a memberThis method gets invoked by the channel if a RPC message comes in and no channel listener accepts the message. |
| void | setChannelReceiver(ChannelReceiver clusterReceiver)
Sets the channel receiver component |
| void | setChannelSender(ChannelSender clusterSender)
Sets the channel sender component |
| void | setHeartbeat(boolean heartbeat)
Enables or disables local heartbeat.
if setHeartbeat(true) is invoked then the channel will start an internal
thread to invoke Channel.heartbeat() every getHeartbeatSleeptime milliseconds |
| void | setHeartbeatSleeptime(long heartbeatSleeptime)
Configure local heartbeat sleep time Only used when getHeartbeat()==true |
| void | setMembershipService(MembershipService membershipService)
Sets the membership component |
| void | setOptionCheck(boolean optionCheck)
Enables/disables the option check Setting this to true, will make the GroupChannel perform a conflict check on the interceptors. |
| protected void | setupDefaultStack()
Sets up the default implementation interceptor stack
if no interceptors have been added |
| void | start(int svc)
Starts the channel |
| void | stop(int svc)
Stops the channel |
ChannelCoordinator coordinates the bottom layer components:heartbeat == true then how often do we want this
heartbeat to run. default is one minuteParameters: channelListener ChannelListener
channel.addInterceptor(A);channel.addInterceptor(C);channel.addInterceptor(B);A -> C -> BChannel -> A -> C -> B -> ChannelCoordinatorParameters: interceptor ChannelInterceptorBase
Parameters: membershipListener MembershipListener
Throws: ChannelException
Returns: ChannelReceiver
Returns: ChannelSender
Returns: ChannelInterceptor
Returns: boolean
See Also: GroupChannel
Channel.heartbeat()Returns: long
Returns: Iterator
Returns: MembershipService
Returns: boolean
See Also: GroupChannel
channel.setHeartbeat(false)Parameters: member Member - the new member
Parameters: member Member - the member that left or crashed
Parameters: msg ChannelMessage
Parameters: channelListener ChannelListener
Parameters: membershipListener MembershipListener
Parameters: destination Member[] - destination.length > 1 msg Serializable - the message to send options int - sender options, options can trigger guarantee levels and different interceptors to
react to the message see class documentation for the Channel object.
Returns: UniqueId - the unique Id that was assigned to this message
Throws: ChannelException - if an error occurs processing the message
See Also: Channel
Parameters: destination Member[] - destination.length > 1 msg Serializable - the message to send options int - sender options, options can trigger guarantee levels and different interceptors to
react to the message see class documentation for the Channel object.
handler - callback object for error handling and completion notification, used when a message is
sent asynchronously using the Channel.SEND_OPTIONS_ASYNCHRONOUS flag enabled.
Returns: UniqueId - the unique Id that was assigned to this message
Throws: ChannelException - if an error occurs processing the message
See Also: Channel
NoRpcChannelReply message to a memberParameters: msg RpcMessage destination Member - the destination for the reply
Parameters: clusterReceiver ChannelReceiver
Parameters: clusterSender ChannelSender
setHeartbeat(true) is invoked then the channel will start an internal
thread to invoke Channel.heartbeat() every getHeartbeatSleeptime millisecondsParameters: heartbeat boolean
getHeartbeat()==trueParameters: heartbeatSleeptime long - time in milliseconds to sleep between heartbeats
Parameters: membershipService MembershipService
Parameters: optionCheck boolean
Throws: ChannelException
Parameters: svc int - what service to start
Throws: ChannelException
See Also: Channel