Fields Summary |
---|
private int | portThe port of which we gather statistics |
private boolean | startedIs this object started? |
private int | maxQueueSizeInBytesMaximum pending connection before refusing requests. |
private int | totalCountThe total number of connections queued during the lifetime of the
pipeline |
private int | peakCountThe largest number of connections that have been in the pipeline
simultaneouly |
private int | overflowCountTotal number of pipeline overflows |
private ScheduledThreadPoolExecutor | countAverageExecutorThe Thread Pool used when gathering count statistic. |
private Statistic | lastMinuteStatAverage number of connection queued in that last 1 minute |
private Statistic | lastFiveMinuteStatAverage number of connection queued in that last 5 minute |
private Statistic | lastFifteenMinuteStatAverage number of connection queued in that last 15 minute |
private ConcurrentHashMap | statsPlaceholder to gather statistics. |
private Pipeline | processorPipelineThe pipelines whose stats are being collected |
private Future[] | futuresFuture instance in case we need to stop this object. |
private int | totalAcceptCountTotal number of connections that have been accepted. |
Methods Summary |
---|
public boolean | gather(int queueLength)Gather Pipeline statistic.
if ( queueLength == maxQueueSizeInBytes){
overflowCount++;
return false;
}
if ( queueLength > 0 )
totalCount++;
// Track peak of this Pipeline
if (queueLength > peakCount) {
peakCount = queueLength;
}
return true;
|
private int | getCountAverage(int minutes)Gets the average number of connection queued in the last
minutes minutes.
Statistic stat = stats.get((minutes * 60));
return (stat == null ? 0 : stat.average());
|
public int | getCountOverflows()Total number of pipeline overflow
return overflowCount;
|
public int | getCountQueued()Gets the number of connections currently in the queue
int size = 0;
if (processorPipeline != null) {
size += processorPipeline.size();
}
return size;
|
public int | getCountQueued15MinuteAverage()Gets the average number of connections queued in the last 15 minutes
return getCountAverage(15);
|
public int | getCountQueued1MinuteAverage()Gets the average number of connections queued in the last 1 minute
return getCountAverage(1);
|
public int | getCountQueued5MinuteAverage()Gets the average number of connections queued in the last 5 minutes
return getCountAverage(5);
|
public int | getCountTotalConnections()Gets the total number of connections that have been accepted.
return totalAcceptCount;
|
public int | getCountTotalQueued()Gets the total number of connections that have been queued.
A given connection may be queued multiple times, so
counttotalqueued may be greater than or equal to
counttotalconnections .
return totalCount;
|
public int | getMaxQueued()Gets the maximum size of the connection queue
return maxQueueSizeInBytes;
|
public int | getPeakQueued()Gets the largest number of connections that were in the queue
simultaneously.
return peakCount;
|
public int | getQueueSizeInBytes()Get the maximum pending connection this Pipeline
can handle.
return maxQueueSizeInBytes;
|
public int | getTicksTotalQueued()Gets the total number of ticks that connections have spent in the
queue.
A tick is a system-dependent unit of time.
return -1; // Not supported
|
public void | incrementTotalAcceptCount()
totalAcceptCount++;
|
void | setProcessorPipeline(Pipeline processorPipeline)
this.processorPipeline = processorPipeline;
|
public void | setQueueSizeInBytes(int maxQueueSizeInBytesCount)Set the maximum pending connection this Pipeline
can handle.
this.maxQueueSizeInBytes = maxQueueSizeInBytesCount;
|
public void | start()Start gathering statistics.
if ( started ) return;
futures[0] = countAverageExecutor.scheduleAtFixedRate(lastMinuteStat, 1 ,
lastMinuteStat.getSeconds(), TimeUnit.SECONDS);
futures[1] = countAverageExecutor.scheduleAtFixedRate(lastFiveMinuteStat, 1 ,
lastFiveMinuteStat.getSeconds(), TimeUnit.SECONDS);
futures[2] = countAverageExecutor.scheduleAtFixedRate(lastFifteenMinuteStat, 1 ,
lastFifteenMinuteStat.getSeconds(), TimeUnit.SECONDS);
stats.put(lastMinuteStat.getSeconds(), lastMinuteStat);
stats.put(lastFiveMinuteStat.getSeconds(), lastFiveMinuteStat);
stats.put(lastFifteenMinuteStat.getSeconds(), lastFifteenMinuteStat);
started = true;
|
public void | stop()Stop gathering statistics.
if ( !started ) return;
for (Future future: futures){
future.cancel(true);
}
stats.clear();
started = false;
|