1 24 25 package org.objectweb.cjdbc.controller.cache; 26 27 import org.objectweb.cjdbc.common.util.Stats; 28 29 35 public class CacheStatistics 36 { 37 private Stats select; 39 private Stats hits; 40 private Stats insert; 41 private Stats update; 42 private Stats uncacheable; 43 private Stats delete; 44 private Stats unknown; 45 private Stats remove; 46 private Stats create; 47 private Stats drop; 48 49 52 public CacheStatistics() 53 { 54 select = new Stats("select"); 55 hits = new Stats("hits"); 56 insert = new Stats("insert"); 57 update = new Stats("update"); 58 uncacheable = new Stats("uncacheable"); 59 delete = new Stats("delete"); 60 unknown = new Stats("unknown"); 61 remove = new Stats("remove"); 62 create = new Stats("create"); 63 drop = new Stats("drop"); 64 } 65 66 69 public void reset() 70 { 71 select.reset(); 72 hits.reset(); 73 insert.reset(); 74 update.reset(); 75 uncacheable.reset(); 76 delete.reset(); 77 unknown.reset(); 78 remove.reset(); 79 create.reset(); 80 drop.reset(); 81 } 82 83 88 public int getCreate() 89 { 90 return create.getCount(); 91 } 92 93 98 public int getDelete() 99 { 100 return delete.getCount(); 101 } 102 103 108 public int getDrop() 109 { 110 return drop.getCount(); 111 } 112 113 118 public int getHits() 119 { 120 return hits.getCount(); 121 } 122 123 128 public int getInsert() 129 { 130 return insert.getCount(); 131 } 132 133 138 public int getRemove() 139 { 140 return remove.getCount(); 141 } 142 143 148 public int getSelect() 149 { 150 return select.getCount(); 151 } 152 153 158 public int getUnknown() 159 { 160 return unknown.getCount(); 161 } 162 163 168 public int getUpdate() 169 { 170 return update.getCount(); 171 } 172 173 178 public int getUncacheable() 179 { 180 return uncacheable.getCount(); 181 } 182 183 186 public void addCreate() 187 { 188 create.incrementCount(); 189 } 190 191 194 public void addDelete() 195 { 196 delete.incrementCount(); 197 } 198 199 202 public void addDrop() 203 { 204 drop.incrementCount(); 205 } 206 207 210 public void addHits() 211 { 212 hits.incrementCount(); 213 } 214 215 218 public void addInsert() 219 { 220 insert.incrementCount(); 221 } 222 223 226 public void addRemove() 227 { 228 remove.incrementCount(); 229 } 230 231 234 public void addSelect() 235 { 236 select.incrementCount(); 237 } 238 239 242 public void addUnknown() 243 { 244 unknown.incrementCount(); 245 } 246 247 250 public void addUpdate() 251 { 252 update.incrementCount(); 253 } 254 255 258 public void addUncacheable() 259 { 260 uncacheable.incrementCount(); 261 } 262 263 269 public String [] getCacheStatsData() 270 { 271 String [] stats = new String [11]; 272 stats[0] = "" + getSelect(); 273 stats[1] = "" + getHits(); 274 stats[2] = "" + getInsert(); 275 stats[3] = "" + getUpdate(); 276 stats[4] = "" + getUncacheable(); 277 stats[5] = "" + getDelete(); 278 stats[6] = "" + getUnknown(); 279 stats[7] = "" + getRemove(); 280 stats[8] = "" + getCreate(); 281 stats[9] = "" + getDrop(); 282 stats[10] = "" + getCacheHitRatio(); 283 return stats; 284 } 285 286 291 public long getCacheHitRatio() 292 { 293 if (select.getCount() == 0) 294 return 0; 295 else 296 return (long) ((float) hits.getCount() / (float) select.getCount() * 100.0); 297 } 298 } 299 | Popular Tags |