based on the maxKeepAliveRequests.
- Author:
- Jeanfrancois Arcand
KEEP_ALIVE_RULE
public static final int KEEP_ALIVE_RULE
- See Also:
- Constant Field Values
keepAliveCounts
protected ConcurrentHashMap<SelectionKey,Integer> keepAliveCounts
- Placeholder for keep-alive count monitoring.
maxKeepAliveRequests
protected int maxKeepAliveRequests
- Maximum number of requests in a single transaction.
pipelineStat
protected PipelineStatistic pipelineStat
- The
PipelineStatistic
objects used when gathering statistics.
KeepAliveCountManager
public KeepAliveCountManager()
- Default constructor.
initPipeline
public void initPipeline()
- Init the
Pipeline
by initializing the required
WorkerThread
.
startPipeline
public void startPipeline()
- Start the
Pipeline
and all associated
WorkerThread
stopPipeline
public void stopPipeline()
- Stop the
Pipeline
and all associated
WorkerThread
addTask
public void addTask(Task task)
- Add an object to this pipeline
getTask
public Task getTask()
- Return a
SelectionKey
object available in the pipeline.
All Threads will synchronize on that method
size
public int size()
- Returns the number of tasks in this
Pipeline
.
- Returns:
- Number of tasks in this
Pipeline
.
getWaitingThread
public int getWaitingThread()
- Return the number of waiting threads.
setMaxThreads
public void setMaxThreads(int maxThreads)
- Set the number of threads used by this pipeline.
getMaxThreads
public int getMaxThreads()
- Return the number of threads used by this pipeline.
getCurrentThreadCount
public int getCurrentThreadCount()
- Return the current number of active threads.
getCurrentThreadsBusy
public int getCurrentThreadsBusy()
- Return the current number of active threads.
getMaxSpareThreads
public int getMaxSpareThreads()
- Return the maximum spare thread.
setPriority
public void setPriority(int priority)
- Set the thread priority of the
Pipeline
setName
public void setName(String name)
- Set the name of this
Pipeline
getName
public String getName()
- Return the name of this
Pipeline
- Returns:
- the name of this
Pipeline
setPort
public void setPort(int port)
- Set the port used by this
Pipeline
- Parameters:
port
- the port used by this Pipeline
setMinThreads
public void setMinThreads(int minThreads)
- Set the minimum thread this
Pipeline
will creates
when initializing.
- Parameters:
minThreads
- the minimum number of threads.
toString
public String toString()
- Overrides:
toString
in class Object
setQueueSizeInBytes
public void setQueueSizeInBytes(int maxQueueSizeInBytes)
- Set the maximum pending connection this
Pipeline
can handle.
setThreadsIncrement
public void setThreadsIncrement(int threadsIncrement)
setThreadsTimeout
public void setThreadsTimeout(int threadsTimeout)
getMinSpareThreads
public int getMinSpareThreads()
- Return the minimum spare thread.
setMinSpareThreads
public void setMinSpareThreads(int minSpareThreads)
- Set the minimum space thread this
Pipeline
can handle.
trap
public boolean trap(SelectionKey key)
- Monitor keep-alive request count for the given connection.
- Returns:
- true if the request can be processed, false if the maximun
number of requests has been reached.
untrap
public void untrap(SelectionKey key)
- Stop monitoring keep-alive request count for the given connection.
getMaxKeepAliveRequests
public int getMaxKeepAliveRequests()
- Return the maximum number of keep-alive requests per connection.
setMaxKeepAliveRequests
public void setMaxKeepAliveRequests(int maxKeepAliveRequests)
- Set the maximum number of Keep-Alive requests that we will
honor per connection. A value < 0 will disabled the keep-alive mechanism.
setKeepAliveTimeoutInSeconds
public void setKeepAliveTimeoutInSeconds(int keepAliveTimeout)
- Sets the number of seconds before a keep-alive connection that has
been idle times out and is closed.
- Parameters:
keepAliveTimeout
- Keep-alive timeout in number of seconds
getKeepAliveTimeoutInSeconds
public int getKeepAliveTimeoutInSeconds()
- Gets the number of seconds before a keep-alive connection that has
been idle times out and is closed.
- Returns:
- Keep-alive timeout in number of seconds
dropConnection
public boolean dropConnection()
- Return
true
if we need to close the connection just after
the first request.
setPipelineStatistic
public void setPipelineStatistic(PipelineStatistic pipelineStatistic)
- Set the
PipelineStatistic
object used
to gather statistic;
getPipelineStatistic
public PipelineStatistic getPipelineStatistic()
- Return the
PipelineStatistic
object used
to gather statistic;
interruptThread
public boolean interruptThread(long threadId)
- Interrupt the
Thread
using it thread id
Copyright © 2010 SUN Microsystems. All Rights Reserved.