1 17 18 package org.apache.coyote; 19 20 21 35 public class RequestInfo { 36 RequestGroupInfo global=null; 37 38 40 public RequestInfo( Request req) { 41 this.req=req; 42 } 43 44 public RequestGroupInfo getGlobalProcessor() { 45 return global; 46 } 47 48 public void setGlobalProcessor(RequestGroupInfo global) { 49 if( global != null) { 50 this.global=global; 51 global.addRequestProcessor( this ); 52 } else { 53 if (this.global != null) { 54 this.global.removeRequestProcessor( this ); 55 this.global = null; 56 } 57 } 58 } 59 60 61 Request req; 63 Response res; 64 int stage = Constants.STAGE_NEW; 65 66 69 public String getMethod() { 70 return req.method().toString(); 71 } 72 73 public String getCurrentUri() { 74 return req.requestURI().toString(); 75 } 76 77 public String getCurrentQueryString() { 78 return req.queryString().toString(); 79 } 80 81 public String getProtocol() { 82 return req.protocol().toString(); 83 } 84 85 public String getVirtualHost() { 86 return req.serverName().toString(); 87 } 88 89 public int getServerPort() { 90 return req.getServerPort(); 91 } 92 93 public String getRemoteAddr() { 94 req.action(ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE, null); 95 return req.remoteAddr().toString(); 96 } 97 98 public int getContentLength() { 99 return req.getContentLength(); 100 } 101 102 public long getRequestBytesReceived() { 103 return req.getBytesRead(); 104 } 105 106 public long getRequestBytesSent() { 107 return req.getResponse().getBytesWritten(); 108 } 109 110 public long getRequestProcessingTime() { 111 return (System.currentTimeMillis() - req.getStartTime()); 112 } 113 114 private long bytesSent; 117 private long bytesReceived; 118 119 private long processingTime; 121 private long maxTime; 123 private String maxRequestUri; 125 126 private int requestCount; 127 private int errorCount; 129 130 131 134 void updateCounters() { 135 bytesReceived+=req.getBytesRead(); 136 bytesSent+=req.getResponse().getBytesWritten(); 137 138 requestCount++; 139 if( req.getResponse().getStatus() >=400 ) 140 errorCount++; 141 long t0=req.getStartTime(); 142 long t1=System.currentTimeMillis(); 143 long time=t1-t0; 144 processingTime+=time; 145 if( maxTime < time ) { 146 maxTime=time; 147 maxRequestUri=req.requestURI().toString(); 148 } 149 } 150 151 public int getStage() { 152 return stage; 153 } 154 155 public void setStage(int stage) { 156 this.stage = stage; 157 } 158 159 public long getBytesSent() { 160 return bytesSent; 161 } 162 163 public void setBytesSent(long bytesSent) { 164 this.bytesSent = bytesSent; 165 } 166 167 public long getBytesReceived() { 168 return bytesReceived; 169 } 170 171 public void setBytesReceived(long bytesReceived) { 172 this.bytesReceived = bytesReceived; 173 } 174 175 public long getProcessingTime() { 176 return processingTime; 177 } 178 179 public void setProcessingTime(long processingTime) { 180 this.processingTime = processingTime; 181 } 182 183 public long getMaxTime() { 184 return maxTime; 185 } 186 187 public void setMaxTime(long maxTime) { 188 this.maxTime = maxTime; 189 } 190 191 public String getMaxRequestUri() { 192 return maxRequestUri; 193 } 194 195 public void setMaxRequestUri(String maxRequestUri) { 196 this.maxRequestUri = maxRequestUri; 197 } 198 199 public int getRequestCount() { 200 return requestCount; 201 } 202 203 public void setRequestCount(int requestCount) { 204 this.requestCount = requestCount; 205 } 206 207 public int getErrorCount() { 208 return errorCount; 209 } 210 211 public void setErrorCount(int errorCount) { 212 this.errorCount = errorCount; 213 } 214 215 216 } 217 | Popular Tags |