public class GroupChannel extends ChannelInterceptorBase implements ManagedChannel
| Modifier and Type | Class and Description |
|---|---|
static class |
GroupChannel.HeartbeatThread
Title: Internal heartbeat thread
Description: if
Channel.getHeartbeat()==true then a thread of this class
is created |
static class |
GroupChannel.InterceptorIterator
Title: Interceptor Iterator
Description: An iterator to loop through the interceptors in a channel
|
ChannelInterceptor.InterceptorEvent| Modifier and Type | Field and Description |
|---|---|
protected List<Object> |
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 interceptor stack.
|
protected List<Object> |
membershipListeners
A list of membership listeners that subscribe to membership announcements
|
protected String |
name
the name of this channel.
|
protected boolean |
optionCheck
If set to true, the GroupChannel will check to make sure that
|
optionFlagDEFAULT, MBR_RX_SEQ, MBR_TX_SEQ, SEND_OPTIONS_ASYNCHRONOUS, SEND_OPTIONS_BYTE_MESSAGE, SEND_OPTIONS_DEFAULT, SEND_OPTIONS_MULTICAST, SEND_OPTIONS_SECURE, SEND_OPTIONS_SYNCHRONIZED_ACK, SEND_OPTIONS_UDP, SEND_OPTIONS_USE_ACK, SND_RX_SEQ, SND_TX_SEQ| Constructor and Description |
|---|
GroupChannel()
Creates a GroupChannel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChannelListener(ChannelListener channelListener)
Adds a channel listener to the channel.
|
void |
addInterceptor(ChannelInterceptor interceptor)
Adds an interceptor to the stack for message processing
Interceptors are ordered in the way they are added. |
void |
addMembershipListener(MembershipListener membershipListener)
Adds a membership listener to the channel.
|
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 invocations of
Channel.heartbeat() |
Iterator<ChannelInterceptor> |
getInterceptors()
Returns an iterator of all the interceptors in this stack
|
MembershipService |
getMembershipService()
Returns the membership service component
|
String |
getName() |
boolean |
getOptionCheck() |
void |
heartbeat()
Sends a heartbeat through the interceptor stack.
|
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.
|
void |
removeMembershipListener(MembershipListener membershipListener)
Removes a membership listener from the channel.
|
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)
Send a message to one or more members in the cluster
|
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.
|
void |
setHeartbeatSleeptime(long heartbeatSleeptime)
Configure local heartbeat sleep time
Only used when getHeartbeat()==true |
void |
setMembershipService(MembershipService membershipService)
Sets the membership component
|
void |
setName(String name) |
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
|
accept, fireInterceptorEvent, getChannel, getLocalMember, getMember, getMembers, getNext, getOptionFlag, getPrevious, hasMembers, okToProcess, sendMessage, setChannel, setNext, setOptionFlag, setPreviousclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLocalMember, getMember, getMembers, hasMembersprotected boolean heartbeat
protected long heartbeatSleeptime
heartbeat == true then how often do we want this
heartbeat to run. default is one minuteprotected GroupChannel.HeartbeatThread hbthread
protected ChannelCoordinator coordinator
ChannelCoordinator coordinates the bottom layer components:protected ChannelInterceptor interceptors
protected List<Object> membershipListeners
protected List<Object> channelListeners
protected boolean optionCheck
protected String name
public GroupChannel()
public void addInterceptor(ChannelInterceptor interceptor)
channel.addInterceptor(A);channel.addInterceptor(C);channel.addInterceptor(B);A -> C -> BChannel -> A -> C -> B -> ChannelCoordinatoraddInterceptor in interface Channelinterceptor - ChannelInterceptorBasepublic void heartbeat()
channel.setHeartbeat(false)heartbeat in interface Channelheartbeat in interface ChannelInterceptorheartbeat in interface Heartbeatheartbeat in class ChannelInterceptorBaseChannel.setHeartbeat(boolean)public UniqueId send(Member[] destination, Serializable msg, int options) throws ChannelException
send in interface Channeldestination - Member[] - destination.length > 0msg - Serializable - the message to sendoptions - int - sender options, options can trigger guarantee levels and different interceptors to
react to the message see class documentation for the Channel object.ChannelException - - if an error occurs processing the messageChannelpublic UniqueId send(Member[] destination, Serializable msg, int options, ErrorHandler handler) throws ChannelException
Channelsend in interface Channeldestination - Member[] - destination.length > 0msg - Serializable - the message to sendoptions - 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.ChannelException - - if an error occurs processing the messageChannelpublic void messageReceived(ChannelMessage msg)
messageReceived in interface ChannelInterceptormessageReceived in class ChannelInterceptorBasemsg - ChannelMessageprotected void sendNoRpcChannelReply(RpcMessage msg, Member destination)
NoRpcChannelReply message to a membermsg - RpcMessagedestination - Member - the destination for the replypublic void memberAdded(Member member)
memberAdded in interface MembershipListenermemberAdded in class ChannelInterceptorBasemember - Member - the new memberpublic void memberDisappeared(Member member)
memberDisappeared in interface MembershipListenermemberDisappeared in class ChannelInterceptorBasemember - Member - the member that left or crashedMember.SHUTDOWN_PAYLOADprotected void setupDefaultStack()
throws ChannelException
ChannelExceptionprotected void checkOptionFlags()
throws ChannelException
ChannelExceptionpublic void start(int svc)
throws ChannelException
start in interface Channelstart in interface ChannelInterceptorstart in class ChannelInterceptorBasesvc - int - what service to startChannelExceptionChannel.start(int)public void stop(int svc)
throws ChannelException
stop in interface Channelstop in interface ChannelInterceptorstop in class ChannelInterceptorBasesvc - intChannelExceptionChannel.stop(int)public ChannelInterceptor getFirstInterceptor()
public ChannelReceiver getChannelReceiver()
getChannelReceiver in interface ManagedChannelChannelReceiverpublic ChannelSender getChannelSender()
getChannelSender in interface ManagedChannelChannelSenderpublic MembershipService getMembershipService()
getMembershipService in interface ManagedChannelMembershipServicepublic void setChannelReceiver(ChannelReceiver clusterReceiver)
setChannelReceiver in interface ManagedChannelclusterReceiver - ChannelReceiverChannelReceiverpublic void setChannelSender(ChannelSender clusterSender)
setChannelSender in interface ManagedChannelclusterSender - ChannelSenderChannelSenderpublic void setMembershipService(MembershipService membershipService)
setMembershipService in interface ManagedChannelmembershipService - MembershipServiceMembershipServicepublic void addMembershipListener(MembershipListener membershipListener)
addMembershipListener in interface ChannelmembershipListener - MembershipListenerMembershipListenerpublic void removeMembershipListener(MembershipListener membershipListener)
removeMembershipListener in interface ChannelmembershipListener - MembershipListenerMembershipListenerpublic void addChannelListener(ChannelListener channelListener)
addChannelListener in interface ChannelchannelListener - ChannelListenerChannelListener,
Heartbeatpublic void removeChannelListener(ChannelListener channelListener)
removeChannelListener in interface ChannelchannelListener - ChannelListenerChannelListenerpublic Iterator<ChannelInterceptor> getInterceptors()
getInterceptors in interface ManagedChannelChannel.addInterceptor(ChannelInterceptor)public void setOptionCheck(boolean optionCheck)
optionCheck - booleanpublic void setHeartbeatSleeptime(long heartbeatSleeptime)
getHeartbeat()==trueheartbeatSleeptime - long - time in milliseconds to sleep between heartbeatspublic void setHeartbeat(boolean heartbeat)
setHeartbeat(true) is invoked then the channel will start an internal
thread to invoke Channel.heartbeat() every getHeartbeatSleeptime millisecondssetHeartbeat in interface Channelheartbeat - booleanChannel.heartbeat()public boolean getOptionCheck()
setOptionCheck(boolean)public boolean getHeartbeat()
setHeartbeat(boolean)public long getHeartbeatSleeptime()
Channel.heartbeat()public String getName()
public void setName(String name)
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.