public class GroupChannel extends ChannelInterceptorBase implements ManagedChannel, JmxChannel, GroupChannelMBean
| Modifier and Type | Class and Description |
|---|---|
class |
GroupChannel.HeartbeatRunnable
Title: Internal heartbeat runnable
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<ChannelListener> |
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 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 ScheduledFuture<?> |
heartbeatFuture
Internal heartbeat future
|
protected long |
heartbeatSleeptime
If
heartbeat == true then how often do we want this
heartbeat to run. |
protected ChannelInterceptor |
interceptors
The first interceptor in the interceptor stack.
|
protected List<MembershipListener> |
membershipListeners
A list of membership listeners that subscribe to membership announcements
|
protected ScheduledFuture<?> |
monitorFuture |
protected String |
name
the name of this channel.
|
protected boolean |
optionCheck
If set to true, the GroupChannel will check to make sure that
|
protected boolean |
ownExecutor |
protected static StringManager |
sm |
protected ScheduledExecutorService |
utilityExecutor
Executor service.
|
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
|
String |
getJmxDomain()
Return the jmx domain which this channel is registered.
|
String |
getJmxPrefix()
Return the jmx prefix which will be used with channel ObjectName.
|
MembershipService |
getMembershipService()
Returns the membership service component
|
String |
getName()
Return the name of this channel.
|
boolean |
getOptionCheck() |
ScheduledExecutorService |
getUtilityExecutor()
Return executor that can be used for utility tasks.
|
void |
heartbeat()
Sends a heartbeat through the interceptor stack.
|
boolean |
isJmxEnabled()
If set to true, this channel is registered with jmx.
|
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 |
postDeregister() |
void |
postRegister(Boolean registrationDone) |
void |
preDeregister() |
ObjectName |
preRegister(MBeanServer server,
ObjectName name) |
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 an 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 |
setJmxDomain(String jmxDomain)
Set the jmx domain which this channel should be registered.
|
void |
setJmxEnabled(boolean jmxEnabled)
If set to true, this channel is registered with jmx.
|
void |
setJmxPrefix(String jmxPrefix)
Set the jmx prefix which will be used with channel ObjectName.
|
void |
setMembershipService(MembershipService membershipService)
Sets the membership component
|
void |
setName(String name)
Set the name of this channel
|
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 |
setUtilityExecutor(ScheduledExecutorService utilityExecutor)
Set the executor that can be used for utility tasks.
|
void |
start(int svc)
Starts the channel.
|
protected void |
startHeartbeat() |
void |
stop(int svc)
Stops the channel.
|
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, getSendOptionsAsString, getSendOptionValue, hasMembers, parseSendOptionsgetLocalMember, getMembers, hasMembersprotected static final StringManager sm
protected boolean heartbeat
protected long heartbeatSleeptime
heartbeat == true then how often do we want this
heartbeat to run. The default value is 5000 milliseconds.protected ScheduledFuture<?> heartbeatFuture
protected ScheduledFuture<?> monitorFuture
protected final ChannelCoordinator coordinator
ChannelCoordinator coordinates the bottom layer components:protected ChannelInterceptor interceptors
protected final List<MembershipListener> membershipListeners
protected final List<ChannelListener> channelListeners
protected boolean optionCheck
protected String name
protected ScheduledExecutorService utilityExecutor
protected boolean ownExecutor
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 Channelsend in interface GroupChannelMBeandestination - Member[] - destination.length > 0msg - Serializable - the message to sendoptions - 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 Channelsend in interface GroupChannelMBeandestination - Member[] - destination.length > 0msg - Serializable - the message to sendoptions - 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
ChannelException - Cluster errorprotected void checkOptionFlags()
throws ChannelException
ChannelException - Error with option flagpublic void start(int svc)
throws ChannelException
start in interface Channelstart in interface ChannelInterceptorstart in interface GroupChannelMBeanstart in class ChannelInterceptorBasesvc - int - what service to startChannelException - Start errorChannel.start(int)protected void startHeartbeat()
public void stop(int svc)
throws ChannelException
stop in interface Channelstop in interface ChannelInterceptorstop in interface GroupChannelMBeanstop in class ChannelInterceptorBasesvc - intChannelException - Stop errorChannel.stop(int)public ChannelInterceptor getFirstInterceptor()
public ScheduledExecutorService getUtilityExecutor()
ChannelgetUtilityExecutor in interface Channelpublic void setUtilityExecutor(ScheduledExecutorService utilityExecutor)
ChannelsetUtilityExecutor in interface ChannelutilityExecutor - the executorpublic 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 ChanneladdMembershipListener in interface GroupChannelMBeanmembershipListener - MembershipListenerMembershipListenerpublic void removeMembershipListener(MembershipListener membershipListener)
removeMembershipListener in interface ChannelremoveMembershipListener in interface GroupChannelMBeanmembershipListener - MembershipListenerMembershipListenerpublic void addChannelListener(ChannelListener channelListener)
addChannelListener in interface ChanneladdChannelListener in interface GroupChannelMBeanchannelListener - ChannelListenerChannelListener,
Heartbeatpublic void removeChannelListener(ChannelListener channelListener)
removeChannelListener in interface ChannelremoveChannelListener in interface GroupChannelMBeanchannelListener - 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()
getOptionCheck in interface GroupChannelMBeansetOptionCheck(boolean)public boolean getHeartbeat()
getHeartbeat in interface GroupChannelMBeansetHeartbeat(boolean)public long getHeartbeatSleeptime()
Channel.heartbeat()getHeartbeatSleeptime in interface GroupChannelMBeanpublic String getName()
Channelpublic void setName(String name)
Channelpublic boolean isJmxEnabled()
JmxChannelisJmxEnabled in interface JmxChannelpublic void setJmxEnabled(boolean jmxEnabled)
JmxChannelsetJmxEnabled in interface JmxChanneljmxEnabled - set to true if this channel should be registered with jmx.public String getJmxDomain()
JmxChannelgetJmxDomain in interface JmxChannelpublic void setJmxDomain(String jmxDomain)
JmxChannelsetJmxDomain in interface JmxChanneljmxDomain - The jmx domain which this channel should be registered.public String getJmxPrefix()
JmxChannelgetJmxPrefix in interface JmxChannelpublic void setJmxPrefix(String jmxPrefix)
JmxChannelsetJmxPrefix in interface JmxChanneljmxPrefix - The jmx prefix which will be used with channel ObjectName.public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister in interface MBeanRegistrationExceptionpublic void postRegister(Boolean registrationDone)
postRegister in interface MBeanRegistrationpublic void preDeregister()
throws Exception
preDeregister in interface MBeanRegistrationExceptionpublic void postDeregister()
postDeregister in interface MBeanRegistrationCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.