From: <jt...@hy...> - 2007-05-23 18:56:36
|
Author: jtravis Date: 2007-05-23 11:56:28 -0700 (Wed, 23 May 2007) New Revision: 4511 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=4511 Modified: trunk/etc/ehcache.xml trunk/etc/preload_caches.txt trunk/sql/appdef/ServiceCluster.hbm.xml trunk/src/org/hyperic/hq/dao/ServerDAO.java trunk/src/org/hyperic/hq/dao/VirtualDAO.java trunk/src/org/hyperic/hq/measurement/server/session/DerivedMeasurementDAO.java trunk/src/org/hyperic/hq/measurement/server/session/DerivedMeasurementManagerEJBImpl.java trunk/src/org/hyperic/hq/measurement/server/session/MeasurementTemplateDAO.java Log: HHQ-888. Add a few more general performance improvements Modified: trunk/etc/ehcache.xml =================================================================== --- trunk/etc/ehcache.xml 2007-05-23 18:55:14 UTC (rev 4510) +++ trunk/etc/ehcache.xml 2007-05-23 18:56:28 UTC (rev 4511) @@ -225,6 +225,18 @@ timeToIdleSeconds="0" timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/> + <cache name="Server.findByPlatformAndType_orderName" + maxElementsInMemory="100" + eternal="true" + timeToIdleSeconds="0" + timeToLiveSeconds="0" + memoryStoreEvictionPolicy="LRU"/> + <cache name="Server.findByPlatform_orderName" + maxElementsInMemory="100" + eternal="true" + timeToIdleSeconds="0" + timeToLiveSeconds="0" + memoryStoreEvictionPolicy="LRU"/> <cache name="Server.findAll_orderName" maxElementsInMemory="2" eternal="true" @@ -244,7 +256,21 @@ timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/> + <!-- Virtual --> + <cache name="Virtual.findVirtualByPhysicalId" + maxElementsInMemory="100" + eternal="true" + timeToIdleSeconds="0" + timeToLiveSeconds="0" + memoryStoreEvictionPolicy="LRU"/> + <!-- Service Caches --> + <cache name="org.hyperic.hq.appdef.ServiceCluster" + maxElementsInMemory="100" + eternal="true" + timeToIdleSeconds="0" + timeToLiveSeconds="0" + memoryStoreEvictionPolicy="LRU"/> <cache name="org.hyperic.hq.appdef.server.session.ServiceType" maxElementsInMemory="300" eternal="true" Modified: trunk/etc/preload_caches.txt =================================================================== --- trunk/etc/preload_caches.txt 2007-05-23 18:55:14 UTC (rev 4510) +++ trunk/etc/preload_caches.txt 2007-05-23 18:56:28 UTC (rev 4511) @@ -1,5 +1,13 @@ org.hyperic.hq.authz.server.session.Resource +org.hyperic.hq.authz.server.session.ResourceType org.hyperic.hq.authz.server.session.ResourceGroup +org.hyperic.hq.authz.server.session.UserConfigResp +org.hyperic.hq.appdef.ServiceCluster +org.hyperic.hq.appdef.AgentType +org.hyperic.hq.appdef.Agent +org.hyperic.hq.appdef.server.session.PlatformType +org.hyperic.hq.appdef.server.session.ServerType +org.hyperic.hq.appdef.server.session.ServiceType org.hyperic.hq.appdef.server.session.Platform org.hyperic.hq.appdef.server.session.Server org.hyperic.hq.appdef.server.session.Service @@ -7,5 +15,6 @@ org.hyperic.hq.events.server.session.AlertCondition org.hyperic.hq.events.server.session.AlertDefinition org.hyperic.hq.events.server.session.RegisteredTrigger +org.hyperic.hq.measurement.server.session.Category org.hyperic.hq.measurement.server.session.MonitorableType org.hyperic.hq.measurement.server.session.Baseline Modified: trunk/sql/appdef/ServiceCluster.hbm.xml =================================================================== --- trunk/sql/appdef/ServiceCluster.hbm.xml 2007-05-23 18:55:14 UTC (rev 4510) +++ trunk/sql/appdef/ServiceCluster.hbm.xml 2007-05-23 18:56:28 UTC (rev 4511) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="org.hyperic.hq.appdef"> - <class name="ServiceCluster" table="EAM_SVC_CLUSTER"> + <cache usage="read-write" /> <id name="id" type="integer"> <meta attribute="scope-set" inherit="true"><![CDATA[private]]></meta> <column name="ID" not-null="true"/> Modified: trunk/src/org/hyperic/hq/dao/ServerDAO.java =================================================================== --- trunk/src/org/hyperic/hq/dao/ServerDAO.java 2007-05-23 18:55:14 UTC (rev 4510) +++ trunk/src/org/hyperic/hq/dao/ServerDAO.java 2007-05-23 18:56:28 UTC (rev 4511) @@ -145,6 +145,8 @@ return getSession().createQuery(sql) .setInteger(0, id.intValue()) .setBoolean(1, virtual.booleanValue()) + .setCacheable(true) + .setCacheRegion("Server.findByPlatform_orderName") .list(); } @@ -171,6 +173,8 @@ .setInteger(0, id.intValue()) .setInteger(1, tid.intValue()) .setBoolean(2, isVirtual.booleanValue()) + .setCacheable(true) + .setCacheRegion("Server.findByPlatformAndType_orderName") .list(); } Modified: trunk/src/org/hyperic/hq/dao/VirtualDAO.java =================================================================== --- trunk/src/org/hyperic/hq/dao/VirtualDAO.java 2007-05-23 18:55:14 UTC (rev 4510) +++ trunk/src/org/hyperic/hq/dao/VirtualDAO.java 2007-05-23 18:56:28 UTC (rev 4511) @@ -68,6 +68,8 @@ return getSession().createQuery(sql) .setString(0, rtName) .setInteger(1, id.intValue()) + .setCacheable(true) + .setCacheRegion("Virtual.findVirtualByPhysicalId") .list(); } Modified: trunk/src/org/hyperic/hq/measurement/server/session/DerivedMeasurementDAO.java =================================================================== --- trunk/src/org/hyperic/hq/measurement/server/session/DerivedMeasurementDAO.java 2007-05-23 18:55:14 UTC (rev 4510) +++ trunk/src/org/hyperic/hq/measurement/server/session/DerivedMeasurementDAO.java 2007-05-23 18:56:28 UTC (rev 4511) @@ -31,6 +31,7 @@ import java.util.Map; import org.hibernate.Query; +import org.hibernate.criterion.Restrictions; import org.hyperic.dao.DAOFactory; import org.hyperic.hq.appdef.shared.AppdefEntityID; import org.hyperic.hq.appdef.shared.AppdefUtil; @@ -78,9 +79,9 @@ } List findAllCollected() { - String sql = "from DerivedMeasurement m " + - "where m.interval is not null"; - return getSession().createQuery(sql).list(); + return createCriteria() + .add(Restrictions.isNotNull("interval")) + .list(); } public DerivedMeasurement findByTemplateForInstance(Integer tid, @@ -254,22 +255,18 @@ } List findDesignatedByInstanceForCategory(int appdefType, int iid, - String cat) { - String sql = - "select distinct m from DerivedMeasurement m " + - "join m.template t " + - "join t.monitorableType mt " + - "where m.instanceId = ? " + - "and t.designate = true " + - "and mt.appdefType = ? " + - "and t.category.name = ?"; - - return getSession().createQuery(sql) - .setInteger(0, iid) - .setInteger(1, appdefType) - .setCacheable(true) - .setCacheRegion("DerivedMeasurement.findDesignatedByInstanceForCategory") - .setString(2, cat).list(); + String cat) + { + List res = findDesignatedByInstance(appdefType, iid); + + for (Iterator i=res.iterator(); i.hasNext(); ) { + DerivedMeasurement dm = (DerivedMeasurement)i.next(); + + if (!dm.getTemplate().getCategory().getName().equals(cat)) + i.remove(); + } + + return res; } List findDesignatedByInstance(int type, int id) { Modified: trunk/src/org/hyperic/hq/measurement/server/session/DerivedMeasurementManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/measurement/server/session/DerivedMeasurementManagerEJBImpl.java 2007-05-23 18:55:14 UTC (rev 4510) +++ trunk/src/org/hyperic/hq/measurement/server/session/DerivedMeasurementManagerEJBImpl.java 2007-05-23 18:56:28 UTC (rev 4511) @@ -1413,9 +1413,8 @@ * @ejb:interface-method */ public void preload() { - StopWatch s = new StopWatch(); - getDerivedMeasurementDAO().findAllCollected(); + getMeasurementTemplateDAO().findAllUsed(); } public static DerivedMeasurementManagerLocal getOne() { Modified: trunk/src/org/hyperic/hq/measurement/server/session/MeasurementTemplateDAO.java =================================================================== --- trunk/src/org/hyperic/hq/measurement/server/session/MeasurementTemplateDAO.java 2007-05-23 18:55:14 UTC (rev 4510) +++ trunk/src/org/hyperic/hq/measurement/server/session/MeasurementTemplateDAO.java 2007-05-23 18:56:28 UTC (rev 4511) @@ -268,6 +268,17 @@ .setInteger(0, tId.intValue()) .setString(1, template).uniqueResult(); } + + List findAllUsed() { + // This should be distinct as well, but see below error about BLOB + String sql = + "select t from MeasurementTemplate t, " + + " DerivedMeasurement dm " + + " where dm.template.id = t.id " + + " and dm.interval is not null"; + + return getSession().createQuery(sql).list(); + } List findDerivedByMonitorableType(String name) { // Oracle doesn't like 'distinct' qualifier on select when |