com.planetj.servlet.filter.compression
Class CompressingFilterStats

java.lang.Object
  extended by com.planetj.servlet.filter.compression.CompressingFilterStats
All Implemented Interfaces:
java.io.Serializable

public final class CompressingFilterStats
extends java.lang.Object
implements java.io.Serializable

This class provides runtime statistics on the performance of CompressingFilter. If stats are enabled, then an instance of this object will be available in the servlet context under the key STATS_KEY. It can be retrieved and used like so:

 ServletContext ctx = ...;
 // in a JSP, "ctx" is already available as the "application" variable
 CompressingFilterStats stats = (CompressingFilterStats) ctx.getAttribute(CompressingFilterStats.STATS_KEY);
 double ratio = stats.getAverageCompressionRatio();
 ...
 

Since:
1.1
Author:
Sean Owen
See Also:
Serialized Form

Nested Class Summary
(package private)  class CompressingFilterStats.InputStatsCallback
           
(package private)  class CompressingFilterStats.OutputStatsCallback
           
(package private) static class CompressingFilterStats.StatsField
          A simple enum used by CompressingFilterStats.OutputStatsCallback to select a field in this class.
 
Field Summary
private  int numRequestsCompressed
           
private  int numResponsesCompressed
           
private  long requestCompressedBytes
           
private  CompressingFilterStats.InputStatsCallback requestCompressedStatsCallback
           
private  long requestInputBytes
           
private  CompressingFilterStats.InputStatsCallback requestInputStatsCallback
           
private  long responseCompressedBytes
           
private  CompressingFilterStats.OutputStatsCallback responseCompressedStatsCallback
           
private  long responseInputBytes
           
private  CompressingFilterStats.OutputStatsCallback responseInputStatsCallback
           
private static long serialVersionUID
           
static java.lang.String STATS_KEY
          Key under which a CompressingFilterStats object can be found in the servlet context.
private  int totalRequestsNotCompressed
           
private  int totalResponsesNotCompressed
           
 
Constructor Summary
CompressingFilterStats()
           
 
Method Summary
 double getAverageCompressionRatio()
          Deprecated. use getResponseAverageCompressionRatio()
 long getCompressedBytes()
          Deprecated. use getResponseCompressedBytes()
 long getInputBytes()
          Deprecated. use getResponseInputBytes()
(package private)  CompressingFilterStats.InputStatsCallback getInputStatsCallback(CompressingFilterStats.StatsField field)
           
 int getNumRequestsCompressed()
           
 int getNumResponsesCompressed()
           
(package private)  CompressingFilterStats.OutputStatsCallback getOutputStatsCallback(CompressingFilterStats.StatsField field)
           
 double getRequestAverageCompressionRatio()
           
 long getRequestCompressedBytes()
           
 long getRequestInputBytes()
           
 double getResponseAverageCompressionRatio()
           
 long getResponseCompressedBytes()
           
 long getResponseInputBytes()
           
 int getTotalRequestsNotCompressed()
           
 int getTotalResponsesNotCompressed()
           
(package private)  void incrementNumRequestsCompressed()
           
(package private)  void incrementNumResponsesCompressed()
           
(package private)  void incrementTotalRequestsNotCompressed()
           
(package private)  void incrementTotalResponsesNotCompressed()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

STATS_KEY

public static final java.lang.String STATS_KEY
Key under which a CompressingFilterStats object can be found in the servlet context.

See Also:
Constant Field Values

numResponsesCompressed

private int numResponsesCompressed

totalResponsesNotCompressed

private int totalResponsesNotCompressed

responseInputBytes

private long responseInputBytes

responseCompressedBytes

private long responseCompressedBytes

numRequestsCompressed

private int numRequestsCompressed

totalRequestsNotCompressed

private int totalRequestsNotCompressed

requestInputBytes

private long requestInputBytes

requestCompressedBytes

private long requestCompressedBytes

responseInputStatsCallback

private final CompressingFilterStats.OutputStatsCallback responseInputStatsCallback

responseCompressedStatsCallback

private final CompressingFilterStats.OutputStatsCallback responseCompressedStatsCallback

requestInputStatsCallback

private final CompressingFilterStats.InputStatsCallback requestInputStatsCallback

requestCompressedStatsCallback

private final CompressingFilterStats.InputStatsCallback requestCompressedStatsCallback
Constructor Detail

CompressingFilterStats

CompressingFilterStats()
Method Detail

getNumResponsesCompressed

public int getNumResponsesCompressed()
Returns:
the number of responses which CompressingFilter has compressed.

incrementNumResponsesCompressed

void incrementNumResponsesCompressed()

getTotalResponsesNotCompressed

public int getTotalResponsesNotCompressed()
Returns:
the number of responses which CompressingFilter has processed but not compressed for some reason (compression not supported by the browser, for example).

incrementTotalResponsesNotCompressed

void incrementTotalResponsesNotCompressed()

getInputBytes

@Deprecated
public long getInputBytes()
Deprecated. use getResponseInputBytes()


getResponseInputBytes

public long getResponseInputBytes()
Returns:
total number of bytes written to the CompressingFilter in responses.

getCompressedBytes

@Deprecated
public long getCompressedBytes()
Deprecated. use getResponseCompressedBytes()


getResponseCompressedBytes

public long getResponseCompressedBytes()
Returns:
total number of compressed bytes written by the CompressingFilter to the client in responses.

getAverageCompressionRatio

@Deprecated
public double getAverageCompressionRatio()
Deprecated. use getResponseAverageCompressionRatio()


getResponseAverageCompressionRatio

public double getResponseAverageCompressionRatio()
Returns:
average compression ratio (input bytes / compressed bytes) in responses, or 0 if nothing has yet been compressed. Note that this is (typically) greater than 1, not less than 1.

getNumRequestsCompressed

public int getNumRequestsCompressed()
Returns:
the number of requests which CompressingFilter has compressed.
Since:
1.6

incrementNumRequestsCompressed

void incrementNumRequestsCompressed()

getTotalRequestsNotCompressed

public int getTotalRequestsNotCompressed()
Returns:
the number of requests which CompressingFilter has processed but not compressed for some reason (no compression requested, for example).
Since:
1.6

incrementTotalRequestsNotCompressed

void incrementTotalRequestsNotCompressed()

getRequestInputBytes

public long getRequestInputBytes()
Returns:
total number of bytes written to the CompressingFilter in requests.
Since:
1.6

getRequestCompressedBytes

public long getRequestCompressedBytes()
Returns:
total number of compressed bytes written by the CompressingFilter to the client in requests.
Since:
1.6

getRequestAverageCompressionRatio

public double getRequestAverageCompressionRatio()
Returns:
average compression ratio (input bytes / compressed bytes) in requests, or 0 if nothing has yet been compressed. Note that this is (typically) greater than 1, not less than 1.
Since:
1.6

toString

@NotNull
public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a summary of the stats in String form

getOutputStatsCallback

@NotNull
CompressingFilterStats.OutputStatsCallback getOutputStatsCallback(CompressingFilterStats.StatsField field)

getInputStatsCallback

@NotNull
CompressingFilterStats.InputStatsCallback getInputStatsCallback(CompressingFilterStats.StatsField field)