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 java.util.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 java.util.List<MembershipListener> |
membershipListeners
A list of membership listeners that subscribe to membership announcements
|
protected java.lang.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() |
java.util.Iterator<ChannelInterceptor> |
getInterceptors()
Returns an iterator of all the interceptors in this stack
|
MembershipService |
getMembershipService()
Returns the membership service component
|
java.lang.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,
java.io.Serializable msg,
int options)
Send a message to the destinations specified
|
UniqueId |
send(Member[] destination,
java.io.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(java.lang.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
|
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, 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 java.util.List<MembershipListener> membershipListeners
protected final java.util.List<ChannelListener> channelListeners
protected boolean optionCheck
protected java.lang.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, java.io.Serializable msg, int options) throws ChannelException
send
in interface Channel
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, java.io.Serializable msg, int options, ErrorHandler handler) throws ChannelException
Channel
send
in interface Channel
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
protected void checkOptionFlags() throws ChannelException
ChannelException
public void start(int svc) throws ChannelException
start
in interface Channel
start
in interface ChannelInterceptor
start
in class ChannelInterceptorBase
svc
- int - what service to startChannelException
Channel.start(int)
public void stop(int svc) throws ChannelException
stop
in interface Channel
stop
in interface ChannelInterceptor
stop
in class ChannelInterceptorBase
svc
- intChannelException
Channel.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
membershipListener
- MembershipListenerMembershipListener
public void removeMembershipListener(MembershipListener membershipListener)
removeMembershipListener
in interface Channel
membershipListener
- MembershipListenerMembershipListener
public void addChannelListener(ChannelListener channelListener)
addChannelListener
in interface Channel
channelListener
- ChannelListenerChannelListener
,
Heartbeat
public void removeChannelListener(ChannelListener channelListener)
removeChannelListener
in interface Channel
channelListener
- ChannelListenerChannelListener
public java.util.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()
setOptionCheck(boolean)
public boolean getHeartbeat()
setHeartbeat(boolean)
public long getHeartbeatSleeptime()
Channel.heartbeat()
public java.lang.String getName()
public void setName(java.lang.String name)
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.