Fields Summary |
---|
public static final int | KEEP_ALIVE_RULE |
private int | maxThreadsThe maximum number of Thread |
private int | priorityThe Thread Priority |
private int | portThe port used. |
private String | nameThe name of this Pipeline |
private boolean | isStartedHas the pipeline already started |
private int | firstReadTimeout |
private int | keepAliveTimeoutInSeconds |
protected ConcurrentHashMap | keepAliveCountsPlaceholder for keep-alive count monitoring. |
protected int | maxKeepAliveRequestsMaximum number of requests in a single transaction. |
protected PipelineStatistic | pipelineStatThe PipelineStatistic objects used when gathering statistics. |
private KeepAliveStats | keepAliveStatsThe stats object used to gather statistics. |
Methods Summary |
---|
public void | addTask(Task task)Add an object to this pipeline
throw new UnsupportedOperationException();
|
public boolean | dropConnection()Return true if we need to close the connection just after
the first request.
return (keepAliveTimeoutInSeconds == 0
|| firstReadTimeout == 0 || maxKeepAliveRequests == 0);
|
public int | getCurrentThreadCount()Return the current number of active threads.
return 1;
|
public int | getCurrentThreadsBusy()Return the current number of active threads.
return 1;
|
public int | getKeepAliveTimeoutInSeconds()Gets the number of seconds before a keep-alive connection that has
been idle times out and is closed.
return keepAliveTimeoutInSeconds;
|
public int | getMaxKeepAliveRequests()Return the maximum number of keep-alive requests per connection.
return maxKeepAliveRequests;
|
public int | getMaxSpareThreads()Return the maximum spare thread.
return 0;
|
public int | getMaxThreads()Return the number of threads used by this pipeline.
return maxThreads;
|
public int | getMinSpareThreads()Return the minimum spare thread.
throw new UnsupportedOperationException();
|
public java.lang.String | getName()Return the name of this Pipeline
return name+port;
|
public PipelineStatistic | getPipelineStatistic()Return the PipelineStatistic object used
to gather statistic;
return pipelineStat;
|
public Task | getTask()Return a SelectionKey object available in the pipeline.
All Threads will synchronize on that method
return null;
|
public int | getWaitingThread()Return the number of waiting threads.
return 0;
|
public void | initPipeline()Init the Pipeline by initializing the required
WorkerThread .
if (isStarted){
return;
}
isStarted = true;
keepAliveCounts = new ConcurrentHashMap<SelectionKey,Integer>();
|
public boolean | interruptThread(long threadId)Interrupt the Thread using it thread id
return false;
|
public boolean | isKeepAlive(java.nio.channels.SelectionKey key)Is the SelectionKey already added to the keep-alive mechanism.
return (keepAliveCounts.get(key) != null);
|
void | setKeepAliveStats(KeepAliveStats keepAliveStats)Sets the given KeepAliveStats, which is responsible for storing
keep-alive statistics.
this.keepAliveStats = keepAliveStats;
|
public void | setKeepAliveTimeoutInSeconds(int keepAliveTimeout)Sets the number of seconds before a keep-alive connection that has
been idle times out and is closed.
this.keepAliveTimeoutInSeconds = keepAliveTimeout;
|
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.
this.maxKeepAliveRequests = maxKeepAliveRequests;
|
public void | setMaxThreads(int maxThreads)Set the number of threads used by this pipeline.
this.maxThreads = maxThreads;
|
public void | setMinSpareThreads(int minSpareThreads)Set the minimum space thread this Pipeline can handle.
throw new UnsupportedOperationException();
|
public void | setMinThreads(int minThreads)Set the minimum thread this Pipeline will creates
when initializing.
throw new UnsupportedOperationException();
|
public void | setName(java.lang.String name)Set the name of this Pipeline
this.name = name;
|
public void | setPipelineStatistic(PipelineStatistic pipelineStatistic)Set the PipelineStatistic object used
to gather statistic;
this.pipelineStat = pipelineStatistic;
|
public void | setPort(int port)Set the port used by this Pipeline
this.port = port;
|
public void | setPriority(int priority)Set the thread priority of the Pipeline
this.priority = priority;
|
public void | setQueueSizeInBytes(int maxQueueSizeInBytes)Set the maximum pending connection this Pipeline
can handle.
throw new UnsupportedOperationException();
|
public void | setThreadsIncrement(int threadsIncrement)
throw new UnsupportedOperationException();
|
public void | setThreadsTimeout(int threadsTimeout)
this.firstReadTimeout = threadsTimeout;
|
public int | size()Returns the number of tasks in this Pipeline .
return 0;
|
public void | startPipeline()Start the Pipeline and all associated
WorkerThread
if (isStarted){
return;
}
; // Do nothing
|
public void | stopPipeline()Stop the Pipeline and all associated
WorkerThread
if (!isStarted){
return;
}
isStarted = false;
keepAliveCounts.clear();
|
public java.lang.String | toString()
return "name: " + name + " maxThreads: " + maxThreads ;
|
public boolean | trap(java.nio.channels.SelectionKey key)Monitor keep-alive request count for the given connection.
if ( maxKeepAliveRequests == -1) return true;
Integer count = keepAliveCounts.get(key);
if ( count == null ){
count = 0;
if (keepAliveStats != null) {
keepAliveStats.incrementCountConnections();
}
}
if ((count+1) > maxKeepAliveRequests){
if (keepAliveStats != null) {
keepAliveStats.incrementCountRefusals();
}
return false;
}
count++;
keepAliveCounts.put(key, count);
if (keepAliveStats != null) {
keepAliveStats.incrementCountHits();
}
return true;
|
public void | untrap(java.nio.channels.SelectionKey key)Stop monitoring keep-alive request count for the given connection.
if ( maxKeepAliveRequests == -1) return;
keepAliveCounts.remove(key);
|