1 64 package com.jcorporate.expresso.core.dbobj; 65 66 import com.jcorporate.expresso.core.misc.StringUtil; 67 68 69 75 public class CacheStatEntry 76 extends Object implements Comparable { 77 78 private String dbobjName = null; 79 private String dbName = null; 80 private int readCount = 0; 81 private int cacheHits = 0; 82 private int cacheMisses = 0; 83 84 90 public CacheStatEntry(String newName, String newDBName) { 91 dbobjName = newName; 92 dbName = StringUtil.notNull(newDBName); 93 94 if (dbName.equals("")) { 95 dbName = "default"; 96 } 97 } 98 99 104 public int getReadCount() { 105 return readCount; 106 } 107 108 113 public int getCacheHits() { 114 return cacheHits; 115 } 116 117 122 public int getCacheMisses() { 123 return cacheMisses; 124 } 125 126 131 public String getDataContext() { 132 return dbName; 133 } 134 135 141 public String getDBObjName() { 142 return dbobjName; 143 } 144 145 152 public synchronized void incCounts(boolean cached) { 153 if (cached) { 154 cacheHits++; 155 } else { 156 cacheMisses++; 157 } 158 159 readCount++; 160 } 161 162 173 public int compareTo(Object o) { 174 int result = 0; 175 CacheStatEntry entry = (CacheStatEntry) o; 176 177 Float myhitrate = new Float ((float) this.getCacheHits() / (float) getReadCount()); 179 Float hitrate = new Float ((float) entry.getCacheHits() / (float) entry.getReadCount()); 180 result = myhitrate.compareTo(hitrate); 181 if (result == 0) { 182 result = new Integer (entry.getReadCount()).compareTo(new Integer (getReadCount())); 184 } 185 return result; 186 } 187 } | Popular Tags |