FileDocCategorySizeDatePackage
RequestInfo.javaAPI DocApache Tomcat 6.0.146503Fri Jul 20 04:20:36 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
RequestGroupInfo
global
Request
req
Response
res
int
stage
String
workerThreadName
ObjectName
rpName
private long
bytesSent
private long
bytesReceived
private long
processingTime
private long
maxTime
private String
maxRequestUri
private int
requestCount
private int
errorCount
Constructors Summary
public RequestInfo(Request req)


    // ----------------------------------------------------------- Constructors

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

        return bytesReceived;
    
public longgetBytesSent()

        return bytesSent;
    
public intgetContentLength()

        return req.getContentLength();
    
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 java.lang.StringgetMaxRequestUri()

        return maxRequestUri;
    
public longgetMaxTime()

        return maxTime;
    
public java.lang.StringgetMethod()


    // -------------------- Information about the current request  -----------
    // This is usefull for long-running requests only

       
        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 intgetRequestCount()

        return requestCount;
    
public longgetRequestProcessingTime()

        return (System.currentTimeMillis() - req.getStartTime());
    
public javax.management.ObjectNamegetRpName()

        return rpName;
    
public intgetServerPort()

        return req.getServerPort();
    
public intgetStage()

        return stage;
    
public java.lang.StringgetVirtualHost()

        return req.serverName().toString();
    
public java.lang.StringgetWorkerThreadName()

        return workerThreadName;
    
public voidsetBytesReceived(long bytesReceived)

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

        this.bytesSent = bytesSent;
    
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 voidsetRequestCount(int requestCount)

        this.requestCount = requestCount;
    
public voidsetRpName(javax.management.ObjectName rpName)

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

        this.stage = stage;
    
public voidsetWorkerThreadName(java.lang.String workerThreadName)

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

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

        requestCount++;
        if( req.getResponse().getStatus() >=400 )
            errorCount++;
        long t0=req.getStartTime();
        long t1=System.currentTimeMillis();
        long time=t1-t0;
        processingTime+=time;
        if( maxTime < time ) {
            maxTime=time;
            maxRequestUri=req.requestURI().toString();
        }