Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Licensed to the Apache Software Foundation (ASF) under one or more
   *  contributor license agreements.  See the NOTICE file distributed with
   *  this work for additional information regarding copyright ownership.
   *  The ASF licenses this file to You under the Apache License, Version 2.0
   *  (the "License"); you may not use this file except in compliance with
   *  the License.  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
  *
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
 
 package org.apache.coyote;
 
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(s):
Costin Manolache
 
 public class RequestInfo  {
     RequestGroupInfo global=null;
 
     // ----------------------------------------------------------- Constructors
 
     public RequestInfoRequest req) {
         this.=req;
     }
 
     public RequestGroupInfo getGlobalProcessor() {
         return ;
     }
     
     public void setGlobalProcessor(RequestGroupInfo global) {
         ifglobal != null) {
             this.=global;
             global.addRequestProcessorthis );
         } else {
             if (this. != null) {
                 this..removeRequestProcessorthis ); 
                 this. = null;
             }
         }
     }
 
 
     // ----------------------------------------------------- Instance Variables
     Request req;
     Response res;
     int stage = .;
     ObjectName rpName;
 
     // -------------------- Information about the current request  -----------
     // This is usefull for long-running requests only
 
     public String getMethod() {
         return .method().toString();
     }
 
     public String getCurrentUri() {
         return .requestURI().toString();
     }
 
     public String getCurrentQueryString() {
         return .queryString().toString();
     }
 
     public String getProtocol() {
         return .protocol().toString();
     }
 
     public String getVirtualHost() {
         return .serverName().toString();
     }
 
     public int getServerPort() {
         return .getServerPort();
     }
 
     public String getRemoteAddr() {
         return .remoteAddr().toString();
    }
    public int getContentLength() {
        return .getContentLength();
    }
    public long getRequestBytesReceived() {
        return .getBytesRead();
    }
    public long getRequestBytesSent() {
        return .getResponse().getBytesWritten();
    }
    public long getRequestProcessingTime() {
        if ( getStage() == .... ) return 0;
        else return (System.currentTimeMillis() - .getStartTime());
    }
    // -------------------- Statistical data  --------------------
    // Collected at the end of each request.
    private long bytesSent;
    private long bytesReceived;
    // Total time = divide by requestCount to get average.
    private long processingTime;
    // The longest response time for a request
    private long maxTime;
    // URI of the request that took maxTime
    private String maxRequestUri;
    private int requestCount;
    // number of response codes >= 400
    private int errorCount;
    
    //the time of the last request
    private long lastRequestProcessingTime = 0;


    
Called by the processor before recycling the request. It'll collect statistic information.
    void updateCounters() {
        +=.getBytesRead();
        ++;
        if.getResponse().getStatus() >=400 )
            ++;
        long t0=.getStartTime();
        long t1=System.currentTimeMillis();
        long time=t1-t0;
        this. = time;
        +=time;
        if < time ) {
            =time;
            =.requestURI().toString();
        }
    }
    public int getStage() {
        return ;
    }
    public void setStage(int stage) {
        this. = stage;
    }
    public long getBytesSent() {
        return ;
    }
    public void setBytesSent(long bytesSent) {
        this. = bytesSent;
    }
    public long getBytesReceived() {
        return ;
    }
    public void setBytesReceived(long bytesReceived) {
        this. = bytesReceived;
    }
    public long getProcessingTime() {
        return ;
    }
    public void setProcessingTime(long processingTime) {
        this. = processingTime;
    }
    public long getMaxTime() {
        return ;
    }
    public void setMaxTime(long maxTime) {
        this. = maxTime;
    }
    public String getMaxRequestUri() {
        return ;
    }
    public void setMaxRequestUri(String maxRequestUri) {
        this. = maxRequestUri;
    }
    public int getRequestCount() {
        return ;
    }
    public void setRequestCount(int requestCount) {
        this. = requestCount;
    }
    public int getErrorCount() {
        return ;
    }
    public void setErrorCount(int errorCount) {
        this. = errorCount;
    }
    public String getWorkerThreadName() {
        return ;
    }
    public ObjectName getRpName() {
        return ;
    }
    public long getLastRequestProcessingTime() {
        return ;
    }
    public void setWorkerThreadName(String workerThreadName) {
        this. = workerThreadName;
    }
    public void setRpName(ObjectName rpName) {
        this. = rpName;
    }
    public void setLastRequestProcessingTime(long lastRequestProcessingTime) {
        this. = lastRequestProcessingTime;
    }
New to GrepCode? Check out our FAQ X