1 22 23 package org.continuent.sequoia.controller.cache; 24 25 import org.continuent.sequoia.common.util.Stats; 26 27 33 public class CacheStatistics 34 { 35 private Stats select; 37 private Stats hits; 38 private Stats insert; 39 private Stats update; 40 private Stats uncacheable; 41 private Stats delete; 42 private Stats unknown; 43 private Stats remove; 44 private Stats create; 45 private Stats drop; 46 47 50 public CacheStatistics() 51 { 52 select = new Stats("select"); 53 hits = new Stats("hits"); 54 insert = new Stats("insert"); 55 update = new Stats("update"); 56 uncacheable = new Stats("uncacheable"); 57 delete = new Stats("delete"); 58 unknown = new Stats("unknown"); 59 remove = new Stats("remove"); 60 create = new Stats("create"); 61 drop = new Stats("drop"); 62 } 63 64 67 public void reset() 68 { 69 select.reset(); 70 hits.reset(); 71 insert.reset(); 72 update.reset(); 73 uncacheable.reset(); 74 delete.reset(); 75 unknown.reset(); 76 remove.reset(); 77 create.reset(); 78 drop.reset(); 79 } 80 81 86 public int getCreate() 87 { 88 return create.getCount(); 89 } 90 91 96 public int getDelete() 97 { 98 return delete.getCount(); 99 } 100 101 106 public int getDrop() 107 { 108 return drop.getCount(); 109 } 110 111 116 public int getHits() 117 { 118 return hits.getCount(); 119 } 120 121 126 public int getInsert() 127 { 128 return insert.getCount(); 129 } 130 131 136 public int getRemove() 137 { 138 return remove.getCount(); 139 } 140 141 146 public int getSelect() 147 { 148 return select.getCount(); 149 } 150 151 156 public int getUnknown() 157 { 158 return unknown.getCount(); 159 } 160 161 166 public int getUpdate() 167 { 168 return update.getCount(); 169 } 170 171 176 public int getUncacheable() 177 { 178 return uncacheable.getCount(); 179 } 180 181 184 public void addCreate() 185 { 186 create.incrementCount(); 187 } 188 189 192 public void addDelete() 193 { 194 delete.incrementCount(); 195 } 196 197 200 public void addDrop() 201 { 202 drop.incrementCount(); 203 } 204 205 208 public void addHits() 209 { 210 hits.incrementCount(); 211 } 212 213 216 public void addInsert() 217 { 218 insert.incrementCount(); 219 } 220 221 224 public void addRemove() 225 { 226 remove.incrementCount(); 227 } 228 229 232 public void addSelect() 233 { 234 select.incrementCount(); 235 } 236 237 240 public void addUnknown() 241 { 242 unknown.incrementCount(); 243 } 244 245 248 public void addUpdate() 249 { 250 update.incrementCount(); 251 } 252 253 256 public void addUncacheable() 257 { 258 uncacheable.incrementCount(); 259 } 260 261 267 public String [] getCacheStatsData() 268 { 269 String [] stats = new String [11]; 270 stats[0] = "" + getSelect(); 271 stats[1] = "" + getHits(); 272 stats[2] = "" + getInsert(); 273 stats[3] = "" + getUpdate(); 274 stats[4] = "" + getUncacheable(); 275 stats[5] = "" + getDelete(); 276 stats[6] = "" + getUnknown(); 277 stats[7] = "" + getRemove(); 278 stats[8] = "" + getCreate(); 279 stats[9] = "" + getDrop(); 280 stats[10] = "" + getCacheHitRatio(); 281 return stats; 282 } 283 284 289 public long getCacheHitRatio() 290 { 291 if (select.getCount() == 0) 292 return 0; 293 else 294 return (long) ((float) hits.getCount() / (float) select.getCount() * 100.0); 295 } 296 } 297 | Popular Tags |