org.apache.catalina.cluster.util
Class FastQueue

java.lang.Object
  extended byorg.apache.catalina.cluster.util.FastQueue
All Implemented Interfaces:
IQueue

public class FastQueue
extends java.lang.Object
implements IQueue

A fast queue that remover thread lock the adder thread.
Limit the queue length when you have strange producer thread problemes. FIXME add i18n support to log messages

Version:
$Id: FastQueue.java 939539 2010-04-30 01:31:33Z kkolinko $
Author:
Rainer Jung, Peter Rossbach

Constructor Summary
FastQueue()
          Generate Queue SingleRemoveSynchronizedAddLock and set add and wait Timeouts
 
Method Summary
 boolean add(java.lang.String key, java.lang.Object data)
          Add new data to the queue
 long getAddCounter()
           
 long getAddErrorCounter()
           
 long getAddWait()
           
 long getAddWaitTimeout()
          get current add wait timeout
 long getAvgSize()
          Avg queue size
 long getAvgSizeSample()
           
 int getMaxQueueLength()
          get Max Queue length
 int getMaxSize()
           
 int getMaxSizeSample()
           
 long getRemoveCounter()
           
 long getRemoveErrorCounter()
           
 long getRemoveWait()
           
 long getRemoveWaitTimeout()
          get current remove wait timeout
 long getSample()
           
 int getSampleInterval()
           
 int getSize()
           
 boolean isCheckLock()
           
 boolean isDoStats()
           
 boolean isEnabled()
           
 boolean isTimeWait()
           
 LinkObject remove()
          remove the complete queued object list
 void resetStatistics()
          reset all stats data
 void setAddCounter(long counter)
           
 void setAddErrorCounter(long counter)
           
 void setAddWait(long wait)
           
 void setAddWaitTimeout(long timeout)
          Set add wait timeout (default 10000 msec)
 void setCheckLock(boolean checkLock)
           
 void setDoStats(boolean doStats)
           
 void setEnabled(boolean enable)
           
 void setMaxQueueLength(int length)
           
 void setMaxSize(int size)
           
 void setMaxSizeSample(int size)
           
 void setRemoveCounter(long counter)
           
 void setRemoveErrorCounter(long counter)
           
 void setRemoveWait(long wait)
           
 void setRemoveWaitTimeout(long timeout)
          set remove wait timeout ( default 30000 msec)
 void setSampleInterval(int interval)
           
 void setTimeWait(boolean timeWait)
           
 void start()
          start queuing
 void stop()
          start queuing
 void unlockAdd()
          unlock queue for next add
 void unlockRemove()
          unlock queue for next remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastQueue

public FastQueue()
Generate Queue SingleRemoveSynchronizedAddLock and set add and wait Timeouts

Method Detail

getAddWaitTimeout

public long getAddWaitTimeout()
get current add wait timeout

Returns:
current wait timeout

setAddWaitTimeout

public void setAddWaitTimeout(long timeout)
Set add wait timeout (default 10000 msec)

Parameters:
timeout -

getRemoveWaitTimeout

public long getRemoveWaitTimeout()
get current remove wait timeout

Returns:
The timeout

setRemoveWaitTimeout

public void setRemoveWaitTimeout(long timeout)
set remove wait timeout ( default 30000 msec)

Parameters:
timeout -

getMaxQueueLength

public int getMaxQueueLength()
get Max Queue length

Specified by:
getMaxQueueLength in interface IQueue
See Also:
IQueue.getMaxQueueLength()

setMaxQueueLength

public void setMaxQueueLength(int length)
Specified by:
setMaxQueueLength in interface IQueue

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(boolean enable)

isCheckLock

public boolean isCheckLock()
Returns:
Returns the checkLock.

setCheckLock

public void setCheckLock(boolean checkLock)
Parameters:
checkLock - The checkLock to set.

isDoStats

public boolean isDoStats()
Returns:
Returns the doStats.

setDoStats

public void setDoStats(boolean doStats)
Parameters:
doStats - The doStats to set.

isTimeWait

public boolean isTimeWait()
Returns:
Returns the timeWait.

setTimeWait

public void setTimeWait(boolean timeWait)
Parameters:
timeWait - The timeWait to set.

getSampleInterval

public int getSampleInterval()

setSampleInterval

public void setSampleInterval(int interval)

getAddCounter

public long getAddCounter()

setAddCounter

public void setAddCounter(long counter)

getAddErrorCounter

public long getAddErrorCounter()

setAddErrorCounter

public void setAddErrorCounter(long counter)

getRemoveCounter

public long getRemoveCounter()

setRemoveCounter

public void setRemoveCounter(long counter)

getRemoveErrorCounter

public long getRemoveErrorCounter()

setRemoveErrorCounter

public void setRemoveErrorCounter(long counter)

getAddWait

public long getAddWait()

setAddWait

public void setAddWait(long wait)

getRemoveWait

public long getRemoveWait()

setRemoveWait

public void setRemoveWait(long wait)

getMaxSize

public int getMaxSize()
Returns:
The max size

setMaxSize

public void setMaxSize(int size)
Parameters:
size -

getAvgSize

public long getAvgSize()
Avg queue size

Returns:
The average queue size

resetStatistics

public void resetStatistics()
reset all stats data


unlockAdd

public void unlockAdd()
unlock queue for next add


unlockRemove

public void unlockRemove()
unlock queue for next remove


start

public void start()
start queuing

Specified by:
start in interface IQueue

stop

public void stop()
start queuing

Specified by:
stop in interface IQueue

getSample

public long getSample()

getMaxSizeSample

public int getMaxSizeSample()

setMaxSizeSample

public void setMaxSizeSample(int size)

getAvgSizeSample

public long getAvgSizeSample()

getSize

public int getSize()

add

public boolean add(java.lang.String key,
                   java.lang.Object data)
Add new data to the queue

Specified by:
add in interface IQueue
See Also:
FIXME extract some method

remove

public LinkObject remove()
remove the complete queued object list

Specified by:
remove in interface IQueue
See Also:
FIXME extract some method


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