FileDocCategorySizeDatePackage
RequestInfo.javaAPI DocGlassfish v2 API14470Fri May 04 22:32:42 BST 2007org.apache.coyote

RequestInfo

public class RequestInfo extends Object
Structure holding the Request and Response objects. It also holds statistical informations about request processing and provide management informations about the requests beeing processed. Each thread uses a Request/Response pair that is recycled on each request. This object provides a place to collect global low-level statistics - without having to deal with synchronization ( since each thread will have it's own RequestProcessorMX ). TODO: Request notifications will be registered here.
author
Costin Manolache

Fields Summary
private RequestGroupInfo
global
private Request
req
private int
stage
private long
bytesSent
private long
bytesReceived
private long
processingTime
private long
maxTime
private String
maxRequestUri
private int
requestCount
private int
errorCount
private long
count2xx
private long
count3xx
private long
count4xx
private long
count5xx
private long
countOther
private long
count200
private long
count302
private long
count304
private long
count400
private long
count401
private long
count403
private long
count404
private long
count503
private long
workerThreadID
private long
requestCompletionTime
private String
lastURI
private String
lastMethod
private long
lastCompletionTime
Constructors Summary
public RequestInfo(Request req)
Constructor

    // END SJSAS 6338793

          
        
        this.req=req;
    
Methods Summary
public longgetBytesReceived()

        return bytesReceived;
    
public longgetBytesSent()

        return bytesSent;
    
public intgetContentLength()

        return req.getContentLength();
    
public longgetCount200()

        return count200;
    
public longgetCount2xx()

        return count2xx;
    
public longgetCount302()

        return count302;
    
public longgetCount304()

        return count304;
    
public longgetCount3xx()

        return count3xx;
    
public longgetCount400()

        return count400;
    
public longgetCount401()

        return count401;
    
public longgetCount403()

        return count403;
    
public longgetCount404()

        return count404;
    
public longgetCount4xx()

        return count4xx;
    
public longgetCount503()

        return count503;
    
public longgetCount5xx()

        return count5xx;
    
public longgetCountOther()

        return countOther;
    
public java.lang.StringgetCurrentQueryString()

        return req.queryString().toString();
    
public java.lang.StringgetCurrentUri()

        return req.requestURI().toString();
    
public intgetErrorCount()

        return errorCount;
    
public RequestGroupInfogetGlobalProcessor()

        return global;
    
public longgetLastRequestCompletionTime()
Gets the time when the last request was completed.

return
The time when the last request was completed.

        return lastCompletionTime;
    
public java.lang.StringgetLastRequestMethod()
Gets the HTTP method of the last request serviced.

return
The HTTP method of the last request serviced

        return lastMethod;
    
public java.lang.StringgetLastRequestURI()
Gets the URI of the last request serviced.

return
The URI of the last request serviced

        return lastURI;
    
public java.lang.StringgetMaxRequestUri()

        return maxRequestUri;
    
public longgetMaxTime()

        return maxTime;
    
public java.lang.StringgetMethod()

        return req.method().toString();
    
public longgetProcessingTime()

        return processingTime;
    
public java.lang.StringgetProtocol()

        return req.protocol().toString();
    
public java.lang.StringgetRemoteAddr()

        req.action(ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE, null);
        return req.remoteAddr().toString();
    
public longgetRequestBytesReceived()

        return req.getBytesRead();
    
public longgetRequestBytesSent()

        return req.getResponse().getBytesWritten();
    
public longgetRequestCompletionTime()
Gets the time taken to complete the request associated with this RequestInfo.

        return requestCompletionTime;
    
public intgetRequestCount()

        return requestCount;
    
public longgetRequestProcessingTime()

        return (System.currentTimeMillis() - req.getStartTime());
    
public intgetServerPort()

        return req.getServerPort();
    
public intgetStage()

        return stage;
    
public java.lang.StringgetVirtualHost()

        return req.serverName().toString();
    
public longgetWorkerThreadID()
Gets the worker thread ID which is processing the request associated with this RequestInfo. Return 0 if no thread ID has been associated.

return
The worker thread id

        return workerThreadID;
    
public voidreset()
Resets this RequestInfo.

        setBytesSent(0);
        setBytesReceived(0);
        setProcessingTime(0);
        setMaxTime(0);
        setMaxRequestUri(null);
        setRequestCount(0);
        setErrorCount(0);
        setCount2xx(0);
        setCount3xx(0);
        setCount4xx(0);
        setCount5xx(0);
        setCountOther(0);
        setCount200(0);
        setCount302(0);
        setCount304(0);
        setCount400(0);
        setCount401(0);
        setCount403(0);
        setCount404(0);
        setCount503(0);
        setWorkerThreadID(0);
        setRequestCompletionTime(0);
        // START SJSAS 6338793
        lastMethod = null;
        lastURI = null;
        lastCompletionTime = 0;
        // END SJSAS 6338793
    
public voidsetBytesReceived(long bytesReceived)

        this.bytesReceived = bytesReceived;
    
public voidsetBytesSent(long bytesSent)

        this.bytesSent = bytesSent;
    
public voidsetCount200(long count200)

        this.count200 = count200;
    
public voidsetCount2xx(long count2xx)

        this.count2xx = count2xx;
    
public voidsetCount302(long count302)

        this.count302 = count302;
    
public voidsetCount304(long count304)

        this.count304 = count304;
    
public voidsetCount3xx(long count3xx)

        this.count3xx = count3xx;
    
public voidsetCount400(long count400)

        this.count400 = count400;
    
public voidsetCount401(long count401)

        this.count401 = count401;
    
public voidsetCount403(long count403)

        this.count403 = count403;
    
public voidsetCount404(long count404)

        this.count404 = count404;
    
public voidsetCount4xx(long count4xx)

        this.count4xx = count4xx;
    
public voidsetCount503(long count503)

        this.count503 = count503;
    
public voidsetCount5xx(long count5xx)

        this.count5xx = count5xx;
    
public voidsetCountOther(long countOther)

        this.countOther = countOther;
    
public voidsetErrorCount(int errorCount)

        this.errorCount = errorCount;
    
public voidsetGlobalProcessor(RequestGroupInfo global)

        if( global != null) {
            this.global=global;
            global.addRequestProcessor( this );
        } else {
            if (this.global != null) {
                this.global.removeRequestProcessor( this ); 
                this.global = null;
            }
        }
    
public voidsetMaxRequestUri(java.lang.String maxRequestUri)

        this.maxRequestUri = maxRequestUri;
    
public voidsetMaxTime(long maxTime)

        this.maxTime = maxTime;
    
public voidsetProcessingTime(long processingTime)

        this.processingTime = processingTime;
    
public voidsetRequestCompletionTime(long completionTime)
Sets the time taken to complete the request associated with this RequestInfo.

        this.requestCompletionTime = completionTime;
    
public voidsetRequestCount(int requestCount)

        this.requestCount = requestCount;
    
public voidsetStage(int stage)

        this.stage = stage;
    
public voidsetWorkerThreadID(long workerThreadID)
Sets the worker thread ID responsible for processing the request associated with this RequestInfo.

param
workerThread The worker thread is

        this.workerThreadID = workerThreadID;
    
voidupdateCounters()
Called by the processor before recycling the request. It'll collect statistic information.

        bytesReceived+=req.getBytesRead();
        bytesSent+=req.getResponse().getBytesWritten();

        requestCount++;

        int responseStatus = req.getResponse().getStatus();

        // START S1AS
        if (responseStatus >= 200 && responseStatus < 299) {
            // 2xx
            count2xx++;
            if (responseStatus == 200) {
                count200++;
            }
        } else if (responseStatus >= 300 && responseStatus < 399) {
            // 3xx
            count3xx++;
            if (responseStatus == 302) {
                count302++;
            } else if (responseStatus == 304) {
                count304++;
            }
        } else if (responseStatus >= 400 && responseStatus < 499) {
            // 4xx
            count4xx++;
            if (responseStatus == 400) {
                count400++;
            } else if (responseStatus == 401) {
                count401++;
            } else if (responseStatus == 403) {
                count403++;
            } else if (responseStatus == 404) {
                count404++;
            }
        } else if (responseStatus >= 500 && responseStatus < 599) {
            // 5xx
            count5xx++;
            if (responseStatus == 503) {
                count503++;
            }
        } else {
            // Other
            countOther++;
        }
        // END S1AS

        if (responseStatus >= 400) {
            errorCount++;
        }

        long t0=req.getStartTime();
        long t1=System.currentTimeMillis();

        requestCompletionTime = t1-t0;
        processingTime+=requestCompletionTime;
        if( maxTime < requestCompletionTime ) {
            maxTime=requestCompletionTime;
            maxRequestUri=req.requestURI().toString();
        }

        // START SJSAS 6338793
        lastURI = req.requestURI().toString();
        lastMethod = req.method().toString();
        lastCompletionTime = t1;
        // END SJAS 6338793