FileDocCategorySizeDatePackage
MessageDispatch15Interceptor.javaAPI DocApache Tomcat 6.0.143626Fri Jul 20 04:20:36 BST 2007org.apache.catalina.tribes.group.interceptors

MessageDispatch15Interceptor

public class MessageDispatch15Interceptor extends MessageDispatchInterceptor
Same implementation as the MessageDispatchInterceptor except is ues an atomic long for the currentSize calculation and uses a thread pool for message sending.
author
Filip Hanik
version
1.0

Fields Summary
protected AtomicLong
currentSize
protected ThreadPoolExecutor
executor
protected int
maxThreads
protected int
maxSpareThreads
protected long
keepAliveTime
protected LinkedBlockingQueue
runnablequeue
Constructors Summary
Methods Summary
public longaddAndGetCurrentSize(long inc)

        return currentSize.addAndGet(inc);
    
public booleanaddToQueue(org.apache.catalina.tribes.ChannelMessage msg, org.apache.catalina.tribes.Member[] destination, org.apache.catalina.tribes.group.InterceptorPayload payload)

        final LinkObject obj = new LinkObject(msg,destination,payload);
        Runnable r = new Runnable() {
            public void run() {
                sendAsyncData(obj);
            }
        };
        executor.execute(r);
        return true;
    
public longgetCurrentSize()


       
        return currentSize.get();
    
public longgetKeepAliveTime()

        return keepAliveTime;
    
public intgetMaxSpareThreads()

        return maxSpareThreads;
    
public intgetMaxThreads()

        return maxThreads;
    
public org.apache.catalina.tribes.transport.bio.util.LinkObjectremoveFromQueue()

        return null; //not used, thread pool contains its own queue.
    
public longsetAndGetCurrentSize(long value)

        currentSize.set(value);
        return value;
    
public voidsetKeepAliveTime(long keepAliveTime)

        this.keepAliveTime = keepAliveTime;
    
public voidsetMaxSpareThreads(int maxSpareThreads)

        this.maxSpareThreads = maxSpareThreads;
    
public voidsetMaxThreads(int maxThreads)

        this.maxThreads = maxThreads;
    
public voidstartQueue()

        if ( run ) return;
        executor = new ThreadPoolExecutor(maxSpareThreads,maxThreads,keepAliveTime,TimeUnit.MILLISECONDS,runnablequeue);
        run = true;
    
public voidstopQueue()

        run = false;
        executor.shutdownNow();
        setAndGetCurrentSize(0);
        runnablequeue.clear();