Changeset 191
- Timestamp:
- 02/23/06 16:34:38
- Files:
-
- trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java (modified) (3 diffs)
- trunk/calendar3/appcommon/src/org/bedework/appcommon/TimezoneCache.java (modified) (1 diff)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalTimezonesImpl.java (modified) (1 diff)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java (modified) (2 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/DbStatistics.java (modified) (3 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwRWStats.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwStats.java (modified) (5 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalTimezones.java (modified) (6 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java (modified) (2 diffs)
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (1 diff)
- trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java (modified) (2 diffs)
- trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/TimezonesImpl.java (modified) (1 diff)
- trunk/calendar3/webadmin/war/WEB-INF/struts-config.xml (modified) (1 diff)
- trunk/calendar3/webadmin/war/docs/system/showSysStats.jsp (added)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/BwActionFormBase.java (modified) (2 diffs)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/StatisticsAction.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java
r185 r191 106 106 private TimeViewDailyInfo[] tvdis; 107 107 108 private static final TimezoneCache tzcache = new TimezoneCache(false);108 //private static final TimezoneCache tzcache = new TimezoneCache(false); 109 109 110 110 /** Constructor: … … 270 270 public Collection getDaysEvents(MyCalendarVO date) throws Throwable { 271 271 Vector v = new Vector(); 272 CalTimezones tzcache = cal.getTimezones(); 272 273 // Dur oneDay = new Dur(1, 0, 0, 0); 273 274 long millis = System.currentTimeMillis(); 274 275 275 tzcache.setSysTimezones(cal.getTimezones());276 //tzcache.setSysTimezones(cal.getTimezones()); 276 277 BwDateTime startDt = CalFacadeUtil.getDateTime(date.getDateDigits(), 277 278 tzcache); 278 // cal.getTimezones()); 279 280 // BwDateTime endDt = startDt.getNextDay(cal.getTimezones()); 279 281 280 BwDateTime endDt = startDt.getNextDay(tzcache); 282 281 String start = startDt.getDate(); … … 291 290 events = cal.getEvents(null, null, 292 291 CalFacadeUtil.getDateTime(firstDay.getDateDigits(), 293 // cal.getTimezones()),294 292 tzcache), 295 293 CalFacadeUtil.getDateTime(lastDay.getTomorrow().getDateDigits(), 296 // cal.getTimezones()),297 294 tzcache), 298 295 CalFacadeDefs.retrieveRecurExpanded); trunk/calendar3/appcommon/src/org/bedework/appcommon/TimezoneCache.java
r185 r191 137 137 HashMap cache; 138 138 139 if (tz == null) {139 if (tzid == null) { 140 140 cache = defaultCache; 141 } else if (tz .equals(getDefaultTimeZoneId())) {141 } else if (tzid.equals(getDefaultTimeZoneId())) { 142 142 cache = defaultCache; 143 143 } else { trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalTimezonesImpl.java
r171 r191 175 175 public void clearPublicTimezones() throws CalFacadeException { 176 176 cal.clearPublicTimezones(); 177 super.clearPublicTimezones(); 177 178 } 178 179 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
r176 r191 338 338 339 339 public BwStats getStats() throws CalFacadeException { 340 if (stats == null) { 341 return null; 342 } 343 344 BwRWStats rwstats = (BwRWStats)stats; 345 346 if (timezones != null) { 347 rwstats.setDateCacheHits(timezones.getDateCacheHits()); 348 rwstats.setDateCacheMisses(timezones.getDateCacheMisses()); 349 rwstats.setDatesCached(timezones.getDatesCached()); 350 } 351 340 352 return stats; 341 353 } 342 354 343 public void set Stats(boolean enable) throws CalFacadeException {355 public void setDbStatsEnabled(boolean enable) throws CalFacadeException { 344 356 if (!enable && (dbStats == null)) { 345 357 return; … … 352 364 dbStats.setStatisticsEnabled(enable); 353 365 } 366 367 public boolean getDbStatsEnabled() throws CalFacadeException { 368 if (dbStats == null) { 369 return false; 370 } 371 372 return dbStats.isStatisticsEnabled(); 373 } 354 374 355 public void dump Stats() throws CalFacadeException {375 public void dumpDbStats() throws CalFacadeException { 356 376 DbStatistics.dumpStats(dbStats); 377 } 378 379 public Collection getDbStats() throws CalFacadeException { 380 return DbStatistics.getStats(dbStats); 357 381 } 358 382 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/DbStatistics.java
r176 r191 54 54 package org.bedework.calcore.hibernate; 55 55 56 import java.util.Collection; 57 import java.util.Vector; 58 56 59 import org.bedework.calfacade.BwCalendar; 57 60 import org.bedework.calfacade.BwCategory; … … 59 62 import org.bedework.calfacade.BwLocation; 60 63 import org.bedework.calfacade.BwSponsor; 64 import org.bedework.calfacade.BwStats; 61 65 import org.bedework.calfacade.BwUser; 66 import org.bedework.calfacade.BwStats.StatsEntry; 62 67 63 68 import org.apache.log4j.Logger; … … 73 78 */ 74 79 public class DbStatistics { 75 private static final int lcolw = 50;76 77 80 public static void dumpStats(Statistics dbStats) { 81 if (dbStats == null) { 82 return; 83 } 84 85 Logger log = Logger.getLogger(DbStatistics.class); 86 87 log.debug(BwStats.toString(getStats(dbStats))); 88 } 89 90 public static Collection getStats(Statistics dbStats) { 78 91 /* XXX this ought to be property driven to some extent. The cache stats in 79 92 * particular. 80 93 */ 94 Vector v = new Vector(); 95 81 96 if (dbStats == null) { 82 return ;97 return v; 83 98 } 84 85 Logger log = Logger.getLogger(DbStatistics.class);86 87 log.debug(lpad("Number of connection requests: " , lcolw) +88 dbStats.getConnectCount());89 log.debug(lpad("Session flushes: " , lcolw) +90 dbStats.getFlushCount());91 log.debug(lpad("Transactions: " , lcolw) +92 dbStats.getTransactionCount());93 log.debug(lpad("Successful transactions: " , lcolw) +94 dbStats.getSuccessfulTransactionCount());95 log.debug(lpad("Sessions opened: " , lcolw) +96 dbStats.getSessionOpenCount());97 log.debug(lpad("Sessions closed: " , lcolw) +98 dbStats.getSessionCloseCount());99 log.debug(lpad("Queries executed: " , lcolw) +100 dbStats.getQueryExecutionCount());101 log.debug(lpad("Slowest query time: " , lcolw) +102 dbStats.getQueryExecutionMaxTime());103 104 log.debug(" ");105 log.debug(lpad("Collection statistics" , lcolw));106 log.debug(" ");107 108 log.debug(lpad("Collections fetched: " , lcolw) +109 dbStats.getCollectionFetchCount());110 log.debug(lpad("Collections loaded: " , lcolw) +111 dbStats.getCollectionLoadCount());112 log.debug(lpad("Collections rebuilt: " , lcolw) +113 dbStats.getCollectionRecreateCount());114 log.debug(lpad("Collections batch deleted: " , lcolw) +115 dbStats.getCollectionRemoveCount());116 log.debug(lpad("Collections batch updated: " , lcolw) +117 dbStats.getCollectionUpdateCount());118 119 log.debug(" ");120 log.debug(lpad("Object statistics" , lcolw));121 log.debug(" ");122 123 log.debug(lpad("Objects fetched: " , lcolw) +124 dbStats.getEntityFetchCount());125 log.debug(lpad("Objects loaded: " , lcolw) +126 dbStats.getEntityLoadCount());127 log.debug(lpad("Objects inserted: " , lcolw) +128 dbStats.getEntityInsertCount());129 log.debug(lpad("Objects deleted: " , lcolw) +130 dbStats.getEntityDeleteCount());131 log.debug(lpad("Objects updated: " , lcolw) +132 dbStats.getEntityUpdateCount());133 99 134 log.debug(" "); 135 log.debug(lpad("Cache statistics" , lcolw)); 136 log.debug(" "); 137 100 v.add(new StatsEntry("Number of connection requests", dbStats.getConnectCount())); 101 v.add(new StatsEntry("Session flushes", dbStats.getFlushCount())); 102 v.add(new StatsEntry("Transactions", dbStats.getTransactionCount())); 103 v.add(new StatsEntry("Successful transactions", dbStats.getSuccessfulTransactionCount())); 104 v.add(new StatsEntry("Sessions opened", dbStats.getSessionOpenCount())); 105 v.add(new StatsEntry("Sessions closed", dbStats.getSessionCloseCount())); 106 v.add(new StatsEntry("Queries executed", dbStats.getQueryExecutionCount())); 107 v.add(new StatsEntry("Slowest query time", dbStats.getQueryExecutionMaxTime())); 108 109 v.add(new StatsEntry("Collection statistics")); 110 111 v.add(new StatsEntry("Collections fetched", dbStats.getCollectionFetchCount())); 112 v.add(new StatsEntry("Collections loaded", dbStats.getCollectionLoadCount())); 113 v.add(new StatsEntry("Collections rebuilt", dbStats.getCollectionRecreateCount())); 114 v.add(new StatsEntry("Collections batch deleted", dbStats.getCollectionRemoveCount())); 115 v.add(new StatsEntry("Collections batch updated", dbStats.getCollectionUpdateCount())); 116 117 v.add(new StatsEntry("Object statistics")); 118 119 v.add(new StatsEntry("Objects fetched", dbStats.getEntityFetchCount())); 120 v.add(new StatsEntry("Objects loaded", dbStats.getEntityLoadCount())); 121 v.add(new StatsEntry("Objects inserted", dbStats.getEntityInsertCount())); 122 v.add(new StatsEntry("Objects deleted", dbStats.getEntityDeleteCount())); 123 v.add(new StatsEntry("Objects updated", dbStats.getEntityUpdateCount())); 124 125 v.add(new StatsEntry("Cache statistics")); 126 138 127 double chit = dbStats.getQueryCacheHitCount(); 139 128 double cmiss = dbStats.getQueryCacheMissCount(); 140 141 log.debug(lpad("Cache hit count: " , lcolw) + chit);142 log.debug(lpad("Cache miss count: " , lcolw) + cmiss);143 log.debug(lpad("Cache hit ratio: " , lcolw) + chit / (chit + cmiss));144 129 145 entityStats(dbStats, BwCalendar.class, log); 146 entityStats(dbStats, BwCategory.class, log); 147 entityStats(dbStats, BwEventObj.class, log); 148 entityStats(dbStats, BwLocation.class, log); 149 entityStats(dbStats, BwSponsor.class, log); 150 entityStats(dbStats, BwUser.class, log); 130 v.add(new StatsEntry("Cache hit count", chit)); 131 v.add(new StatsEntry("Cache miss count", cmiss)); 132 v.add(new StatsEntry("Cache hit ratio", chit / (chit + cmiss))); 151 133 152 collectionStats(dbStats, BwCalendar.class, "children", log); 153 collectionStats(dbStats, BwEventObj.class, "categories", log); 154 collectionStats(dbStats, BwEventObj.class, "attendees", log); 155 collectionStats(dbStats, BwEventObj.class, "rrules", log); 156 //collectionStats(dbStats, BwEventObj.class, "exrules", log); 157 collectionStats(dbStats, BwEventObj.class, "rdates", log); 158 collectionStats(dbStats, BwEventObj.class, "exdates", log); 134 entityStats(v, dbStats, BwCalendar.class); 135 entityStats(v, dbStats, BwCategory.class); 136 entityStats(v, dbStats, BwEventObj.class); 137 entityStats(v, dbStats, BwLocation.class); 138 entityStats(v, dbStats, BwSponsor.class); 139 entityStats(v, dbStats, BwUser.class); 140 141 collectionStats(v, dbStats, BwCalendar.class, "children"); 142 collectionStats(v, dbStats, BwEventObj.class, "categories"); 143 collectionStats(v, dbStats, BwEventObj.class, "attendees"); 144 collectionStats(v, dbStats, BwEventObj.class, "rrules"); 145 //collectionStats(v, dbStats, BwEventObj.class, "exrules"); 146 collectionStats(v, dbStats, BwEventObj.class, "rdates"); 147 collectionStats(v, dbStats, BwEventObj.class, "exdates"); 148 149 return v; 159 150 } 160 161 private static void entityStats(Statistics dbStats, Class cl, Logger log) { 151 152 private static void entityStats(Collection c, Statistics dbStats, 153 Class cl) { 162 154 String name = cl.getName(); 163 164 log.debug(" "); 165 log.debug(lpad("Statistics for " + name , lcolw)); 166 log.debug(" "); 167 155 156 c.add(new StatsEntry("Statistics for " + name)); 157 168 158 EntityStatistics eStats = dbStats.getEntityStatistics(name); 169 159 170 log.debug(lpad("Fetched: " , lcolw) + eStats.getFetchCount());171 log.debug(lpad("Loaded: " , lcolw) + eStats.getLoadCount());172 log.debug(lpad("Inserted: " , lcolw) + eStats.getInsertCount());173 log.debug(lpad("Deleted: " , lcolw) + eStats.getDeleteCount());174 log.debug(lpad("Updated: " , lcolw) + eStats.getUpdateCount());160 c.add(new StatsEntry("Fetched", eStats.getFetchCount())); 161 c.add(new StatsEntry("Loaded", eStats.getLoadCount())); 162 c.add(new StatsEntry("Inserted", eStats.getInsertCount())); 163 c.add(new StatsEntry("Deleted", eStats.getDeleteCount())); 164 c.add(new StatsEntry("Updated", eStats.getUpdateCount())); 175 165 } 176 177 private static void collectionStats( Statistics dbStats, Class cl,178 String cname , Logger log) {166 167 private static void collectionStats(Collection c, Statistics dbStats, Class cl, 168 String cname) { 179 169 String name = cl.getName() + "." + cname; 180 181 log.debug(" "); 182 log.debug(lpad("Statistics for " + name , lcolw)); 183 log.debug(" "); 184 170 171 c.add(new StatsEntry("Statistics for " + name)); 172 185 173 CollectionStatistics cStats = dbStats.getCollectionStatistics(name); 186 174 187 log.debug(lpad("Fetched: " , lcolw) + cStats.getFetchCount());188 log.debug(lpad("Loaded: " , lcolw) + cStats.getLoadCount());189 log.debug(lpad("Recreated: " , lcolw) + cStats.getRecreateCount());190 log.debug(lpad("Removed: " , lcolw) + cStats.getRemoveCount());191 log.debug(lpad("Updated: " , lcolw) + cStats.getUpdateCount());175 c.add(new StatsEntry("Fetched", cStats.getFetchCount())); 176 c.add(new StatsEntry("Loaded", cStats.getLoadCount())); 177 c.add(new StatsEntry("Recreated", cStats.getRecreateCount())); 178 c.add(new StatsEntry("Removed", cStats.getRemoveCount())); 179 c.add(new StatsEntry("Updated", cStats.getUpdateCount())); 192 180 } 193 194 private static void secondLevelStats(Statistics dbStats, String name, 195 Logger log) { 196 log.debug(" "); 197 log.debug(lpad("Second level statistics for " + name , lcolw)); 198 log.debug(" "); 199 181 182 private static void secondLevelStats(Collection c, Statistics dbStats, 183 String name) { 184 c.add(new StatsEntry("Second level statistics for " + name)); 185 200 186 SecondLevelCacheStatistics slStats = dbStats.getSecondLevelCacheStatistics(name); 201 187 202 log.debug(lpad("Elements in memory: " , lcolw) + slStats.getElementCountInMemory()); 203 log.debug(lpad("Element on disk: " , lcolw) + slStats.getElementCountOnDisk()); 204 log.debug(lpad("Entries: " , lcolw) + slStats.getEntries()); 205 log.debug(lpad("Hit count: " , lcolw) + slStats.getHitCount()); 206 log.debug(lpad("Miss count: " , lcolw) + slStats.getMissCount()); 207 log.debug(lpad("Put count: " , lcolw) + slStats.getPutCount()); 208 log.debug(lpad("Memory size: " , lcolw) + slStats.getSizeInMemory()); 209 } 210 211 private final static String padder = " " + 212 " " + 213 " " + 214 " "; 215 216 private final static int padderLen = padder.length(); 217 218 private static String lpad(String s, int len) { 219 int l = len - s.length(); 220 221 if (l > padderLen) { 222 return padder + s; 223 } 224 225 if (l < 0) { 226 return s; 227 } 228 229 return padder.substring(0, l) + s; 188 c.add(new StatsEntry("Elements in memory", slStats.getElementCountInMemory())); 189 c.add(new StatsEntry("Element on disk", slStats.getElementCountOnDisk())); 190 //c.add(new StatsEntry("Entries", slStats.getEntries())); 191 c.add(new StatsEntry("Hit count", slStats.getHitCount())); 192 c.add(new StatsEntry("Miss count", slStats.getMissCount())); 193 c.add(new StatsEntry("Put count", slStats.getPutCount())); 194 c.add(new StatsEntry("Memory size", slStats.getSizeInMemory())); 230 195 } 231 196 } trunk/calendar3/calFacade/src/org/bedework/calfacade/BwRWStats.java
r2 r191 80 80 tzStores++; 81 81 } 82 83 /** 84 * @param val double event fetch millis. 85 */ 86 public void incEventFetchTime(double val) { 87 eventFetchTime += val; 88 } 89 90 /** 91 * @param val long event fetches. 92 */ 93 public void incEventFetches(long val) { 94 eventFetches += val; 95 } 96 97 /** 98 * @param val number of utc values cached 99 */ 100 public void setDatesCached(long val) { 101 datesCached = val; 102 } 103 104 /** 105 * @param val date cache hits 106 */ 107 public void setDateCacheHits(long val) { 108 dateCacheHits = val; 109 } 110 111 /** 112 * @param val data cache misses. 113 */ 114 public void setDateCacheMisses(long val) { 115 dateCacheMisses = val; 116 } 82 117 } trunk/calendar3/calFacade/src/org/bedework/calfacade/BwStats.java
r176 r191 56 56 57 57 import java.io.Serializable; 58 import java.util.Collection; 59 import java.util.Iterator; 60 import java.util.Vector; 58 61 59 62 /** Some statistics for the Bedework calendar. These are not necessarily … … 64 67 */ 65 68 public class BwStats implements Serializable { 69 /** Class to hold a statistics. We build a collection of these. 70 * We use Strings for values as these are going to be dumped as xml. 71 */ 72 public static class StatsEntry { 73 public final static int statKindHeader = 0; 74 public final static int statKindStat = 1; 75 76 private int statKind; 77 78 private String statLabel; 79 80 public final static int statTypeString = 0; 81 public final static int statTypeInt = 1; 82 public final static int statTypeLong = 2; 83 public final static int statTypeDouble = 3; 84 private int statType; 85 86 private String statVal; 87 88 public StatsEntry(String label, int val) { 89 statKind = statKindStat; 90 statLabel = label; 91 statType = statTypeInt; 92 statVal = String.valueOf(val); 93 } 94 95 public StatsEntry(String label, long val) { 96 statKind = statKindStat; 97 statLabel = label; 98 statType = statTypeLong; 99 statVal = String.valueOf(val); 100 } 101 102 public StatsEntry(String label, double val) { 103 statKind = statKindStat; 104 statLabel = label; 105 statType = statTypeDouble; 106 statVal = String.valueOf(val); 107 } 108 109 public StatsEntry(String label, String val) { 110 statKind = statKindStat; 111 statLabel = label; 112 statType = statTypeString; 113 statVal = val; 114 } 115 116 public StatsEntry(String header) { 117 statKind = statKindHeader; 118 statLabel = header; 119 } 120 121 public int getStatKind() { 122 return statKind; 123 } 124 125 public String getStatLabel() { 126 return statLabel; 127 } 128 129 public int getStatType() { 130 return statType; 131 } 132 133 public String getStatVal() { 134 return statVal; 135 } 136 } 137 66 138 protected int tzFetches; 67 139 … … 69 141 70 142 protected int tzStores; 71 143 72 144 protected double eventFetchTime; 73 145 74 146 protected long eventFetches; 147 148 /* Timezone cache stats */ 149 protected long datesCached; 150 protected long dateCacheHits; 151 protected long dateCacheMisses; 75 152 76 153 /** … … 109 186 } 110 187 188 /** 189 * @return Number of utc values cached 190 */ 191 public long getDatesCached() { 192 return datesCached; 193 } 194 195 /** 196 * @return date cache hits 197 */ 198 public long getDateCacheHits() { 199 return dateCacheHits; 200 } 201 202 /** 203 * @return data cache misses. 204 */ 205 public long getDateCacheMisses() { 206 return dateCacheMisses; 207 } 208 209 public Collection getStats() { 210 Vector v = new Vector(); 211 212 v.add(new StatsEntry("Bedework statistics.")); 213 v.add(new StatsEntry("tzFetches", getTzFetches())); 214 v.add(new StatsEntry("systemTzFetches", getSystemTzFetches())); 215 v.add(new StatsEntry("tzStores", getTzStores())); 216 217 v.add(new StatsEntry("event fetch time", getEventFetchTime())); 218 v.add(new StatsEntry("event fetches", getEventFetches())); 219 220 v.add(new StatsEntry("UTC dates cached", getDatesCached())); 221 v.add(new StatsEntry("UTC date cache hits", getDateCacheHits())); 222 v.add(new StatsEntry("UTC date cache misses", getDateCacheMisses())); 223 224 return v; 225 } 226 227 /** Turn the Collection of StatsEntry into a String for dumps. 228 */ 229 public static String toString(Collection c) { 230 StringBuffer sb = new StringBuffer(); 231 232 Iterator it = c.iterator(); 233 234 while (it.hasNext()) { 235 StatsEntry se = (StatsEntry)it.next(); 236 int k = se.getStatKind(); 237 238 if (k == StatsEntry.statKindHeader) { 239 header(sb, se.getStatLabel()); 240 } else { 241 format(sb, se.getStatLabel(), se.getStatVal()); 242 } 243 } 244 245 return sb.toString(); 246 } 247 111 248 public String toString() { 112 StringBuffer sb = new StringBuffer(); 113 114 sb.append("Bedework svc layer statistics.\n"); 115 format(sb, "tzFetches: ", getTzFetches()); 116 format(sb, "systemTzFetches: ", getSystemTzFetches()); 117 format(sb, "tzStores: ", getTzStores()); 118 119 format(sb, "event fetch time: ", getEventFetchTime()); 120 format(sb, "event fetches: ", getEventFetches()); 121 122 return sb.toString(); 123 } 124 125 private static final String padding = " "; 249 return toString(getStats()); 250 } 251 252 private final static String padder = " " + 253 " " + 254 " " + 255 " "; 256 257 private final static int padderLen = padder.length(); 258 126 259 private static final int maxvalpad = 10; 127 private static final int maxnamepad = padding.length(); 128 129 private void pad(StringBuffer sb, String val, int padlen) { 130 int len = val.length(); 131 132 if (len <= padlen) { 133 sb.append(padding.substring(len)); 260 261 private static void pad(StringBuffer sb, String val, int padlen) { 262 int len = padlen - val.length(); 263 264 if (len > 0) { 265 sb.append(padder.substring(0, len)); 134 266 } 135 267 … … 137 269 } 138 270 139 private void format(StringBuffer sb, String name, double val) { 140 pad(sb, name, maxnamepad); 271 private static void header(StringBuffer sb, String h) { 272 sb.append("\n"); 273 pad(sb, h, padderLen); 274 sb.append("\n"); 275 } 276 277 private static void format(StringBuffer sb, String name, String val) { 278 pad(sb, name, padderLen); 141 279 sb.append(": "); 142 pad(sb, String.valueOf(val), maxvalpad);280 pad(sb, val, maxvalpad); 143 281 sb.append("\n"); 144 282 } 145 146 private void format(StringBuffer sb, String name, int val) {147 pad(sb, name, maxnamepad);148 sb.append(": ");149 pad(sb, String.valueOf(val), maxvalpad);150 sb.append("\n");151 }152 283 } trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java
r176 r191 169 169 } 170 170 171 public void setStats(boolean enable) throws CalFacadeException { 172 } 173 174 public void dumpStats() throws CalFacadeException { 171 public void setDbStatsEnabled(boolean enable) throws CalFacadeException { 172 } 173 174 public boolean getDbStatsEnabled() throws CalFacadeException { 175 return false; 176 } 177 178 public void dumpDbStats() throws CalFacadeException { 179 } 180 181 public Collection getDbStats() throws CalFacadeException { 182 return null; 175 183 } 176 184 trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalTimezones.java
r185 r191 140 140 /* Map of user TimezoneInfo */ 141 141 protected HashMap timezones = new HashMap(); 142 143 /* Cache date only UTC values - we do a lot of those but the number of 144 * different dates should be limited. 145 * 146 * We have one cache per timezone 147 */ 148 private HashMap dateCaches = new HashMap(); 149 150 private HashMap defaultDateCache = new HashMap(); 151 152 private long datesCached; 153 private long dateCacheHits; 154 private long dateCacheMisses; 142 155 143 156 protected CalTimezones(boolean debug) { … … 230 243 public abstract VTimeZone findTimeZone(final String id, BwUser owner) throws CalFacadeException; 231 244 232 /** Clear all public timezone objects 245 /** Clear all public timezone objects. Implementing classes should call this. 233 246 * 234 247 * <p>Will remove all public timezones in preparation for a replacement … … 237 250 * @throws CalFacadeException 238 251 */ 239 public abstract void clearPublicTimezones() throws CalFacadeException; 252 public void clearPublicTimezones() throws CalFacadeException { 253 dateCaches.clear(); 254 defaultDateCache.clear(); 255 } 240 256 241 257 /** Refresh the public timezone table - presumably after a call to clearPublicTimezones. … … 291 307 return time; 292 308 } 309 310 String dateKey = null; 311 HashMap cache = null; 293 312 294 313 if (CalFacadeUtil.isISODate(time)) { 314 /* See if we have it cached */ 315 316 if (tzid == null) { 317 cache = defaultDateCache; 318 } else if (tzid.equals(getDefaultTimeZoneId())) { 319 cache = defaultDateCache; 320 } else { 321 cache = (HashMap)dateCaches.get(tzid); 322 if (cache == null) { 323 cache = new HashMap(); 324 dateCaches.put(tzid, cache); 325 } 326 } 327 328 String utc = (String)cache.get(time); 329 330 if (utc != null) { 331 dateCacheHits++; 332 return utc; 333 } 334 335 /* Not in the cache - calculate it */ 336 337 dateCacheMisses++; 338 dateKey = time; 295 339 time += "T000000"; 296 340 } else if (!CalFacadeUtil.isISODateTime(time)) { … … 364 408 digit2(sb, cal.get(Calendar.SECOND)); 365 409 sb.append('Z'); 366 return sb.toString(); 410 411 String utc = sb.toString(); 412 413 if (dateKey != null) { 414 cache.put(dateKey, utc); 415 datesCached++; 416 } 417 418 return utc; 367 419 } catch (Throwable t) { 368 420 t.printStackTrace(); … … 371 423 } 372 424 425 /** 426 * @return Number of utc values cached 427 */ 428 public long getDatesCached() { 429 return datesCached; 430 } 431 432 /** 433 * @return date cache hits 434 */ 435 public long getDateCacheHits() { 436 return dateCacheHits; 437 } 438 439 /** 440 * @return data cache misses. 441 */ 442 public long getDateCacheMisses() { 443 return dateCacheMisses; 444 } 445 373 446 /* ==================================================================== 374 447 * protected methods trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java
r176 r191 126 126 * @throws CalFacadeException if not admin 127 127 */ 128 public void setStats(boolean enable) throws CalFacadeException; 128 public void setDbStatsEnabled(boolean enable) throws CalFacadeException; 129 130 /** 131 * 132 * @return boolean true if statistics collection enabled 133 * @throws CalFacadeException if not admin 134 */ 135 public boolean getDbStatsEnabled() throws CalFacadeException; 129 136 130 137 /** Dump db statistics … … 132 139 * @throws CalFacadeException if not admin 133 140 */ 134 public void dumpStats() throws CalFacadeException; 141 public void dumpDbStats() throws CalFacadeException; 142 143 /** Get db statistics 144 * 145 * @return Collection of BwStats.StatsEntry objects 146 * @throws CalFacadeException if not admin 147 */ 148 public Collection getDbStats() throws CalFacadeException; 135 149 136 150 /** Get the system pars trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r177 r191 325 325 326 326 public BwStats getStats() throws CalFacadeException { 327 //if (!pars.getPublicAdmin()) {328 //throw new CalFacadeAccessException();329 //}327 if (!pars.getPublicAdmin()) { 328 throw new CalFacadeAccessException(); 329 } 330 330 331 331 return getCal().getStats(); 332 332 } 333 333 334 public void setStats(boolean enable) throws CalFacadeException { 335 //if (!pars.getPublicAdmin()) { 336 // throw new CalFacadeAccessException(); 337 //} 338 339 getCal().setStats(enable); 340 } 341 342 public void dumpStats() throws CalFacadeException { 343 //if (!pars.getPublicAdmin()) { 344 // throw new CalFacadeAccessException(); 345 //} 334 public void setDbStatsEnabled(boolean enable) throws CalFacadeException { 335 if (!pars.getPublicAdmin()) { 336 throw new CalFacadeAccessException(); 337 } 338 339 getCal().setDbStatsEnabled(enable); 340 } 341 342 public boolean getDbStatsEnabled() throws CalFacadeException { 343 return getCal().getDbStatsEnabled(); 344 } 345 346 public void dumpDbStats() throws CalFacadeException { 347 if (!pars.getPublicAdmin()) { 348 throw new CalFacadeAccessException(); 349 } 346 350 347 351 trace(getStats().toString()); 348 getCal().dumpStats(); 352 getCal().dumpDbStats(); 353 } 354 355 public Collection getDbStats() throws CalFacadeException { 356 if (!pars.getPublicAdmin()) { 357 throw new CalFacadeAccessException(); 358 } 359 360 return getCal().getDbStats(); 349 361 } 350 362 trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java
r176 r191 119 119 * @throws CalFacadeException if not admin 120 120 */ 121 public abstract void setStats(boolean enable) throws CalFacadeException; 121 public abstract void setDbStatsEnabled(boolean enable) throws CalFacadeException; 122 123 /** 124 * 125 * @return boolean true if statistics collection enabled 126 * @throws CalFacadeException if not admin 127 */ 128 public abstract boolean getDbStatsEnabled() throws CalFacadeException; 122 129 123 130 /** Dump db statistics … … 125 132 * @throws CalFacadeException if not admin 126 133 */ 127 public abstract void dumpStats() throws CalFacadeException; 134 public abstract void dumpDbStats() throws CalFacadeException; 135 136 /** Get db statistics 137 * 138 * @return Collection of BwStats.StatsEntry objects 139 * @throws CalFacadeException if not admin 140 */ 141 public abstract Collection getDbStats() throws CalFacadeException; 128 142 129 143 /** Get the system pars trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/TimezonesImpl.java
r171 r191 190 190 } 191 191 192 public void clearPublicTimezones() throws CalFacadeException {193 }194 195 192 public void refreshTimezones() throws CalFacadeException { 196 193 synchronized (this) { trunk/calendar3/webadmin/war/WEB-INF/struts-config.xml
r190 r191 947 947 <forward name="continue" path="/admingroup/showChooseGroup.rdo" redirect="true" /> 948 948 </action> 949 950 <!-- =============================================================== 951 Stats Actions 952 =============================================================== --> 953 954 <action path="/stats/show" 955 type="org.bedework.webadmin.PERenderAction" 956 name="peForm" 957 scope="session" 958 validate="false"> 959 <forward name="success" path="/docs/system/showSysStats.jsp" /> 960 </action> 961 962 <action path="/stats/update" 963 type="org.bedework.webcommon.misc.StatisticsAction" 964 name="peForm" 965 scope="session" 966 validate="false"> 967 <forward name="continue" path="/stats/show.rdo" redirect="true" /> 968 <forward name="success" path="/stats/show.rdo" redirect="true" /> 969 </action> 949 970 </action-mappings> 950 971 trunk/calendar3/webcommon/src/org/bedework/webcommon/BwActionFormBase.java
r145 r191 108 108 private BwSystem syspars; 109 109 110 private Collection sysStats; 111 110 112 private transient MailerIntf mailer; 111 113 … … 395 397 return syspars; 396 398 } 397 399 400 /** Set system statistics 401 * 402 * @param val Collection of BwStats.StatsEntry objects 403 */ 404 public void assignSysStats(Collection val) { 405 sysStats = val; 406 } 407 408 /** Get system statistics 409 * 410 * @return Collection of BwStats.StatsEntry objects 411 */ 412 public Collection getSysStats() { 413 if (sysStats == null) { 414 sysStats = new Vector(); 415 } 416 417 return sysStats; 418 } 419 420 /** Get system statistics enabled state 421 * 422 * @return boolean true if statistics collection enabled 423 */ 424 public boolean getSysStatsEnabled() { 425 try { 426 return fetchSvci().getDbStatsEnabled(); 427 } catch (Throwable t) { 428 return false; 429 } 430 } 431 398 432 /** This will default to the current user. Superusers will be able to 399 433 * specify a creator. trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/StatisticsAction.java
r176 r191 55 55 package org.bedework.webcommon.misc; 56 56 57 import java.util.Collection; 58 59 import org.bedework.calfacade.BwStats; 57 60 import org.bedework.calsvci.CalSvcI; 58 61 import org.bedework.webcommon.BwAbstractAction; … … 70 73 * <li>"disable" Disable stats</li> 71 74 * <li>"dump" Dump stats</li> 75 * <li>"fetch" fetch stats</li> 72 76 * </ul> 73 77 * … … 90 94 91 95 if (getReqPar(request, "enable") != null) { 92 svci.set Stats(true);96 svci.setDbStatsEnabled(true); 93 97 } else if (getReqPar(request, "disable") != null) { 94 svci.set Stats(false);98 svci.setDbStatsEnabled(false); 95 99 } else if (getReqPar(request, "dump") != null) { 96 svci.dumpStats(); 100 svci.dumpDbStats(); 101 } else if (getReqPar(request, "fetch") != null) { 102 BwStats stats = svci.getStats(); 103 104 Collection c = stats.getStats(); 105 106 c.addAll(svci.getDbStats()); 107 108 form.assignSysStats(c); 109 110 return "continue"; 97 111 } 98 112
