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.GroupChannelModifier and Type | Field and Description |
---|---|
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_MULTICAST
Send options.
|
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_UDP
Send options.
|
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. |
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
static final int DEFAULT
start(int)
,
stop(int)
,
Constant Field Valuesstatic final int SND_RX_SEQ
start(int)
,
stop(int)
,
Constant Field Valuesstatic final int SND_TX_SEQ
start(int)
,
stop(int)
,
Constant Field Valuesstatic final int MBR_RX_SEQ
start(int)
,
stop(int)
,
Constant Field Valuesstatic final int MBR_TX_SEQ
start(int)
,
stop(int)
,
Constant Field Valuesstatic final int SEND_OPTIONS_BYTE_MESSAGE
static final int SEND_OPTIONS_USE_ACK
static final int SEND_OPTIONS_SYNCHRONIZED_ACK
static final int SEND_OPTIONS_ASYNCHRONOUS
static final int SEND_OPTIONS_SECURE
static final int SEND_OPTIONS_UDP
static final int SEND_OPTIONS_MULTICAST
static final int SEND_OPTIONS_DEFAULT
int SEND_OPTIONS_DEFAULT = SEND_OPTIONS_USE_ACK;
void addInterceptor(ChannelInterceptor interceptor)
interceptor
- ChannelInterceptorvoid start(int svc) throws ChannelException
svc
- int value of ChannelException
- if a startup error occurs or the service is already started or an error occurs.void stop(int svc) throws ChannelException
svc
- int value of ChannelException
- if a startup error occurs or the service is already stopped or an error occurs.UniqueId send(Member[] destination, Serializable msg, int options) throws ChannelException
destination
- Member[] - the destinations, cannot 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 arrayoptions
- int - sender options, see class documentation for each interceptor that is configured in order to trigger interceptorsChannelException
- if a serialization error happens.ByteMessage
,
SEND_OPTIONS_USE_ACK
,
SEND_OPTIONS_ASYNCHRONOUS
,
SEND_OPTIONS_SYNCHRONIZED_ACK
UniqueId send(Member[] destination, Serializable msg, int options, ErrorHandler handler) throws ChannelException
destination
- Member[] - the destinations, null or zero length means allmsg
- ClusterMessage - the message to sendoptions
- int - sender options, see class documentationhandler
- ErrorHandler - handle errors through a callback, rather than throw itChannelException
- - if a serialization error happens.void heartbeat()
setHeartbeat(boolean)
void setHeartbeat(boolean enable)
enable
- boolean - default value is implementation specificheartbeat()
void addMembershipListener(MembershipListener listener)
heartbeat()
method will be invoked when the heartbeat runs on the channellistener
- MembershipListenerMembershipListener
void addChannelListener(ChannelListener listener)
heartbeat()
method will be invoked when the heartbeat runs on the channellistener
- ChannelListenerChannelListener
,
Heartbeat
void removeMembershipListener(MembershipListener listener)
listener
- MembershipListenerMembershipListener
void removeChannelListener(ChannelListener listener)
listener
- ChannelListenerChannelListener
boolean hasMembers()
getMembers().length > 0
Member[] getMembers()
Member getLocalMember(boolean incAlive)
incAlive
- - optimization, true if you want it to calculate alive time
since the membership service started.Member getMember(Member mbr)
mbr
- MemberCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.