Apache Tomcat 6.0.43

org.apache.catalina.tribes.group.interceptors
Class MessageDispatchInterceptor

java.lang.Object
  extended by org.apache.catalina.tribes.group.ChannelInterceptorBase
      extended by org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor
All Implemented Interfaces:
java.lang.Runnable, ChannelInterceptor, Heartbeat, MembershipListener
Direct Known Subclasses:
MessageDispatch15Interceptor

public class MessageDispatchInterceptor
extends ChannelInterceptorBase
implements java.lang.Runnable

The message dispatcher is a way to enable asynchronous communication through a channel. The dispatcher will look for the Channel.SEND_OPTIONS_ASYNCHRONOUS flag to be set, if it is, it will queue the message for delivery and immediately return to the sender.

Version:
1.0
Author:
Filip Hanik

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.catalina.tribes.ChannelInterceptor
ChannelInterceptor.InterceptorEvent
 
Field Summary
protected  boolean alwaysSend
           
protected  long currentSize
           
protected static Log log
           
protected  long maxQueueSize
           
protected  java.lang.Thread msgDispatchThread
           
protected  FastQueue queue
           
protected  boolean run
           
protected  boolean useDeepClone
           
 
Fields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
optionFlag
 
Constructor Summary
MessageDispatchInterceptor()
           
 
Method Summary
 long addAndGetCurrentSize(long inc)
           
 boolean addToQueue(ChannelMessage msg, Member[] destination, InterceptorPayload payload)
           
 long getCurrentSize()
           
 long getMaxQueueSize()
           
 boolean getUseDeepClone()
           
 boolean isAlwaysSend()
           
 LinkObject removeFromQueue()
           
 void run()
           
protected  LinkObject sendAsyncData(LinkObject link)
           
 void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
          The sendMessage method is called when a message is being sent to one more destinations.
 void setAlwaysSend(boolean alwaysSend)
           
 long setAndGetCurrentSize(long value)
           
 void setMaxQueueSize(long maxQueueSize)
           
 void setOptionFlag(int flag)
          Sets the option flag
 void setUseDeepClone(boolean useDeepClone)
           
 void start(int svc)
          Starts up the channel.
 void startQueue()
           
 void stop(int svc)
          Shuts down the channel.
 void stopQueue()
           
 
Methods inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
accept, fireInterceptorEvent, getLocalMember, getMember, getMembers, getNext, getOptionFlag, getPrevious, hasMembers, heartbeat, memberAdded, memberDisappeared, messageReceived, okToProcess, setNext, setPrevious
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Log log

maxQueueSize

protected long maxQueueSize

queue

protected FastQueue queue

run

protected boolean run

msgDispatchThread

protected java.lang.Thread msgDispatchThread

currentSize

protected long currentSize

useDeepClone

protected boolean useDeepClone

alwaysSend

protected boolean alwaysSend
Constructor Detail

MessageDispatchInterceptor

public MessageDispatchInterceptor()
Method Detail

sendMessage

public void sendMessage(Member[] destination,
                        ChannelMessage msg,
                        InterceptorPayload payload)
                 throws ChannelException
Description copied from interface: ChannelInterceptor
The 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)
Alternatively the interceptor can stop the message from being sent by not invoking getNext().sendMessage(destination,msg,payload)
If the message is to be sent asynchronous the application can be notified of completion and errors by passing in an error handler attached to a payload object.
The ChannelMessage.getAddress contains Channel.getLocalMember, and can be overwritten to simulate a message sent from another node.

Specified by:
sendMessage in interface ChannelInterceptor
Overrides:
sendMessage in class ChannelInterceptorBase
Parameters:
destination - Member[] - the destination for this message
msg - ChannelMessage - the message to be sent
payload - InterceptorPayload - the payload, carrying an error handler and future useful data, can be null
Throws:
ChannelException
See Also:
ErrorHandler, InterceptorPayload

addToQueue

public boolean addToQueue(ChannelMessage msg,
                          Member[] destination,
                          InterceptorPayload payload)

removeFromQueue

public LinkObject removeFromQueue()

startQueue

public void startQueue()

stopQueue

public void stopQueue()

setOptionFlag

public void setOptionFlag(int flag)
Description copied from interface: ChannelInterceptor
Sets the option flag

Specified by:
setOptionFlag in interface ChannelInterceptor
Overrides:
setOptionFlag in class ChannelInterceptorBase
Parameters:
flag - int
See Also:
ChannelInterceptor.getOptionFlag()

setMaxQueueSize

public void setMaxQueueSize(long maxQueueSize)

setUseDeepClone

public void setUseDeepClone(boolean useDeepClone)

getMaxQueueSize

public long getMaxQueueSize()

getUseDeepClone

public boolean getUseDeepClone()

getCurrentSize

public long getCurrentSize()

addAndGetCurrentSize

public long addAndGetCurrentSize(long inc)

setAndGetCurrentSize

public long setAndGetCurrentSize(long value)

start

public void start(int svc)
           throws ChannelException
Description copied from class: ChannelInterceptorBase
Starts up the channel. This can be called multiple times for individual services to start The svc parameter can be the logical or value of any constants

Specified by:
start in interface ChannelInterceptor
Overrides:
start in class ChannelInterceptorBase
Parameters:
svc - int value of
DEFAULT - will start all services
MBR_RX_SEQ - starts the membership receiver
MBR_TX_SEQ - starts the membership broadcaster
SND_TX_SEQ - starts the replication transmitter
SND_RX_SEQ - starts the replication receiver
Throws:
ChannelException - if a startup error occurs or the service is already started.
See Also:
Channel

stop

public void stop(int svc)
          throws ChannelException
Description copied from class: ChannelInterceptorBase
Shuts down the channel. This can be called multiple times for individual services to shutdown The svc parameter can be the logical or value of any constants

Specified by:
stop in interface ChannelInterceptor
Overrides:
stop in class ChannelInterceptorBase
Parameters:
svc - int value of
DEFAULT - will shutdown all services
MBR_RX_SEQ - stops the membership receiver
MBR_TX_SEQ - stops the membership broadcaster
SND_TX_SEQ - stops the replication transmitter
SND_RX_SEQ - stops the replication receiver
Throws:
ChannelException - if a startup error occurs or the service is already started.
See Also:
Channel

run

public void run()
Specified by:
run in interface java.lang.Runnable

sendAsyncData

protected LinkObject sendAsyncData(LinkObject link)

isAlwaysSend

public boolean isAlwaysSend()

setAlwaysSend

public void setAlwaysSend(boolean alwaysSend)

Apache Tomcat 6.0.43

Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.