public abstract class ChannelInterceptorBase extends java.lang.Object implements ChannelInterceptor
ChannelInterceptor.InterceptorEvent
Modifier and Type | Field and Description |
---|---|
protected int |
optionFlag |
Constructor and Description |
---|
ChannelInterceptorBase() |
Modifier and Type | Method and Description |
---|---|
void |
fireInterceptorEvent(ChannelInterceptor.InterceptorEvent event) |
Channel |
getChannel()
Return the channel that is related to this interceptor
|
Member |
getLocalMember(boolean incAlive)
Return the member that represents this node.
|
Member |
getMember(Member mbr)
Intercepts the
Channel.getMember(Member) method |
Member[] |
getMembers()
Get all current cluster members
|
ChannelInterceptor |
getNext()
Retrieve the next interceptor in the list
|
int |
getOptionFlag()
An interceptor can react to a message based on a set bit on the
message options.
|
ChannelInterceptor |
getPrevious()
Retrieve the previous interceptor in the list
|
boolean |
hasMembers()
has members
|
void |
heartbeat()
The
heartbeat() method gets invoked periodically
to allow interceptors to clean up resources, time out object and
perform actions that are unrelated to sending/receiving data. |
void |
memberAdded(Member member)
A member was added to the group
|
void |
memberDisappeared(Member member)
A member was removed from the group
If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data |
void |
messageReceived(ChannelMessage msg)
the
messageReceived is invoked when a message is received. |
boolean |
okToProcess(int messageFlags) |
void |
sendMessage(Member[] destination,
ChannelMessage msg,
InterceptorPayload payload)
The
sendMessage method is called when a message is being sent to one more destinations. |
void |
setChannel(Channel channel)
Set the channel that is related to this interceptor
|
void |
setNext(ChannelInterceptor next)
Set the next interceptor in the list of interceptors
|
void |
setOptionFlag(int optionFlag)
Sets the option flag
|
void |
setPrevious(ChannelInterceptor previous)
Set the previous interceptor in the list
|
void |
start(int svc)
Starts up the channel.
|
void |
stop(int svc)
Shuts down the channel.
|
public boolean okToProcess(int messageFlags)
public final void setNext(ChannelInterceptor next)
ChannelInterceptor
setNext
in interface ChannelInterceptor
next
- ChannelInterceptorpublic final ChannelInterceptor getNext()
ChannelInterceptor
getNext
in interface ChannelInterceptor
public final void setPrevious(ChannelInterceptor previous)
ChannelInterceptor
setPrevious
in interface ChannelInterceptor
previous
- ChannelInterceptorpublic void setOptionFlag(int optionFlag)
ChannelInterceptor
setOptionFlag
in interface ChannelInterceptor
optionFlag
- intChannelInterceptor.getOptionFlag()
public final ChannelInterceptor getPrevious()
ChannelInterceptor
getPrevious
in interface ChannelInterceptor
public int getOptionFlag()
ChannelInterceptor
boolean react = (getOptionFlag() == (getOptionFlag() & ChannelMessage.getOptions()));
getOptionFlag
in interface ChannelInterceptor
ChannelMessage.getOptions()
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException
ChannelInterceptor
sendMessage
method is called when a message is being sent to one more destinations.
The interceptor can modify any of the parameters and then pass on the message down the stack by
invoking getNext().sendMessage(destination,msg,payload)
getNext().sendMessage(destination,msg,payload)
sendMessage
in interface ChannelInterceptor
destination
- Member[] - the destination for this messagemsg
- ChannelMessage - the message to be sentpayload
- InterceptorPayload - the payload, carrying an error handler and future useful data, can be nullChannelException
ErrorHandler
,
InterceptorPayload
public void messageReceived(ChannelMessage msg)
ChannelInterceptor
messageReceived
is invoked when a message is received.
ChannelMessage.getAddress()
is the sender, or the reply-to address
if it has been overwritten.messageReceived
in interface ChannelInterceptor
msg
- ChannelMessagepublic void memberAdded(Member member)
MembershipListener
memberAdded
in interface MembershipListener
member
- Member - the member that was addedpublic void memberDisappeared(Member member)
MembershipListener
memberDisappeared
in interface MembershipListener
member
- MemberMember.SHUTDOWN_PAYLOAD
public void heartbeat()
ChannelInterceptor
heartbeat()
method gets invoked periodically
to allow interceptors to clean up resources, time out object and
perform actions that are unrelated to sending/receiving data.heartbeat
in interface ChannelInterceptor
heartbeat
in interface Heartbeat
public boolean hasMembers()
hasMembers
in interface ChannelInterceptor
Channel.hasMembers()
public Member[] getMembers()
getMembers
in interface ChannelInterceptor
Channel.getMembers()
public Member getMember(Member mbr)
ChannelInterceptor
Channel.getMember(Member)
methodgetMember
in interface ChannelInterceptor
mbr
- MemberChannel.getMember(Member)
public Member getLocalMember(boolean incAlive)
getLocalMember
in interface ChannelInterceptor
incAlive
- booleanChannel.getLocalMember(boolean)
public void start(int svc) throws ChannelException
start
in interface ChannelInterceptor
svc
- int value of ChannelException
- if a startup error occurs or the service is already started.Channel
public void stop(int svc) throws ChannelException
stop
in interface ChannelInterceptor
svc
- int value of ChannelException
- if a startup error occurs or the service is already started.Channel
public void fireInterceptorEvent(ChannelInterceptor.InterceptorEvent event)
fireInterceptorEvent
in interface ChannelInterceptor
public Channel getChannel()
public void setChannel(Channel channel)
channel
- Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.