Author: pnguyen Date: 2009-11-20 15:01:31 -0800 (Fri, 20 Nov 2009) New Revision: 13983 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=13983 Added: branches/HQ_4_2/web/resource/common/monitor/visibility/ParticipatingResourcesSMMR.jsp Modified: branches/HQ_4_2/src/org/hyperic/hq/ui/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java branches/HQ_4_2/web/WEB-INF/tiles/resource-common-def.xml branches/HQ_4_2/web/resource/common/monitor/visibility/ChartLayout.jsp Log: [HQ-1916] To improve the performance of SMMR charts, get the metric display summary for only the first resource since the UI does not need the rest of the data. Modified: branches/HQ_4_2/src/org/hyperic/hq/ui/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java =================================================================== --- branches/HQ_4_2/src/org/hyperic/hq/ui/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java 2009-11-20 15:39:14 UTC (rev 13982) +++ branches/HQ_4_2/src/org/hyperic/hq/ui/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java 2009-11-20 23:01:31 UTC (rev 13983) @@ -88,6 +88,7 @@ import org.hyperic.util.config.ConfigResponse; import org.hyperic.util.pager.PageControl; import org.hyperic.util.pager.PageList; +import org.hyperic.util.timer.StopWatch; /** * An <code>Action</code> that retrieves data from the BizApp to @@ -107,6 +108,10 @@ ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + + final boolean debug = log.isDebugEnabled(); + StopWatch watch = new StopWatch(); + super.workflow(cc, mapping, form, request, response); ViewChartForm chartForm = (ViewChartForm)form; @@ -138,22 +143,33 @@ MeasurementBoss mb = ContextUtils.getMeasurementBoss(ctx); + if (debug) watch.markTimeBegin("_setupResources"); AppdefResourceValue[][] resources = _setupResources(request, sessionId, chartForm, resource, mb); + if (debug) watch.markTimeEnd("_setupResources"); try { if (resources.length == 0 || resources[0].length == 0) throw new MeasurementNotFoundException( "No resources found for chart"); + if (debug) watch.markTimeBegin("_setupMetricData"); _setupMetricData(request, sessionId, chartForm, resources[1], mb, ctx); + if (debug) watch.markTimeEnd("_setupMetricData"); } catch (MeasurementNotFoundException e) { return removeBadDashboardLink(request, ctx); } + if (debug) watch.markTimeBegin("_setupPageData"); + _setupPageData(request, sessionId, chartForm, resources[0], mb); - + + if (debug) { + watch.markTimeEnd("_setupPageData"); + log.debug("workflow: " + watch); + } + return null; } @@ -244,6 +260,10 @@ throws SessionTimeoutException, SessionException, AppdefEntityNotFoundException, PermissionException, RemoteException, MeasurementNotFoundException { + + final boolean debug = log.isDebugEnabled(); + StopWatch watch = new StopWatch(); + ServletContext ctx = getServlet().getServletContext(); // get list of all child resources AppdefResourceValue[] resources = null; @@ -253,9 +273,11 @@ AppdefBoss ab = ContextUtils.getAppdefBoss(ctx); AppdefEntityTypeID atid = new AppdefEntityTypeID(chartForm.getCtype()); + if (debug) watch.markTimeBegin("findChildResources"); PageList children = ab.findChildResources( sessionId, adeId, atid, PageControl.PAGE_ALL ); + if (debug) watch.markTimeEnd("findChildResources"); String[] rids = request.getParameterValues("r"); Integer[] r = ArrayUtil.stringToInteger(rids); // if we've been passed a list of resource ids, we are @@ -287,15 +309,21 @@ grpVal.getAppdefGroupEntries().toArray(grpMembers); AppdefBoss ab = ContextUtils.getAppdefBoss(ctx); + if (debug) watch.markTimeBegin("findByIds"); List memVals = ab.findByIds(sessionId, grpMembers, PageControl.PAGE_ALL); + if (debug) watch.markTimeEnd("findByIds"); resources = new AppdefResourceValue[memVals.size()]; resources = (AppdefResourceValue[]) memVals.toArray(resources); } else { resources = new AppdefResourceValue[] { resource }; } + + if (debug) watch.markTimeBegin("pruneResourcesNotCollecting"); resources = mb.pruneResourcesNotCollecting(sessionId, resources, chartForm.getM()[0]); + if (debug) watch.markTimeEnd("pruneResourcesNotCollecting"); + request.setAttribute("resources", resources); request.setAttribute( "resourcesSize", new Integer(resources.length) ); @@ -303,29 +331,30 @@ // is the same as resources and chartForm.resourceIds contains // all resource ids String[] resourceIds = request.getParameterValues("resourceIds"); + AppdefResourceValue[] checkedResources = null; + + if (debug) watch.markTimeBegin("checkedResources"); + if (null == resourceIds || resourceIds.length == 0) { int maxResources = _getMaxResources(request, resources.length); log.debug("maxResources=" + maxResources); - AppdefResourceValue[] checkedResources = - new AppdefResourceValue[maxResources]; + checkedResources = new AppdefResourceValue[maxResources]; System.arraycopy(resources, 0, checkedResources, 0, maxResources); Integer[] rids = new Integer[checkedResources.length]; for (int i = 0; i < rids.length; ++i) { rids[i] = checkedResources[i].getId(); } chartForm.setResourceIds(rids); - if (log.isDebugEnabled()) { + if (debug) { log.debug("no resourceIds specified: " + StringUtil.arrayToString(rids)); } request.setAttribute("checkedResources", checkedResources); request.setAttribute("checkedResourcesSize", new Integer(checkedResources.length)); - return new AppdefResourceValue[][] { resources, checkedResources }; } else { Integer[] rids = chartForm.getResourceIds(); - AppdefResourceValue[] checkedResources = - new AppdefResourceValue[rids.length]; + checkedResources = new AppdefResourceValue[rids.length]; for (int i=0; i<rids.length; ++i) { for (int j=0; j<resources.length; ++j) { if ( resources[j].getId().equals(rids[i]) ) { @@ -333,15 +362,21 @@ } } } - if ( log.isDebugEnabled() ) { + if (debug) { log.debug( "resourceIds specified: " + org.hyperic.util.StringUtil.arrayToString(rids) ); } request.setAttribute("checkedResources", checkedResources); request.setAttribute("checkedResourcesSize", - new Integer(checkedResources.length) ); - return new AppdefResourceValue[][] {resources, checkedResources}; + new Integer(checkedResources.length) ); } + + if (debug) { + watch.markTimeEnd("checkedResources"); + log.debug("_setupResources: " + watch); + } + + return new AppdefResourceValue[][] {resources, checkedResources}; } private void _setupMetricData(HttpServletRequest request, int sessionId, @@ -353,6 +388,7 @@ RemoteException, AppdefEntityNotFoundException, PermissionException { + final boolean debug = log.isDebugEnabled(); EventLogBoss eb = ContextUtils.getEventLogBoss(ctx); List eventPointsList = new ArrayList(resources.length); @@ -365,7 +401,7 @@ // data points for chart Integer m[] = chartForm.getM(); String[] chartDataKeys = new String[m.length]; - log.trace("number of metrics: " + m.length); + if (debug) log.debug("number of metrics: " + m.length); for (int i = 0; i < m.length; ++i) { // Use the current time concatenated with metric @@ -374,7 +410,7 @@ String.valueOf( System.currentTimeMillis() ) + m[i]; for (int j = 0; j < resources.length; ++j) { - if (log.isDebugEnabled()) { + if (debug) { log.debug("mtid=" + m[i] + ", rid=" + resources[j].getId()); log.debug("startDate=" + chartForm.getStartDate()); log.debug("endDate=" + chartForm.getEndDate()); @@ -404,7 +440,7 @@ } } } - log.debug("Store into session: " + chartDataKeys[i]); + if (debug) log.debug("Store into session: " + chartDataKeys[i]); } request.setAttribute(Constants.CHART_DATA_KEYS_SIZE, new Integer( chartDataKeys.length)); @@ -435,24 +471,44 @@ AppdefEntityNotFoundException, PermissionException, AppdefCompatException, RemoteException, MeasurementNotFoundException, BaselineCreationException { + + final boolean debug = log.isDebugEnabled(); + StopWatch watch = new StopWatch(); + List mtids = Arrays.asList( chartForm.getOrigM() ); ArrayList metricSummaries = new ArrayList(); - for (int i=0; i<resources.length; ++i) { + + if (debug) watch.markTimeBegin("findMetrics"); + + for (int i=0; i<resources.length; ++i) { Map metrics = mb.findMetrics(sessionId, resources[i].getEntityId(), mtids, chartForm.getStartDate().getTime(), chartForm.getEndDate().getTime() ); - MonitorUtils.formatMetrics( metrics, request.getLocale(), - getResources(request) ); - for (Iterator it = metrics.values().iterator(); it.hasNext();) { - metricSummaries.addAll( (Collection) it.next() ); + + for (Iterator it=metrics.entrySet().iterator(); it.hasNext();) { + Map.Entry entry = (Map.Entry)it.next(); + metricSummaries.addAll( (Collection)entry.getValue() ); } + + if (chartForm.getMode().equals(Constants.MODE_MON_CHART_SMMR) + && !metricSummaries.isEmpty()) { + // HQ-1916: For SMMR charts, get the metric display summary + // for only the first resource + break; + } } + Collections.sort(metricSummaries, comp); request.setAttribute("metricSummaries", metricSummaries); request.setAttribute("metricSummariesSize", new Integer(metricSummaries.size())); + if (debug) { + watch.markTimeEnd("findMetrics"); + watch.markTimeBegin("chartedMetrics"); + } + // pick out the charted metrics from the metric summaries ChartedMetricBean[] chartedMetrics = new ChartedMetricBean[chartForm.getM().length]; @@ -472,10 +528,21 @@ } } } + + if (debug) watch.markTimeEnd("chartedMetrics"); + request.setAttribute("chartedMetrics", chartedMetrics); - - _setupBaselineExpectedRange(request, sessionId, chartForm, resources, - chartedMetrics, mb); + + if (chartedMetrics.length > 0 && chartedMetrics[0] != null) { + watch.markTimeBegin("_setupBaselineExpectedRange"); + _setupBaselineExpectedRange(request, sessionId, chartForm, + resources, chartedMetrics, mb); + watch.markTimeEnd("_setupBaselineExpectedRange"); + } + + if (debug) { + log.debug("_setupPageData: " + watch); + } } protected void _setupBaselineExpectedRange(HttpServletRequest request, Modified: branches/HQ_4_2/web/WEB-INF/tiles/resource-common-def.xml =================================================================== --- branches/HQ_4_2/web/WEB-INF/tiles/resource-common-def.xml 2009-11-20 15:39:14 UTC (rev 13982) +++ branches/HQ_4_2/web/WEB-INF/tiles/resource-common-def.xml 2009-11-20 23:01:31 UTC (rev 13983) @@ -173,6 +173,9 @@ <definition name=".resource.common.monitor.visibility.charts.metric.partrsrcs" path="/resource/common/monitor/visibility/ParticipatingResources.jsp"/> + <definition name=".resource.common.monitor.visibility.charts.metric.partrsrcs.smmr" + path="/resource/common/monitor/visibility/ParticipatingResourcesSMMR.jsp"/> + <definition name=".resource.common.monitor.visibility.charts.metric.chartlegend" path="/resource/common/monitor/visibility/ChartLegend.jsp"/> Modified: branches/HQ_4_2/web/resource/common/monitor/visibility/ChartLayout.jsp =================================================================== --- branches/HQ_4_2/web/resource/common/monitor/visibility/ChartLayout.jsp 2009-11-20 15:39:14 UTC (rev 13982) +++ branches/HQ_4_2/web/resource/common/monitor/visibility/ChartLayout.jsp 2009-11-20 23:01:31 UTC (rev 13983) @@ -132,8 +132,7 @@ </tiles:insert> <br> <tiles:insert - definition=".resource.common.monitor.visibility.charts.metric.partrsrcs"> - <tiles:put name="multiResource" value="true" /> + definition=".resource.common.monitor.visibility.charts.metric.partrsrcs.smmr"> </tiles:insert> <br> </c:when> Added: branches/HQ_4_2/web/resource/common/monitor/visibility/ParticipatingResourcesSMMR.jsp =================================================================== --- branches/HQ_4_2/web/resource/common/monitor/visibility/ParticipatingResourcesSMMR.jsp (rev 0) +++ branches/HQ_4_2/web/resource/common/monitor/visibility/ParticipatingResourcesSMMR.jsp 2009-11-20 23:01:31 UTC (rev 13983) @@ -0,0 +1,103 @@ +<%@ taglib uri="struts-html-el" prefix="html" %> +<%@ taglib uri="struts-tiles" prefix="tiles" %> +<%@ taglib uri="jstl-fmt" prefix="fmt" %> +<%@ taglib uri="jstl-c" prefix="c" %> +<%@ taglib uri="hq" prefix="hq" %> +<%-- + NOTE: This copyright does *not* cover user programs that use HQ + program services by normal system calls through the application + program interfaces provided as part of the Hyperic Plug-in Development + Kit or the Hyperic Client Development Kit - this is merely considered + normal use of the program, and does *not* fall under the heading of + "derived work". + + Copyright (C) [2004-2009], Hyperic, Inc. + This file is part of HQ. + + HQ is free software; you can redistribute it and/or modify + it under the terms version 2 of the GNU General Public License as + published by the Free Software Foundation. This program is distributed + in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + even the implied warranty of MERCHANTABILITY or FITNESS FOR A + PARTICULAR PURPOSE. See the GNU General Public License for more + details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. + --%> + +<html:hidden property="m" value="${ViewChartForm.m[0]}"/> + +<c:set var="widgetInstanceName" value="listMetrics"/> +<script type="text/javascript"> +var pageData = new Array(); +initializeWidgetProperties('<c:out value="${widgetInstanceName}"/>'); +widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>'); +</script> + +<!-- PARTICIPATING RESOURCE TITLE --> +<tiles:insert definition=".header.tab"> +<tiles:put name="tabKey" value="resource.common.monitor.visibility.chart.ParticipatingResourceTab"/> +</tiles:insert> +<!-- / --> + +<div id="listDiv"> +<table width="100%" cellpadding="0" cellspacing="0" border="0" id="listTable"> + <tr class="ListHeaderDark"> + <td width="29%" class="ListHeaderInactiveSorted"><fmt:message + key="resource.common.monitor.visibility.MetricNameTH"/></td> + <td width="1%" class="ListHeaderInactiveSorted"><html:img + page="/images/spacer.gif" width="1" height="1" alt="" + border="0"/></td> + <td width="69%" class="ListHeaderInactiveSorted"><fmt:message + key="resource.common.monitor.visibility.ResourceTH"/></td> + </tr> + <c:forEach var="resource" varStatus="rStatus" items="${resources}"> + <c:url var="resourceUrl" value="/Resource.do"> + <c:param name="rid" value="${resource.id}"/> + <c:param name="type" value="${resource.entityId.type}"/> + </c:url> + <tr class="ListRow"> + <c:if test="${rStatus.first}"> + <td rowspan="<c:out value='${resourcesSize}'/>" + class="ListCellPrimary" valign="top"><c:out value="${metricSummaries[0].label}"/></td> + </c:if> + <c:set var="maxResources"><c:out value="${checkedResourcesSize}"/></c:set> + <c:set var="maxMessage"> + <fmt:message key="resource.common.monitor.visibility.chart.TooManyResources"> + <fmt:param value="${maxResources}"/> + </fmt:message> + </c:set> + <td class="ListCellLeftLineNoPadding" valign="top"><html:multibox + property="resourceIds" value="${resource.id}" + onclick="ToggleSelection(this, widgetProperties, ${maxResources}, '${maxMessage}');" + styleClass="resourceList"/></td> + <c:set var="resCellClass" value="ListCellPrimary"/> + <td + class="<c:out value='${resCellClass}'/>" valign="top"> + <html:link href="${resourceUrl}"><c:out value="${resource.name}"/></html:link> + </td> + </tr> + </c:forEach> +</table> + +<!-- REDRAW SELECTED TOOLBAR --> +<table width="100%" cellpadding="5" cellspacing="0" border="0" class="ToolbarContent"> + <tr> + <td id="<c:out value="${widgetInstanceName}"/>RedrawTd"><div + id="<c:out value="${widgetInstanceName}"/>RedrawDiv"><html:img + page="/images/tbb_redrawselectedonchart_gray.gif" width="171" + height="16" alt="" border="0"/></div></td> + <td width="100%" align="right"> </td> + </tr> +</table> +<!-- / --> + +</div> + +<input type="Hidden" id="privateChart"> +<script type="text/javascript"> + testCheckboxes('<c:out value="${widgetInstanceName}"/>'); +</script> |