1 23 package com.sun.enterprise.admin.wsmgmt.stats.impl; 24 25 import com.sun.enterprise.admin.wsmgmt.stats.spi.WebServiceEndpointStatsProvider; 26 27 32 public class WebServiceEndpointStatsProviderImpl 33 implements WebServiceEndpointStatsProvider 34 { 35 36 public WebServiceEndpointStatsProviderImpl() { 37 faultActor = faultString = faultCode = clientHost = clientUser = null; 38 responseSize = requestSize = totalFaults = 39 totalSuccess = totalAuthFailures = totalAuthSuccess = 0; 40 responseTime = avgResponseTime = 41 totalResponseTime = maxResponseTime = (long)0; 42 resetTime = System.currentTimeMillis(); 43 minResponseTime = -1; 44 throughput = 0.0; 45 46 } 47 48 50 public void setRequestTimeStamp(long t , String host, String user, 51 int rSize) { 52 53 enterTime = t; 54 reqSize = rSize; 55 cHost = host; 56 cUser = user; 57 } 58 59 public void setSuccess(int resSize, long exitTime, long respTime) { 60 61 precheck(); 62 63 responseTime = respTime; 64 calculateResponseTimes (responseTime); 65 clientHost = cHost; 66 clientUser = cUser; 67 requestSize = reqSize; 68 responseSize = resSize; 69 totalSuccess++; 70 totalAuthSuccess++; 71 72 faultCode = faultString = faultActor = null; 74 75 cleanup(); 76 } 77 78 void calculateResponseTimes (long curRespTime) { 79 if ( curRespTime > maxResponseTime) { 80 maxResponseTime = curRespTime; 81 } 82 83 if (minResponseTime < 0 ) { 84 minResponseTime = curRespTime; 85 } else if ( curRespTime < minResponseTime) { 86 minResponseTime = curRespTime; 87 } 88 totalResponseTime += curRespTime; 89 } 90 91 public void setFault(int resSize, long exitTime, long rTime, String fCode, String fString, 92 String fActor) { 93 precheck(); 94 95 responseTime = rTime; 96 calculateResponseTimes (responseTime); 97 clientHost = cHost; 98 clientUser = cUser; 99 requestSize = reqSize; 100 responseSize = resSize; 101 totalFaults++; 102 totalAuthSuccess++; 103 104 faultCode = fCode; 106 faultString = fString; 107 faultActor = fActor; 108 109 cleanup(); 110 111 } 112 113 public void setAuthFailure (long t) { 114 115 117 clientHost = cHost; 118 clientUser = cUser; 119 requestSize = reqSize; 120 totalFaults++; 121 totalAuthFailures++; 122 123 faultCode = faultString = faultActor = null; 125 126 cleanup(); 127 128 } 129 130 public void precheck() { 131 if ( enterTime == 0 ) { 132 throw new RuntimeException ( 133 "Request method should also update the request stats"); 134 } 135 136 138 } 139 140 public void cleanup() { 141 enterTime = 0; 142 cHost = cUser = null; 143 } 144 145 public void reset() { 146 faultActor = faultString = faultCode = clientHost = clientUser = null; 147 responseSize = requestSize = totalFaults = 148 totalSuccess = totalAuthFailures = totalAuthSuccess = 0; 149 responseTime = totalResponseTime = maxResponseTime = 150 avgResponseTime = (long) 0; 151 resetTime = System.currentTimeMillis(); 152 throughput = 0.0; 153 minResponseTime = -1; 154 } 155 156 public long getLastResetTime() { 158 return resetTime; 159 } 160 161 public long getAverageResponseTime() { 162 int totalInv = totalSuccess + totalFaults; 163 if (totalInv == 0 ) { 164 return (long)0; 165 } else { 166 return totalResponseTime/ (totalInv); 167 } 168 } 169 170 public long getMinResponseTime() { 171 if (minResponseTime < 0 ) { 172 return 0; 173 } else { 174 return minResponseTime; 175 } 176 } 177 178 public long getMaxResponseTime() { 179 return maxResponseTime; 180 } 181 182 public long getResponseTime() { 183 return responseTime; 184 } 185 186 public int getTotalFailures() { 187 return totalFaults; 188 } 189 190 public int getTotalSuccesses() { 191 return totalSuccess; 192 } 193 194 public int getTotalAuthFailures() { 195 return totalAuthFailures; 196 } 197 198 public int getTotalAuthSuccesses() { 199 return totalAuthSuccess; 200 } 201 202 public double getThroughput() { 203 long avgRespTime = getAverageResponseTime(); 204 double dValue = avgRespTime; 205 if ( avgRespTime == 0 ) { 206 return 0; 207 } else { 208 return 1000/dValue; 209 } 210 } 211 212 public int getRequestSize() { 213 return requestSize; 214 } 215 216 public int getResponseSize() { 217 return responseSize; 218 } 219 220 public String getClientHost() { 221 return clientHost; 222 } 223 224 public String getClientUser() { 225 return clientUser; 226 } 227 228 public String getFaultCode() { 229 return faultCode; 230 } 231 232 public String getFaultString() { 233 return faultString; 234 } 235 236 public String getFaultActor() { 237 return faultActor; 238 } 239 240 242 String faultActor, faultString, faultCode, clientHost, clientUser; 243 244 int responseSize, requestSize, totalFaults, totalSuccess, 245 totalAuthFailures, totalAuthSuccess; 246 long responseTime, totalResponseTime, avgResponseTime, minResponseTime, 247 maxResponseTime; 248 double throughput; 249 250 253 long enterTime =0; 254 long resetTime =0; 255 int reqSize = 0; 256 String cHost = null, cUser = null; 257 } 258 | Popular Tags |