00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.objectweb.cjdbc.controller.cache;
00026
00027 import org.objectweb.cjdbc.common.util.Stats;
00028
00029
00030
00031
00032
00033
00034
00035 public class CacheStatistics
00036 {
00037
00038 private Stats select;
00039 private Stats hits;
00040 private Stats insert;
00041 private Stats update;
00042 private Stats uncacheable;
00043 private Stats delete;
00044 private Stats unknown;
00045 private Stats remove;
00046 private Stats create;
00047 private Stats drop;
00048
00049
00050
00051
00052 public CacheStatistics()
00053 {
00054 select = new Stats("select");
00055 hits = new Stats("hits");
00056 insert = new Stats("insert");
00057 update = new Stats("update");
00058 uncacheable = new Stats("uncacheable");
00059 delete = new Stats("delete");
00060 unknown = new Stats("unknown");
00061 remove = new Stats("remove");
00062 create = new Stats("create");
00063 drop = new Stats("drop");
00064 }
00065
00066
00067
00068
00069 public void reset()
00070 {
00071 select.reset();
00072 hits.reset();
00073 insert.reset();
00074 update.reset();
00075 uncacheable.reset();
00076 delete.reset();
00077 unknown.reset();
00078 remove.reset();
00079 create.reset();
00080 drop.reset();
00081 }
00082
00083
00084
00085
00086
00087
00088 public int getCreate()
00089 {
00090 return create.getCount();
00091 }
00092
00093
00094
00095
00096
00097
00098 public int getDelete()
00099 {
00100 return delete.getCount();
00101 }
00102
00103
00104
00105
00106
00107
00108 public int getDrop()
00109 {
00110 return drop.getCount();
00111 }
00112
00113
00114
00115
00116
00117
00118 public int getHits()
00119 {
00120 return hits.getCount();
00121 }
00122
00123
00124
00125
00126
00127
00128 public int getInsert()
00129 {
00130 return insert.getCount();
00131 }
00132
00133
00134
00135
00136
00137
00138 public int getRemove()
00139 {
00140 return remove.getCount();
00141 }
00142
00143
00144
00145
00146
00147
00148 public int getSelect()
00149 {
00150 return select.getCount();
00151 }
00152
00153
00154
00155
00156
00157
00158 public int getUnknown()
00159 {
00160 return unknown.getCount();
00161 }
00162
00163
00164
00165
00166
00167
00168 public int getUpdate()
00169 {
00170 return update.getCount();
00171 }
00172
00173
00174
00175
00176
00177
00178 public int getUncacheable()
00179 {
00180 return uncacheable.getCount();
00181 }
00182
00183
00184
00185
00186 public void addCreate()
00187 {
00188 create.incrementCount();
00189 }
00190
00191
00192
00193
00194 public void addDelete()
00195 {
00196 delete.incrementCount();
00197 }
00198
00199
00200
00201
00202 public void addDrop()
00203 {
00204 drop.incrementCount();
00205 }
00206
00207
00208
00209
00210 public void addHits()
00211 {
00212 hits.incrementCount();
00213 }
00214
00215
00216
00217
00218 public void addInsert()
00219 {
00220 insert.incrementCount();
00221 }
00222
00223
00224
00225
00226 public void addRemove()
00227 {
00228 remove.incrementCount();
00229 }
00230
00231
00232
00233
00234 public void addSelect()
00235 {
00236 select.incrementCount();
00237 }
00238
00239
00240
00241
00242 public void addUnknown()
00243 {
00244 unknown.incrementCount();
00245 }
00246
00247
00248
00249
00250 public void addUpdate()
00251 {
00252 update.incrementCount();
00253 }
00254
00255
00256
00257
00258 public void addUncacheable()
00259 {
00260 uncacheable.incrementCount();
00261 }
00262
00263
00264
00265
00266
00267
00268
00269 public String[] getCacheStatsData()
00270 {
00271 String[] stats = new String[11];
00272 stats[0] = "" + getSelect();
00273 stats[1] = "" + getHits();
00274 stats[2] = "" + getInsert();
00275 stats[3] = "" + getUpdate();
00276 stats[4] = "" + getUncacheable();
00277 stats[5] = "" + getDelete();
00278 stats[6] = "" + getUnknown();
00279 stats[7] = "" + getRemove();
00280 stats[8] = "" + getCreate();
00281 stats[9] = "" + getDrop();
00282 stats[10] = "" + getCacheHitRatio();
00283 return stats;
00284 }
00285
00286
00287
00288
00289
00290
00291 public long getCacheHitRatio()
00292 {
00293 if (select.getCount() == 0)
00294 return 0;
00295 else
00296 return (long) ((float) hits.getCount() / (float) select.getCount() * 100.0);
00297 }
00298 }