org.apache.catalina.tribes
public interface Channel
ChannelListener
getMembers()
MembershipListener
ChannelListener_1..ChannelListener_N MembershipListener_1..MembershipListener_N [Application Layer]
\ \ / /
\ \ / /
\ \ / /
\ \ / /
\ \ / /
\ \ / /
---------------------------------------
|
|
Channel
|
ChannelInterceptor_1
| [Channel stack]
ChannelInterceptor_N
|
Coordinator (implements MessageListener,MembershipListener,ChannelInterceptor)
--------------------
/ | \
/ | \
/ | \
/ | \
/ | \
MembershipService ChannelSender ChannelReceiver [IO layer]
For example usage @see org.apache.catalina.tribes.group.GroupChannelVersion: $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (Tue, 24 Oct 2006) $
Field Summary | |
---|---|
static int | DEFAULT
Start and stop sequences can be controlled by these constants
This allows you to start separate components of the channel DEFAULT - starts or stops all components in the channel |
static int | MBR_RX_SEQ
Start and stop sequences can be controlled by these constants
This allows you to start separate components of the channel MBR_RX_SEQ - starts or stops the membership listener. |
static int | MBR_TX_SEQ
Start and stop sequences can be controlled by these constants
This allows you to start separate components of the channel MBR_TX_SEQ - starts or stops the membership broadcaster. |
static int | SEND_OPTIONS_ASYNCHRONOUS
Send options, when a message is sent, it can have an option flag
to trigger certain behavior. |
static int | SEND_OPTIONS_BYTE_MESSAGE
Send options, when a message is sent, it can have an option flag
to trigger certain behavior. |
static int | SEND_OPTIONS_DEFAULT
Send options, when a message is sent, it can have an option flag
to trigger certain behavior. |
static int | SEND_OPTIONS_SECURE
Send options, when a message is sent, it can have an option flag
to trigger certain behavior. |
static int | SEND_OPTIONS_SYNCHRONIZED_ACK
Send options, when a message is sent, it can have an option flag
to trigger certain behavior. |
static int | SEND_OPTIONS_USE_ACK
Send options, when a message is sent, it can have an option flag
to trigger certain behavior. |
static int | SND_RX_SEQ
Start and stop sequences can be controlled by these constants
This allows you to start separate components of the channel SND_RX_SEQ - starts or stops the data receiver. |
static int | SND_TX_SEQ
Start and stop sequences can be controlled by these constants
This allows you to start separate components of the channel SND_TX_SEQ - starts or stops the data sender. |
Method Summary | |
---|---|
void | addChannelListener(ChannelListener listener)
Add a channel listener, this is a callback object when messages are received
If the channel listener implements the Heartbeat interface the heartbeat() method will be invoked when the heartbeat runs on the channel |
void | addInterceptor(ChannelInterceptor interceptor)
Adds an interceptor to the channel message chain. |
void | addMembershipListener(MembershipListener listener)
Add a membership listener, will get notified when a new member joins, leaves or crashes
If the membership listener implements the Heartbeat interface the heartbeat() method will be invoked when the heartbeat runs on the channel |
Member | getLocalMember(boolean incAlive)
Return the member that represents this node. |
Member | getMember(Member mbr)
Returns the member from the membership service with complete and
recent data. |
Member[] | getMembers()
Get all current group members |
boolean | hasMembers()
Returns true if there are any members in the group,
this call is the same as getMembers().length>0 |
void | heartbeat()
Sends a heart beat through the interceptor stacks
Use this method to alert interceptors and other components to
clean up garbage, timed out messages etc. If you application has a background thread, then you can save one thread, by configuring your channel to not use an internal heartbeat thread and invoking this method. |
void | removeChannelListener(ChannelListener listener)
remove a channel listener, listeners are removed based on Object.hashCode and Object.equals |
void | removeMembershipListener(MembershipListener listener)
remove a membership listener, listeners are removed based on Object.hashCode and Object.equals |
UniqueId | send(Member[] destination, Serializable msg, int options)
Send a message to one or more members in the cluster |
UniqueId | send(Member[] destination, Serializable msg, int options, ErrorHandler handler)
Send a message to one or more members in the cluster |
void | setHeartbeat(boolean enable)
Enables or disables internal heartbeat. |
void | start(int svc)
Starts up the channel. |
void | stop(int svc)
Shuts down the channel. |
See Also: (Member[], Serializable , int)
(Member[], Serializable, int, ErrorHandler)
See Also: (Member[], Serializable , int)
(Member[], Serializable, int, ErrorHandler)
int SEND_OPTIONS_DEFAULT = SEND_OPTIONS_USE_ACK;
See Also: SEND_OPTIONS_USE_ACK (Member[], Serializable , int)
(Member[], Serializable, int, ErrorHandler)
See Also: (Member[], Serializable , int)
(Member[], Serializable, int, ErrorHandler)
See Also: (Member[], Serializable , int)
(Member[], Serializable, int, ErrorHandler)
See Also: (Member[], Serializable , int)
(Member[], Serializable, int, ErrorHandler)
heartbeat()
method will be invoked when the heartbeat runs on the channelParameters: listener ChannelListener
See Also: ChannelListener Heartbeat
Parameters: interceptor ChannelInterceptor
heartbeat()
method will be invoked when the heartbeat runs on the channelParameters: listener MembershipListener
See Also: MembershipListener
Parameters: incAlive - optimization, true if you want it to calculate alive time since the membership service started.
Returns: Member
Parameters: mbr Member
Returns: Member
Returns: all members or empty array, never null
getMembers().length>0
Returns: boolean - true if there are any members automatically discovered
See Also: Channel
Parameters: listener ChannelListener
See Also: ChannelListener
Parameters: listener MembershipListener
See Also: MembershipListener
Parameters: destination Member[] - the destinations, can not be null or zero length, the reason for that
is that a membership change can occur and at that time the application is uncertain what group the message
actually got sent to. msg Serializable - the message to send, has to be serializable, or a ByteMessage
to
send a pure byte array options int - sender options, see class documentation for each interceptor that is configured in order to trigger interceptors
Returns: a unique Id that identifies the message that is sent
See Also: ByteMessage SEND_OPTIONS_USE_ACK SEND_OPTIONS_ASYNCHRONOUS SEND_OPTIONS_SYNCHRONIZED_ACK
Parameters: destination Member[] - the destinations, null or zero length means all msg ClusterMessage - the message to send options int - sender options, see class documentation handler ErrorHandler - handle errors through a callback, rather than throw it
Returns: a unique Id that identifies the message that is sent
Throws: ChannelException - if a serialization error happens.
Parameters: enable boolean - default value is implementation specific
See Also: heartbeat
Parameters: svc int value of
DEFAULT - will start all services
MBR_RX_SEQ - starts the membership receiver
MBR_TX_SEQ - starts the membership broadcaster
SND_TX_SEQ - starts the replication transmitter
SND_RX_SEQ - starts the replication receiver
Note: In order for the membership broadcaster to
transmit the correct information, it has to be started after the replication receiver.
Throws: ChannelException if a startup error occurs or the service is already started or an error occurs.
Parameters: svc int value of
DEFAULT - will shutdown all services
MBR_RX_SEQ - stops the membership receiver
MBR_TX_SEQ - stops the membership broadcaster
SND_TX_SEQ - stops the replication transmitter
SND_RX_SEQ - stops the replication receiver
Throws: ChannelException if a startup error occurs or the service is already stopped or an error occurs.