Changeset 176

Show
Ignore:
Timestamp:
02/22/06 11:06:10
Author:
douglm
Message:

Make some changes to caching

Add code to allow us to enable hibernate statistics and then dump it

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/calCore/resources/hbms/Category.hbm.xml

    r2 r176  
    1111  <class name="org.bedework.calfacade.BwCategory" 
    1212         table="categories"> 
     13    <cache usage="read-write"/> 
     14 
    1315    <id name="id" type="integer" column="categoryid" unsaved-value="-1"> 
    1416      <generator class="native"/> 
     
    4143    </property> 
    4244    <property name="description" column="description" type="text"/> 
    43  
    44     <set name="events" table="event_categories" 
    45          lazy="true" 
    46          inverse="true" 
    47          cascade="all" > 
    48       <key column="categoryid"/> 
    49       <many-to-many class="org.bedework.calfacade.BwEventObj" 
    50                     column="eventid"/> 
    51     </set> 
    5245  </class> 
    5346 
  • trunk/calendar3/calCore/resources/hbms/Event.hbm.xml

    r48 r176  
    133133    <set name="categories" table="event_categories" 
    134134         lazy="true" > 
     135      <cache usage="read-write"/> 
    135136      <key column="eventid"/> 
    136137      <many-to-many class="org.bedework.calfacade.BwCategory" 
  • trunk/calendar3/calCore/resources/hbms/Location.hbm.xml

    r2 r176  
    1111  <class name="org.bedework.calfacade.BwLocation" 
    1212         table="locations"> 
     13    <cache usage="read-write"/> 
     14 
    1315    <id name="id" type="integer" column="entityid" unsaved-value="-1"> 
    1416      <generator class="native"/> 
     
    4143    <property name="subaddress" column="subaddress" type="string"/> 
    4244    <property name="link" column="link" type="string"/> 
    43  
    44     <set name="events" 
    45          lazy="true" 
    46          inverse="true" 
    47          cascade="all" > 
    48       <key column="locationid"/> 
    49       <one-to-many class="org.bedework.calfacade.BwEventObj" /> 
    50     </set> 
    5145  </class> 
    5246 
  • trunk/calendar3/calCore/resources/hbms/Sponsor.hbm.xml

    r2 r176  
    1111  <class name="org.bedework.calfacade.BwSponsor" 
    1212         table="sponsors"> 
     13    <cache usage="read-write"/> 
     14 
    1315    <id name="id" type="integer" column="entityid" unsaved-value="-1"> 
    1416      <generator class="native"/> 
     
    4244    <property name="email" column="email" type="string"/> 
    4345    <property name="link" column="link" type="string"/> 
    44  
    45     <set name="events" 
    46          lazy="true" 
    47          inverse="true" > 
    48       <key column="sponsorid"/> 
    49       <one-to-many class="org.bedework.calfacade.BwEventObj" /> 
    50     </set> 
    5146  </class> 
    5247 
  • trunk/calendar3/calCore/resources/properties/ehcache.xml

    r2 r176  
    7575        /> 
    7676 
    77     <!-- Subscription cache - these change infrequently and we should be able to cache all entries 
    78          in use 
     77    <!-- categories cache - these change infrequently 
    7978        --> 
    80     <cache name="org.bedework.calfacade.svc.BwSubscription" 
     79    <cache name="org.bedework.calfacade.BwCategory" 
     80        maxElementsInMemory="10000" 
     81        eternal="false" 
     82        timeToIdleSeconds="300" 
     83        timeToLiveSeconds="600" 
     84        overflowToDisk="true" 
     85        /> 
     86 
     87    <!-- event.categories cache - these change infrequently 
     88        --> 
     89    <cache name="org.bedework.calfacade.BwEventObj.categories" 
     90        maxElementsInMemory="10000" 
     91        eternal="false" 
     92        timeToIdleSeconds="300" 
     93        timeToLiveSeconds="600" 
     94        overflowToDisk="true" 
     95        /> 
     96 
     97    <!-- locations cache - these change infrequently 
     98        --> 
     99    <cache name="org.bedework.calfacade.BwLocation" 
     100        maxElementsInMemory="10000" 
     101        eternal="false" 
     102        timeToIdleSeconds="300" 
     103        timeToLiveSeconds="600" 
     104        overflowToDisk="true" 
     105        /> 
     106 
     107    <!-- sponsors cache - these change infrequently 
     108        --> 
     109    <cache name="org.bedework.calfacade.BwSponsor" 
    81110        maxElementsInMemory="10000" 
    82111        eternal="false" 
     
    113142        /> 
    114143 
     144    <!-- Subscription cache - these change infrequently and we should be able to cache all entries 
     145         in use 
     146        --> 
     147    <cache name="org.bedework.calfacade.svc.BwSubscription" 
     148        maxElementsInMemory="10000" 
     149        eternal="false" 
     150        timeToIdleSeconds="300" 
     151        timeToLiveSeconds="600" 
     152        overflowToDisk="true" 
     153        /> 
     154 
    115155    <!-- users cache - these change infrequently but are referenced frequently, usually many 
    116156         times a query. 
    117157        --> 
    118158 
    119     <cache name="org.bedework.calfacade.BwUsers
     159    <cache name="org.bedework.calfacade.BwUser
    120160        maxElementsInMemory="10000" 
    121161        eternal="false" 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java

    r164 r176  
    9393 
    9494import org.hibernate.cfg.Configuration; 
     95import org.hibernate.stat.Statistics; 
    9596import org.hibernate.SessionFactory; 
    9697 
     
    202203   */ 
    203204  private static SessionFactory sessFactory; 
     205  private static Statistics dbStats; 
    204206 
    205207  static { 
     
    339341  } 
    340342 
     343  public void setStats(boolean enable) throws CalFacadeException { 
     344    if (!enable && (dbStats == null)) { 
     345      return; 
     346    } 
     347     
     348    if (dbStats == null) { 
     349      dbStats = sessFactory.getStatistics(); 
     350    } 
     351     
     352    dbStats.setStatisticsEnabled(enable); 
     353  } 
     354   
     355  public void dumpStats() throws CalFacadeException { 
     356    DbStatistics.dumpStats(dbStats); 
     357  } 
     358 
    341359  public BwSystem getSyspars() throws CalFacadeException { 
    342360    if (syspars == null) { 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEventProperty.java

    r2 r176  
    5656import org.bedework.calfacade.base.BwShareableDbentity; 
    5757 
    58 import java.util.Set; 
    59  
    6058/** Base for those classes that can be a property of an event and are all 
    6159 * treated in the same manner, being Category, Location and Sponsor. 
     
    6866 */ 
    6967public class BwEventProperty extends BwShareableDbentity { 
    70   /** Events referencing this entity 
    71    */ 
    72   protected Set events; 
    73  
    7468  /** Constructor 
    7569   * 
     
    9286    super(owner, publick, creator, access); 
    9387  } 
    94  
    95   /** Set the events - must be a set of BwEvent 
    96    * 
    97    * @param val      Set of EventVO 
    98    */ 
    99   public void setEvents(Set val) { 
    100     events = val; 
    101   } 
    102  
    103   /** Get the events 
    104    * 
    105    * @return Set      of BwEvent 
    106    */ 
    107   public Set getEvents() { 
    108     return events; 
    109   } 
    11088} 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/BwStats.java

    r2 r176  
    6969 
    7070  protected int tzStores; 
     71   
     72  protected double eventFetchTime; 
     73   
     74  protected long eventFetches; 
    7175 
    7276  /** 
     
    9195  } 
    9296 
     97  /** 
     98   * @return double   event fetch millis. 
     99   */ 
     100  public double getEventFetchTime() { 
     101    return eventFetchTime; 
     102  } 
     103 
     104  /** 
     105   * @return long   event fetches. 
     106   */ 
     107  public long getEventFetches() { 
     108    return eventFetches; 
     109  } 
     110 
    93111  public String toString() { 
    94112    StringBuffer sb = new StringBuffer(); 
     
    98116    format(sb, "systemTzFetches: ", getSystemTzFetches()); 
    99117    format(sb, "tzStores: ", getTzStores()); 
     118     
     119    format(sb, "event fetch time: ", getEventFetchTime()); 
     120    format(sb, "event fetches: ", getEventFetches()); 
    100121 
    101122    return sb.toString(); 
     
    116137  } 
    117138 
     139  private void format(StringBuffer sb, String name, double val) { 
     140    pad(sb, name, maxnamepad); 
     141    sb.append(": "); 
     142    pad(sb, String.valueOf(val), maxvalpad); 
     143    sb.append("\n"); 
     144  } 
     145 
    118146  private void format(StringBuffer sb, String name, int val) { 
    119147    pad(sb, name, maxnamepad); 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java

    r162 r176  
    169169  } 
    170170 
     171  public void setStats(boolean enable) throws CalFacadeException { 
     172  } 
     173 
     174  public void dumpStats() throws CalFacadeException { 
     175  } 
     176 
    171177  public BwSystem getSyspars() throws CalFacadeException { 
    172178    return null; 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java

    r99 r176  
    114114                      boolean debug) throws CalFacadeException; 
    115115 
    116   /** Get the current stats 
     116  /** Get the current system (not db) stats 
    117117   * 
    118118   * @return BwStats object 
     
    120120   */ 
    121121  public BwStats getStats() throws CalFacadeException; 
     122 
     123  /** Enable/disable db statistics  
     124   * 
     125   * @param enable       boolean true to turn on db statistics collection 
     126   * @throws CalFacadeException if not admin 
     127   */ 
     128  public void setStats(boolean enable) throws CalFacadeException; 
     129 
     130  /** Dump db statistics  
     131   * 
     132   * @throws CalFacadeException if not admin 
     133   */ 
     134  public void dumpStats() throws CalFacadeException; 
    122135 
    123136  /** Get the system pars 
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r163 r176  
    324324 
    325325  public BwStats getStats() throws CalFacadeException { 
    326     if (!pars.getPublicAdmin()) { 
    327       throw new CalFacadeAccessException(); 
    328    
     326    //if (!pars.getPublicAdmin()) { 
     327    //  throw new CalFacadeAccessException(); 
     328    //
    329329 
    330330    return getCal().getStats(); 
     331  } 
     332 
     333  public void setStats(boolean enable) throws CalFacadeException { 
     334    //if (!pars.getPublicAdmin()) { 
     335    //  throw new CalFacadeAccessException(); 
     336    //} 
     337 
     338    getCal().setStats(enable); 
     339  } 
     340 
     341  public void dumpStats() throws CalFacadeException { 
     342    //if (!pars.getPublicAdmin()) { 
     343    //  throw new CalFacadeAccessException(); 
     344    //} 
     345     
     346    trace(getStats().toString()); 
     347    getCal().dumpStats(); 
    331348  } 
    332349 
  • trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java

    r119 r176  
    114114  public abstract BwStats getStats() throws CalFacadeException; 
    115115 
     116  /** Enable/disable db statistics  
     117   * 
     118   * @param enable       boolean true to turn on db statistics collection 
     119   * @throws CalFacadeException if not admin 
     120   */ 
     121  public abstract void setStats(boolean enable) throws CalFacadeException; 
     122 
     123  /** Dump db statistics  
     124   * 
     125   * @throws CalFacadeException if not admin 
     126   */ 
     127  public abstract void dumpStats() throws CalFacadeException; 
     128 
    116129  /** Get the system pars 
    117130   * 
  • trunk/calendar3/docs/todo.txt

    r173 r176  
    11Todo 
    22 
     3-------------------------------------------------------------------------------- 
     4Lost the exrules from the recurrence info hbm - add them 
    35-------------------------------------------------------------------------------- 
    46Installing webtest 
     
    2224Same url - eg week tab still causes fetch of events 
    2325-------------------------------------------------------------------------------- 
     26Watch for same event appearing in different calendars through ref. 
    2427-------------------------------------------------------------------------------- 
    25282.3.2 dump needs to dump filters before events. 
  • trunk/calendar3/webclient/war/WEB-INF/struts-config.xml

    r111 r176  
    308308    </action> 
    309309 
     310    <action    path="/stats" 
     311               type="org.bedework.webcommon.misc.StatisticsAction" 
     312               name="calForm" 
     313               scope="session" 
     314               validate="false"> 
     315    </action> 
     316 
    310317    <action    path="/manageLocations" 
    311318               type="org.bedework.webclient.BwAction"