public class GroupChannel extends ChannelInterceptorBase implements ManagedChannel, JmxChannel, GroupChannelMBean
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<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 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<MembershipListener> |
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
|
protected static StringManager |
sm |
optionFlag
DEFAULT, 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() |
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 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 |
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 |
start(int svc)
Starts the channel.
|
void |
stop(int svc)
Stops the channel.
|
fireInterceptorEvent, getChannel, getLocalMember, getMember, getMembers, getNext, getOptionFlag, getPrevious, hasMembers, okToProcess, sendMessage, setChannel, setNext, setOptionFlag, setPrevious
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLocalMember, getMember, getMembers, getSendOptionsAsString, getSendOptionValue, hasMembers, parseSendOptions
getLocalMember, getMembers, hasMembers
protected static final StringManager sm
protected 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 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
public GroupChannel()
public void addInterceptor(ChannelInterceptor interceptor)
channel.addInterceptor(A);
channel.addInterceptor(C);
channel.addInterceptor(B);
A -> C -> B
Channel -> A -> C -> B -> ChannelCoordinator
addInterceptor
in interface Channel
interceptor
- ChannelInterceptorBasepublic void heartbeat()
channel.setHeartbeat(false)
heartbeat
in interface Channel
heartbeat
in interface ChannelInterceptor
heartbeat
in interface Heartbeat
heartbeat
in class ChannelInterceptorBase
Channel.setHeartbeat(boolean)
public UniqueId send(Member[] destination, Serializable msg, int options) throws ChannelException
send
in interface Channel
send
in interface GroupChannelMBean
destination
- 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 messageChannel
public UniqueId send(Member[] destination, Serializable msg, int options, ErrorHandler handler) throws ChannelException
Channel
send
in interface Channel
send
in interface GroupChannelMBean
destination
- 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 messageChannel
public void messageReceived(ChannelMessage msg)
messageReceived
in interface ChannelInterceptor
messageReceived
in class ChannelInterceptorBase
msg
- 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 MembershipListener
memberAdded
in class ChannelInterceptorBase
member
- Member - the new memberpublic void memberDisappeared(Member member)
memberDisappeared
in interface MembershipListener
memberDisappeared
in class ChannelInterceptorBase
member
- Member - the member that left or crashedMember.SHUTDOWN_PAYLOAD
protected 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 Channel
start
in interface ChannelInterceptor
start
in interface GroupChannelMBean
start
in class ChannelInterceptorBase
svc
- int - what service to startChannelException
- Start errorChannel.start(int)
public void stop(int svc) throws ChannelException
stop
in interface Channel
stop
in interface ChannelInterceptor
stop
in interface GroupChannelMBean
stop
in class ChannelInterceptorBase
svc
- intChannelException
- Stop errorChannel.stop(int)
public ChannelInterceptor getFirstInterceptor()
public ChannelReceiver getChannelReceiver()
getChannelReceiver
in interface ManagedChannel
ChannelReceiver
public ChannelSender getChannelSender()
getChannelSender
in interface ManagedChannel
ChannelSender
public MembershipService getMembershipService()
getMembershipService
in interface ManagedChannel
MembershipService
public void setChannelReceiver(ChannelReceiver clusterReceiver)
setChannelReceiver
in interface ManagedChannel
clusterReceiver
- ChannelReceiverChannelReceiver
public void setChannelSender(ChannelSender clusterSender)
setChannelSender
in interface ManagedChannel
clusterSender
- ChannelSenderChannelSender
public void setMembershipService(MembershipService membershipService)
setMembershipService
in interface ManagedChannel
membershipService
- MembershipServiceMembershipService
public void addMembershipListener(MembershipListener membershipListener)
addMembershipListener
in interface Channel
addMembershipListener
in interface GroupChannelMBean
membershipListener
- MembershipListenerMembershipListener
public void removeMembershipListener(MembershipListener membershipListener)
removeMembershipListener
in interface Channel
removeMembershipListener
in interface GroupChannelMBean
membershipListener
- MembershipListenerMembershipListener
public void addChannelListener(ChannelListener channelListener)
addChannelListener
in interface Channel
addChannelListener
in interface GroupChannelMBean
channelListener
- ChannelListenerChannelListener
,
Heartbeat
public void removeChannelListener(ChannelListener channelListener)
removeChannelListener
in interface Channel
removeChannelListener
in interface GroupChannelMBean
channelListener
- ChannelListenerChannelListener
public Iterator<ChannelInterceptor> getInterceptors()
getInterceptors
in interface ManagedChannel
Channel.addInterceptor(ChannelInterceptor)
public void setOptionCheck(boolean optionCheck)
optionCheck
- booleanpublic void setHeartbeatSleeptime(long heartbeatSleeptime)
getHeartbeat()==true
heartbeatSleeptime
- 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 Channel
heartbeat
- booleanChannel.heartbeat()
public boolean getOptionCheck()
getOptionCheck
in interface GroupChannelMBean
setOptionCheck(boolean)
public boolean getHeartbeat()
getHeartbeat
in interface GroupChannelMBean
setHeartbeat(boolean)
public long getHeartbeatSleeptime()
Channel.heartbeat()
getHeartbeatSleeptime
in interface GroupChannelMBean
public String getName()
Channel
public void setName(String name)
Channel
public boolean isJmxEnabled()
JmxChannel
isJmxEnabled
in interface JmxChannel
public void setJmxEnabled(boolean jmxEnabled)
JmxChannel
setJmxEnabled
in interface JmxChannel
jmxEnabled
- set to true if this channel should be registered with jmx.public String getJmxDomain()
JmxChannel
getJmxDomain
in interface JmxChannel
public void setJmxDomain(String jmxDomain)
JmxChannel
setJmxDomain
in interface JmxChannel
jmxDomain
- The jmx domain which this channel should be registered.public String getJmxPrefix()
JmxChannel
getJmxPrefix
in interface JmxChannel
public void setJmxPrefix(String jmxPrefix)
JmxChannel
setJmxPrefix
in interface JmxChannel
jmxPrefix
- The jmx prefix which will be used with channel ObjectName.public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister
in interface MBeanRegistration
Exception
public void postRegister(Boolean registrationDone)
postRegister
in interface MBeanRegistration
public void preDeregister() throws Exception
preDeregister
in interface MBeanRegistration
Exception
public void postDeregister()
postDeregister
in interface MBeanRegistration
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.