[prev in list] [next in list] [prev in thread] [next in thread]
List: rhq-commits
Subject: [rhq] modules/enterprise
From: mike thompson <mithomps () fedoraproject ! org>
Date: 2013-12-13 23:54:42
Message-ID: 20131213235442.7486260CDF () fedorahosted ! org
[Download RAW message or body]
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java \
| 1 modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java \
| 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java \
| 408 ++++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java \
| 193 ++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java \
| 314 +++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java \
| 223 +++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java \
| 63 + modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java \
| 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java \
| 30 modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java \
| 56 - modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java \
| 224 ----- 11 files changed, 1240 insertions(+), 278 deletions(-)
New commits:
commit 1b05bf1c0d1976e7109e163e10cdc0c736fec9e0
Author: Mike Thompson <mithomps@redhat.com>
Date: Fri Dec 13 15:51:56 2013 -0800
[BZ 1034512] Update Group Metric Graphs to be more like new Resource Metrics \
Graphs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
index d0b56a7..f6805e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
@@ -189,6 +189,7 @@ public final class D3GroupGraphListView extends \
AbstractD3GraphListView implemen
private void buildIndividualGraph(MeasurementDefinition measurementDefinition,
List<MeasurementDataNumericHighLowComposite> data) {
+ Log.debug("\n***** D3GroupGraphListView.MD: "+measurementDefinition);
MetricGraphData metricGraphData = \
MetricGraphData.createForResourceGroup(resourceGroup.getId(), \
resourceGroup.getName(), measurementDefinition, data);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9ddbb77..8394217 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -63,6 +63,7 @@ import \
org.rhq.coregui.client.inventory.groups.detail.configuration.HistoryGroup import \
org.rhq.coregui.client.inventory.groups.detail.inventory.GroupPluginConfigurationEditView;
import org.rhq.coregui.client.inventory.groups.detail.inventory.HistoryGroupPluginConfigurationView;
import org.rhq.coregui.client.inventory.groups.detail.inventory.MembersView;
+import org.rhq.coregui.client.inventory.groups.detail.monitoring.metric.MetricsGroupView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.schedules.ResourceGroupSchedulesView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.table.GroupMonitoringTablesView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
@@ -332,7 +333,7 @@ public class ResourceGroupDetailView extends
viewFactory = (!showOnPage) ? null : new ViewFactory() {
@Override
public Canvas createView() {
- return createD3GraphListView();
+ return \
MetricsGroupView.create(groupComposite.getResourceGroup()); }
};
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
new file mode 100644
index 0000000..89d4f67
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
@@ -0,0 +1,408 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.METRIC_DEF_ID;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.RESOURCE_GROUP_ID;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.ExpansionMode;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
+import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import com.smartgwt.client.widgets.grid.events.RecordCollapseEvent;
+import com.smartgwt.client.widgets.grid.events.RecordCollapseHandler;
+import com.smartgwt.client.widgets.grid.events.RecordExpandEvent;
+import com.smartgwt.client.widgets.grid.events.RecordExpandHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionEvent;
+import com.smartgwt.client.widgets.grid.events.SortChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SortEvent;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.components.table.Table;
+import org.rhq.coregui.client.dashboard.portlets.inventory.groups.graph.ResourceGroupD3GraphPortlet;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.inventory.common.graph.MetricGraphData;
+import org.rhq.coregui.client.inventory.common.graph.Refreshable;
+import org.rhq.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.MetricD3Graph;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.Log;
+import org.rhq.coregui.client.util.message.Message;
+
+/**
+ * Views a resource's metrics in a tabular view with sparkline graph and optional \
detailed d3 graph. + *
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> \
implements Refreshable { +
+ private final ResourceGroup resourceGroup;
+ private final AbstractD3GraphListView abstractD3GraphListView;
+ private ToolStrip toolStrip;
+ private SelectItem dashboardSelectItem;
+ private Dashboard selectedDashboard;
+ private IButton addToDashboardButton;
+ private LinkedHashMap<String, String> dashboardMenuMap;
+ private LinkedHashMap<Integer, Dashboard> dashboardMap;
+ private Set<Integer> expandedRows;
+ private MetricsTableListGrid metricsTableListGrid;
+ private int selectedMetricDefinitionId;
+
+ public MetricsGroupTableView(ResourceGroup resourceGroup, \
AbstractD3GraphListView abstractD3GraphListView, + Set<Integer> expandedRows) \
{ + super();
+ this.resourceGroup = resourceGroup;
+ this.abstractD3GraphListView = abstractD3GraphListView;
+ dashboardMenuMap = new LinkedHashMap<String, String>();
+ dashboardMap = new LinkedHashMap<Integer, Dashboard>();
+ setDataSource(new MetricsGroupViewDataSource(resourceGroup));
+ this.expandedRows = expandedRows;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ }
+
+ /**
+ * Creates this Table's list grid (called by onInit()). Subclasses can override \
this if they require a custom + * subclass of ListGrid.
+ *
+ * @return this Table's list grid (must be an instance of ListGrid)
+ */
+ @Override
+ protected ListGrid createListGrid() {
+ metricsTableListGrid = new MetricsTableListGrid(this, resourceGroup);
+ metricsTableListGrid.addSelectionChangedHandler(new \
SelectionChangedHandler() { + @Override
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ if (resourceGroup.getGroupCategory() == GroupCategory.COMPATIBLE) {
+ addToDashboardButton.enable();
+ ListGridRecord selectedRecord = \
selectionEvent.getSelectedRecord(); + if (null != selectedRecord) \
{ + selectedMetricDefinitionId = \
selectedRecord.getAttributeAsInt(METRIC_DEF_ID.getValue()); + }
+ }
+ }
+ });
+
+ if (null == toolStrip) {
+ toolStrip = createToolstrip();
+ }
+ addExtraWidget(toolStrip, false);
+ addToDashboardButton.disable();
+ return metricsTableListGrid;
+ }
+
+ protected void configureTable() {
+ ArrayList<ListGridField> fields = getDataSource().getListGridFields();
+ setListGridFields(fields.toArray(new ListGridField[0]));
+ }
+
+ private ToolStrip createToolstrip() {
+ toolStrip = new ToolStrip();
+ toolStrip.setWidth(300);
+ toolStrip.setMembersMargin(15);
+ toolStrip.setPadding(5);
+ toolStrip.addSpacer(10);
+ addToDashboardButton = new \
IButton(MSG.chart_metrics_add_to_dashboard_button()); + \
addToDashboardButton.setWidth(80); + dashboardSelectItem = new SelectItem();
+ dashboardSelectItem.setTitle(MSG.chart_metrics_add_to_dashboard_label());
+ dashboardSelectItem.setWidth(240);
+ dashboardSelectItem.setWrapTitle(false);
+ populateDashboardMenu();
+ toolStrip.addFormItem(dashboardSelectItem);
+ toolStrip.addMember(addToDashboardButton);
+
+ dashboardSelectItem.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ Integer selectedDashboardId = Integer.valueOf((String) \
changeEvent.getValue()); + selectedDashboard = \
dashboardMap.get(selectedDashboardId); + }
+ });
+ addToDashboardButton.addClickHandler(new \
com.smartgwt.client.widgets.events.ClickHandler() { + @Override
+ public void onClick(ClickEvent clickEvent) {
+ for (MeasurementDefinition measurementDefinition : \
resourceGroup.getResourceType() + .getMetricDefinitions()) {
+ if (measurementDefinition.getId() == selectedMetricDefinitionId) \
{ + Log.debug("Add to Dashboard -- Storing: " + \
measurementDefinition.getDisplayName() + " in " + + \
selectedDashboard.getName()); +
+ storeDashboardMetric(selectedDashboard, \
resourceGroup.getId(), measurementDefinition); + break;
+ }
+ }
+ }
+ });
+ return toolStrip;
+ }
+
+ @Override
+ /**
+ * Redraw Graphs in this context means to refresh the table and redraw open \
graphs. + */
+ public void refreshData() {
+ new Timer() {
+ @Override
+ public void run() {
+ metricsTableListGrid.expandOpenedRows();
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh(false);
+ metricsTableListGrid.expandOpenedRows();
+ }
+
+ private void populateDashboardMenu() {
+ dashboardMenuMap.clear();
+ dashboardMap.clear();
+
+ DashboardCriteria criteria = new DashboardCriteria();
+ GWTServiceLookup.getDashboardService().findDashboardsByCriteria(criteria,
+ new AsyncCallback<PageList<Dashboard>>() {
+
+ public void onFailure(Throwable caught) {
+ \
CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(),
+ caught);
+ }
+
+ public void onSuccess(PageList<Dashboard> dashboards) {
+ if (dashboards.size() > 0) {
+ for (final Dashboard dashboard : dashboards) {
+ dashboardMenuMap.put(String.valueOf(dashboard.getId()), \
dashboard.getName()); + \
dashboardMap.put(dashboard.getId(), dashboard); + }
+ selectedDashboard = dashboards.get(0);
+ dashboardSelectItem.setValueMap(dashboardMenuMap);
+ dashboardSelectItem.setValue(selectedDashboard.getId());
+ }
+ }
+ });
+ }
+
+ private void storeDashboardMetric(Dashboard dashboard, int resourceGroupId, \
MeasurementDefinition definition) { +
+ DashboardPortlet dashboardPortlet = new \
DashboardPortlet(MSG.view_tree_common_contextMenu_groupGraph(), + \
ResourceGroupD3GraphPortlet.KEY, 260); + \
dashboardPortlet.getConfiguration().put( + new \
PropertySimple(ResourceGroupD3GraphPortlet.CFG_RESOURCE_GROUP_ID, resourceGroupId)); \
+ dashboardPortlet.getConfiguration().put( + new \
PropertySimple(ResourceGroupD3GraphPortlet.CFG_DEFINITION_ID, definition.getId())); +
+ dashboard.addPortlet(dashboardPortlet);
+
+ GWTServiceLookup.getDashboardService().storeDashboard(dashboard, new \
AsyncCallback<Dashboard>() { + public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(),
+ caught);
+ }
+
+ public void onSuccess(Dashboard result) {
+ String msg = \
MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result.getName()); + \
CoreGUI.getMessageCenter().notify(new Message(msg, Message.Severity.Info)); + \
} + });
+ }
+
+ public class MetricsTableListGrid extends ListGrid {
+
+ private static final int TREEVIEW_DETAIL_CHART_HEIGHT = 205;
+ private static final int NUM_METRIC_POINTS = 60;
+ final MetricsGroupTableView metricsTableView;
+ private ResourceGroup group;
+
+ public MetricsTableListGrid(final MetricsGroupTableView metricsTableView, \
final ResourceGroup group) { + super();
+ this.group = group;
+ this.metricsTableView = metricsTableView;
+ setCanExpandRecords(true);
+ setSelectionType(SelectionStyle.SINGLE);
+ setCanExpandMultipleRecords(true);
+ setExpansionMode(ExpansionMode.DETAIL_FIELD);
+
+ addRecordExpandHandler(new RecordExpandHandler() {
+ @Override
+ public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
+ \
metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt( + \
METRIC_DEF_ID.getValue())); + refreshData();
+ }
+
+ });
+ addRecordCollapseHandler(new RecordCollapseHandler() {
+ @Override
+ public void onRecordCollapse(RecordCollapseEvent \
recordCollapseEvent) { + \
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
+ METRIC_DEF_ID.getValue()));
+ refresh();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ });
+ addSortChangedHandler(new SortChangedHandler() {
+ @Override
+ public void onSortChanged(SortEvent sortEvent) {
+ refreshData();
+ }
+ });
+
+ addDataArrivedHandler(new DataArrivedHandler() {
+ @Override
+ public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
+ expandOpenedRows();
+ }
+ });
+
+ }
+
+ public void expandOpenedRows() {
+ int startRow = 0;
+ int endRow = this.getRecords().length;
+ for (int i = startRow; i < endRow; i++) {
+ ListGridRecord listGridRecord = getRecord(i);
+ if (null != listGridRecord) {
+ int metricDefinitionId = \
listGridRecord.getAttributeAsInt(METRIC_DEF_ID.getValue()); + if \
(null != metricsTableView && null != expandedRows + && \
metricsTableView.expandedRows.contains(metricDefinitionId)) { + \
expandRecord(listGridRecord); + }
+ }
+ }
+ }
+
+ @Override
+ /**
+ * If you expand a grid row then create a graph.
+ */
+ protected Canvas getExpansionComponent(final ListGridRecord record) {
+ final Integer definitionId = \
record.getAttributeAsInt(METRIC_DEF_ID.getValue()); + final Integer \
resourceGroupId = record.getAttributeAsInt(RESOURCE_GROUP_ID.getValue()); + \
VLayout vLayout = new VLayout(); + vLayout.setPadding(5);
+
+ final String chartId = "rChart-" + resourceGroupId + "-" + definitionId;
+ HTMLFlow htmlFlow = new \
HTMLFlow(MetricD3Graph.createGraphMarkerTemplate(chartId, + \
TREEVIEW_DETAIL_CHART_HEIGHT)); + vLayout.addMember(htmlFlow);
+
+ int[] definitionArrayIds = new int[1];
+ definitionArrayIds[0] = definitionId;
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(resourceGroupId,
+ definitionArrayIds, \
CustomDateRangeState.getInstance().getStartTime(), + \
CustomDateRangeState.getInstance().getEndTime(), NUM_METRIC_POINTS, + \
new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() { + \
@Override + public void onFailure(Throwable caught) {
+ Log.warn("Error retrieving recent metrics charting data for \
resource group [" + resourceGroupId + + "]:" + \
caught.getMessage()); + }
+
+ @Override
+ public void \
onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) { + \
if (!results.isEmpty()) { +
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite> \
measurementList = results.get(0); +
+ MeasurementDefinition measurementDefinition = null;
+ for (MeasurementDefinition definition : \
group.getResourceType().getMetricDefinitions()) { + if \
(definition.getId() == definitionId) { + \
measurementDefinition = definition; + break;
+ }
+ }
+
+ MetricGraphData metricGraphData = \
MetricGraphData.createForResourceGroup(group.getId(), + \
group.getName(), measurementDefinition, measurementList); + \
metricGraphData.setHideLegend(true); +
+ StackedBarMetricGraphImpl graph = \
GWT.create(StackedBarMetricGraphImpl.class); + \
graph.setMetricGraphData(metricGraphData); + final \
MetricD3Graph graphView = new MetricD3Graph(graph, abstractD3GraphListView); + \
new Timer() { + @Override
+ public void run() {
+ graphView.drawJsniChart();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ }.schedule(150);
+
+ } else {
+ Log.warn("No chart data retrieving for resource group [" \
+ resourceGroupId + "-" + + definitionId + "]");
+ }
+ }
+ });
+
+ return vLayout;
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
new file mode 100644
index 0000000..1e07e7a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
@@ -0,0 +1,193 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.measurement.Availability;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.IconEnum;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.ExpandedRowsMomento;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricAvailabilityView;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.async.CountDownLatch;
+import org.rhq.coregui.client.util.enhanced.EnhancedHLayout;
+
+/**
+ * The consolidated metrics view showing metric graphs and availability data both in \
graphical and tabular form. + * @author Mike Thompson
+ */
+public class MetricsGroupView extends AbstractD3GraphListView implements
+ AbstractTwoLevelTabSetView.ViewRenderedListener {
+
+ private static final String COLLAPSED_TOOLTIP = \
MSG.chart_metrics_collapse_tooltip(); + private static final String \
EXPANDED_TOOLTIP = MSG.chart_metrics_expand_tooltip(); +
+ private final ResourceGroup resourceGroup;
+ private EnhancedHLayout expandCollapseHLayout;
+ private MetricsGroupTableView metricsTableView;
+ private static Integer lastResourceGroupId = 0;
+
+ /**
+ * Encapsulate the creation logic and not let it leak out into other objects.
+ * Clear the expanded rows set when changing resources as well.
+ * @see ExpandedRowsMomento
+ * @param group
+ * @return MetricsGroupView
+ */
+ public static MetricsGroupView create(ResourceGroup group ){
+
+ boolean isDifferentResource = (group.getId() != lastResourceGroupId);
+
+ if(isDifferentResource){
+ ExpandedRowsMomento.getInstance().clear();
+ }
+
+ return new MetricsGroupView(group, \
ExpandedRowsMomento.getInstance().getExpandedRows()); +
+ }
+
+ private MetricsGroupView(ResourceGroup resourceGroup, Set<Integer> expandedRows) \
{ + super();
+ setOverflow(Overflow.AUTO);
+ setWidth100();
+ setHeight100();
+ this.resourceGroup = resourceGroup;
+ metricsTableView = new MetricsGroupTableView(resourceGroup, this, \
expandedRows); +
+ final MetricAvailabilityView availabilityDetails = new \
MetricAvailabilityView(resourceGroup.getId()); + availabilityDetails.hide();
+
+ metricsTableView.setHeight100();
+
+ availabilityGraph = AvailabilityD3GraphView.create( new \
AvailabilityOverUnderGraphType(resourceGroup.getId())); +
+ expandCollapseHLayout = new EnhancedHLayout();
+ //add expand/collapse icon
+ final Img expandCollapseArrow = new \
Img(IconEnum.COLLAPSED_ICON.getIcon16x16Path(), 16, 16); + \
expandCollapseArrow.setTooltip(COLLAPSED_TOOLTIP); + \
expandCollapseArrow.setLayoutAlign(VerticalAlignment.BOTTOM); + \
expandCollapseArrow.addClickHandler(new ClickHandler() { + private boolean \
collapsed = true; +
+ @Override
+ public void onClick(ClickEvent event) {
+ collapsed = !collapsed;
+ if (collapsed) {
+ \
expandCollapseArrow.setSrc(IconEnum.COLLAPSED_ICON.getIcon16x16Path()); + \
expandCollapseArrow.setTooltip(COLLAPSED_TOOLTIP); + \
availabilityDetails.hide(); + } else {
+ \
expandCollapseArrow.setSrc(IconEnum.EXPANDED_ICON.getIcon16x16Path()); + \
expandCollapseArrow.setTooltip(EXPANDED_TOOLTIP); + \
availabilityDetails.show(); +
+ }
+ drawAvailabilityGraphAndSparklines();
+ }
+ });
+ expandCollapseHLayout.addMember(expandCollapseArrow);
+ addAvailabilityGraph();
+
+ addMember(buttonBarDateTimeRangeEditor);
+ addMember(expandCollapseHLayout);
+ addMember(availabilityDetails);
+ addMember(metricsTableView);
+ lastResourceGroupId = resourceGroup.getId();
+ }
+
+
+ private void addAvailabilityGraph() {
+ expandCollapseHLayout.removeMember(availabilityGraph);
+ availabilityGraph.destroy();
+
+ availabilityGraph = AvailabilityD3GraphView.create(new \
AvailabilityOverUnderGraphType(resourceGroup.getId())); +
+ expandCollapseHLayout.addMember(availabilityGraph);
+
+ queryAvailability(EntityContext.forGroup(resourceGroup.getId()), \
CustomDateRangeState.getInstance().getStartTime(), + \
CustomDateRangeState.getInstance().getEndTime(), null); + }
+
+
+ @Override
+ protected void queryAvailability(final EntityContext context, Long startTime, \
Long endTime, CountDownLatch notUsed) { +
+ // now return the availability
+ GWTServiceLookup.getAvailabilityService().getAvailabilitiesForResource(context.getGroupId(), \
startTime, + endTime, new AsyncCallback<List<Availability>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_availability_loadFailed(), \
caught); + }
+
+ @Override
+ public void onSuccess(List<Availability> availList) {
+ availabilityGraph.setAvailabilityList(availList);
+ new Timer() {
+ @Override
+ public void run() {
+ buttonBarDateTimeRangeEditor.updateTimeRangeToNow();
+ availabilityGraph.drawJsniChart();
+
+ }
+ }.schedule(150);
+ }
+ });
+ }
+
+ private void drawAvailabilityGraphAndSparklines() {
+ new Timer() {
+ @Override
+ public void run() {
+ availabilityGraph.drawJsniChart();
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+
+ @Override
+ public void refreshData() {
+ addAvailabilityGraph();
+ metricsTableView.refresh();
+ }
+
+ @Override
+ public void onViewRendered() {
+ // refresh the graphs on subtab nav because we are a cached view not new
+ refreshData();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
new file mode 100644
index 0000000..a5f1353
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
@@ -0,0 +1,314 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
+import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.Log;
+import org.rhq.coregui.client.util.MeasurementUtility;
+import org.rhq.coregui.client.util.RPCDataSource;
+import org.rhq.coregui.client.util.async.Command;
+import org.rhq.coregui.client.util.async.CountDownLatch;
+
+import static org.rhq.core.domain.measurement.DataType.COMPLEX;
+import static org.rhq.core.domain.measurement.DataType.MEASUREMENT;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
+/**
+ * A simple data source to read in metric data summaries for a resource.
+ * This doesn't support paging - everything is returned in one query. Since
+ * the number of metrics per resource is relatively small (never more than tens of \
them), + * we just load them all in at once.
+ *
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySummary, \
Criteria> { +
+ private static final int NUMBER_OF_METRIC_POINTS = 60;
+
+ private final ResourceGroup resourceGroup;
+ private List<MetricDisplaySummary> metricDisplaySummaries;
+ private List<List<MeasurementDataNumericHighLowComposite>> metricsDataList;
+ private int[] definitionArrayIds;
+
+ public MetricsGroupViewDataSource(ResourceGroup resourceGroup) {
+ this.resourceGroup = resourceGroup;
+ }
+
+ /**
+ * The view that contains the list grid which will display this datasource's \
data will call this + * method to get the field information which is used to \
control the display of the data. + *
+ * @return list grid fields used to display the datasource data
+ */
+ public ArrayList<ListGridField> getListGridFields() {
+ ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
+
+ ListGridField sparklineField = new ListGridField(SPARKLINE.getValue(), \
MSG.chart_metrics_sparkline_header()); + sparklineField.setCellFormatter(new \
CellFormatter() { + @Override
+ public String format(Object value, ListGridRecord record, int rowNum, \
int colNum) { + if (value == null) {
+ return "";
+ }
+ String contents = "<span id='sparkline_" + resourceGroup.getId() + \
"-" + + record.getAttributeAsInt(METRIC_DEF_ID.getValue()) + "' \
class='dynamicsparkline' width='70' " + + "values='" + \
record.getAttribute(SPARKLINE.getValue()) + "'></span>"; + return \
contents; +
+ }
+ });
+
+ sparklineField.setWidth(80);
+ fields.add(sparklineField);
+
+ ListGridField nameField = new ListGridField(METRIC_LABEL.getValue(), \
METRIC_LABEL.getLabel()); + nameField.setWidth("30%");
+ fields.add(nameField);
+
+ ListGridField minField = new ListGridField(MIN_VALUE.getValue(), \
MIN_VALUE.getLabel()); + minField.setWidth("15%");
+ fields.add(minField);
+
+ ListGridField maxField = new ListGridField(MAX_VALUE.getValue(), \
MAX_VALUE.getLabel()); + maxField.setWidth("15%");
+ fields.add(maxField);
+
+ ListGridField avgField = new ListGridField(AVG_VALUE.getValue(), \
AVG_VALUE.getLabel()); + avgField.setWidth("15%");
+ fields.add(avgField);
+
+ ListGridField alertsField = new ListGridField(ALERT_COUNT.getValue(), \
ALERT_COUNT.getLabel()); + alertsField.setWidth("10%");
+ fields.add(alertsField);
+
+ return fields;
+ }
+
+ @Override
+ public MetricDisplaySummary copyValues(Record from) {
+ // we should never need this method - we only go in one direction
+ // if we ever need this, just have copyValues store an "object" attribute \
whose value is "from" + // which this method then just reads out. Since we \
don't need this now, save memory by not + // keeping the MetricDisplayValue \
around + return null;
+ }
+
+ @Override
+ public ListGridRecord copyValues(MetricDisplaySummary from) {
+ MeasurementUtility.formatSimpleMetrics(from);
+
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(SPARKLINE.getValue(), \
getCsvMetricsForSparkline(from.getDefinitionId())); + \
record.setAttribute(METRIC_LABEL.getValue(), from.getLabel()); + \
record.setAttribute(ALERT_COUNT.getValue(), String.valueOf(from.getAlertCount())); + \
record.setAttribute(MIN_VALUE.getValue(), getMetricStringValue(from.getMinMetric())); \
+ record.setAttribute(MAX_VALUE.getValue(), \
getMetricStringValue(from.getMaxMetric())); + \
record.setAttribute(AVG_VALUE.getValue(), getMetricStringValue(from.getAvgMetric())); \
+ record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId()); + \
record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId()); + \
record.setAttribute(METRIC_UNITS.getValue(), from.getUnits()); + \
record.setAttribute(METRIC_NAME.getValue(), from.getMetricName()); + \
record.setAttribute(RESOURCE_GROUP_ID.getValue(), resourceGroup.getId()); + \
return record; + }
+
+ private String getCsvMetricsForSparkline(int definitionId) {
+ StringBuilder sb = new StringBuilder();
+ List<MeasurementDataNumericHighLowComposite> selectedMetricsList = \
getMeasurementsForMeasurementDefId(definitionId); +
+ for (MeasurementDataNumericHighLowComposite measurementData : \
selectedMetricsList) { + if (!Double.isNaN(measurementData.getValue())) {
+ sb.append((int) measurementData.getValue());
+ sb.append(",");
+ }
+ }
+
+ if (sb.toString().endsWith(",")) {
+ sb.setLength(sb.length() - 1);
+ }
+ // handle the case where we have just installed the server so not much \
history + // and our date range is set such that only one value returns which \
the + // sparkline graph will not plot anything, so we need at least 2 values
+ if (!sb.toString().contains(",")) {
+ // append another value just so we have 2 values and it will graph
+ return "0," + sb.toString();
+ }
+
+ return sb.toString();
+ }
+
+ private List<MeasurementDataNumericHighLowComposite> \
getMeasurementsForMeasurementDefId(int definitionId) { + int selectedIndex = \
0; +
+ // find the ordinal position as specified when querying the metrics
+ for (int i = 0; i < definitionArrayIds.length; i++) {
+ if (definitionArrayIds[i] == definitionId) {
+ selectedIndex = i;
+ break;
+ }
+ }
+
+ return metricsDataList.get(selectedIndex);
+ }
+
+ protected String getMetricStringValue(MetricDisplayValue value) {
+ return (value != null) ? value.toString() : "";
+ }
+
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // NOTE: we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, \
final Criteria unused) { +
+ // This latch is the last thing that gets executed after we have executed \
the + // 1 query
+ final CountDownLatch countDownLatch = CountDownLatch.create(1, new Command() \
{ +
+ @Override
+ public void execute() {
+
+ // NOTE: this runs after the queryMetricDisplaySummaries is complete
+ queryGroupMetrics(resourceGroup, request, response);
+ }
+ });
+
+ organizeMeasurementDefinitionOrder(resourceGroup);
+ queryMetricDisplaySummaries(definitionArrayIds, \
CustomDateRangeState.getInstance().getStartTime(), + \
CustomDateRangeState.getInstance().getEndTime(), countDownLatch); +
+ }
+
+ private void queryGroupMetrics(final ResourceGroup resourceGroup, final \
DSRequest request, final DSResponse response) { +
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(resourceGroup.getId(),
+ definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), \
NUMBER_OF_METRIC_POINTS, + new \
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() { + \
@Override + public void onFailure(Throwable caught) {
+ Log.warn("Error retrieving recent metrics charting data for \
resource [" + resourceGroup.getId() + + "]:" + \
caught.getMessage()); + }
+
+ @Override
+ public void \
onSuccess(List<List<MeasurementDataNumericHighLowComposite>> measurementDataList) { + \
if (null != measurementDataList && !measurementDataList.isEmpty()) { + \
metricsDataList = measurementDataList; + \
response.setData(buildRecords(metricDisplaySummaries)); + \
processResponse(request.getRequestId(), response); + new \
Timer() { + @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ }
+ });
+
+ }
+
+ private void organizeMeasurementDefinitionOrder(ResourceGroup resourceGroup) {
+ Set<MeasurementDefinition> definitions = \
getMetricDefinitions(resourceGroup); +
+ //build id mapping for measurementDefinition instances Ex. Free Memory -> \
MeasurementDefinition[100071] + final HashMap<String, MeasurementDefinition> \
measurementDefMap = new HashMap<String, MeasurementDefinition>(); + for \
(MeasurementDefinition definition : definitions) { + \
measurementDefMap.put(definition.getDisplayName(), definition); + }
+ //bundle definition ids for asynch call.
+ definitionArrayIds = new int[definitions.size()];
+ final String[] displayOrder = new String[definitions.size()];
+ measurementDefMap.keySet().toArray(displayOrder);
+ //sort the charting data ex. Free Memory, Free Swap Space,..System Load
+ Arrays.sort(displayOrder);
+
+ //organize definitionArrayIds for ordered request on server.
+ int index = 0;
+ for (String definitionToDisplay : displayOrder) {
+ definitionArrayIds[index++] = \
measurementDefMap.get(definitionToDisplay).getId(); + }
+ }
+
+ private void queryMetricDisplaySummaries(int[] measurementDefIds, Long \
startTime, Long endTime, + final CountDownLatch countDownLatch) {
+ GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForCompatibleGroup(
+ resourceGroup.getId(), measurementDefIds, startTime, endTime, false,
+ new AsyncCallback<ArrayList<MetricDisplaySummary>>() {
+ @Override
+ public void onSuccess(ArrayList<MetricDisplaySummary> \
metricDisplaySummaries) { + \
setMetricDisplaySummaries(metricDisplaySummaries); + \
countDownLatch.countDown(); + }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Cannot load metrics", \
caught); + countDownLatch.countDown();
+ }
+ }
+
+ );
+ }
+
+ private void setMetricDisplaySummaries(List<MetricDisplaySummary> \
metricDisplaySummaries) { + this.metricDisplaySummaries = \
metricDisplaySummaries; + }
+
+ private Set<MeasurementDefinition> getMetricDefinitions(ResourceGroup \
resourceGroup) { + Set<MeasurementDefinition> definitions = new \
HashSet<MeasurementDefinition>(); + for (MeasurementDefinition \
measurementDefinition : resourceGroup.getResourceType().getMetricDefinitions()) { + \
if (measurementDefinition.getDataType() == MEASUREMENT || \
measurementDefinition.getDataType() == COMPLEX) { + \
definitions.add(measurementDefinition); + }
+ }
+ return definitions;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
new file mode 100644
index 0000000..4b542c9
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
@@ -0,0 +1,223 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.coregui.client.inventory.resource.detail.monitoring.table;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.util.MeasurementConverterClient;
+import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;
+
+/**
+ * This shows the availability history for a resource.
+ *
+ * @author Jay Shaughnessy
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricAvailabilityView extends EnhancedVLayout {
+
+ private int resourceId;
+ private StaticTextItem currentField;
+ private StaticTextItem availField;
+ private StaticTextItem availTimeField;
+ private StaticTextItem downField;
+ private StaticTextItem downTimeField;
+ private StaticTextItem disabledField;
+ private StaticTextItem disabledTimeField;
+ private StaticTextItem failureCountField;
+ private StaticTextItem disabledCountField;
+ private StaticTextItem mtbfField;
+ private StaticTextItem mttrField;
+ private StaticTextItem unknownField;
+ private StaticTextItem currentTimeField;
+
+ public MetricAvailabilityView(int resourceId) {
+ super();
+
+ this.resourceId = resourceId;
+
+ setWidth100();
+ setHeight(165);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ addMember(createSummaryForm());
+ }
+
+ private DynamicForm createSummaryForm() {
+ DynamicForm form = new DynamicForm();
+ form.setWidth100();
+ form.setAutoHeight();
+ form.setMargin(10);
+ form.setNumCols(4);
+
+ // row 1
+ currentField = new StaticTextItem("current", \
MSG.view_resource_monitor_availability_currentStatus()); + \
currentField.setWrapTitle(false); + currentField.setColSpan(4);
+
+ // row 2
+ availField = new StaticTextItem("avail", MSG.common_title_availability());
+ availField.setWrapTitle(false);
+ prepareTooltip(availField, \
MSG.view_resource_monitor_availability_tooltip_up()); +
+ availTimeField = new StaticTextItem("availTime", \
MSG.view_resource_monitor_availability_uptime()); + \
availTimeField.setWrapTitle(false); + prepareTooltip(availTimeField, \
MSG.view_resource_monitor_availability_uptime_tooltip()); +
+ // row 3
+ downField = new StaticTextItem("down", \
MSG.common_status_avail_down_lower()); + downField.setWrapTitle(false);
+ prepareTooltip(downField, \
MSG.view_resource_monitor_availability_tooltip_down()); +
+ downTimeField = new StaticTextItem("downTime", \
MSG.view_resource_monitor_availability_downtime()); + \
downTimeField.setWrapTitle(false); + prepareTooltip(downTimeField, \
MSG.view_resource_monitor_availability_downtime_tooltip()); +
+ // row 4
+ disabledField = new StaticTextItem("disabled", \
MSG.common_status_avail_disabled_lower()); + \
disabledField.setWrapTitle(false); + prepareTooltip(disabledField, \
MSG.view_resource_monitor_availability_tooltip_disabled()); +
+ disabledTimeField = new StaticTextItem("disabledTime", \
MSG.view_resource_monitor_availability_disabledTime()); + \
disabledTimeField.setWrapTitle(false); + prepareTooltip(disabledTimeField, \
MSG.view_resource_monitor_availability_disabledTime_tooltip()); +
+ // row 5
+ failureCountField = new StaticTextItem("failureCount", \
MSG.view_resource_monitor_availability_numFailures()); + \
failureCountField.setWrapTitle(false); + prepareTooltip(failureCountField, \
MSG.view_resource_monitor_availability_numFailures_tooltip()); +
+ disabledCountField = new StaticTextItem("disabledCount", \
MSG.view_resource_monitor_availability_numDisabled()); + \
disabledCountField.setWrapTitle(false); + prepareTooltip(disabledCountField, \
MSG.view_resource_monitor_availability_numDisabled_tooltip()); +
+ // row 6
+ mtbfField = new StaticTextItem("mtbf", \
MSG.view_resource_monitor_availability_mtbf()); + \
mtbfField.setWrapTitle(false); + prepareTooltip(mtbfField, \
MSG.view_resource_monitor_availability_mtbf_tooltip()); +
+ mttrField = new StaticTextItem("mttr", \
MSG.view_resource_monitor_availability_mttr()); + \
mttrField.setWrapTitle(false); + prepareTooltip(mttrField, \
MSG.view_resource_monitor_availability_mttr_tooltip()); +
+ // row 7
+ unknownField = new StaticTextItem("unknown");
+ unknownField.setWrapTitle(false);
+ unknownField.setColSpan(4);
+ unknownField.setShowTitle(false);
+
+ // row 8
+ currentTimeField = new StaticTextItem("currentTime");
+ currentTimeField.setWrapTitle(false);
+ currentTimeField.setColSpan(4);
+ currentTimeField.setShowTitle(false);
+
+ form.setItems(currentField, availField, availTimeField, downField, \
downTimeField, disabledField, + disabledTimeField, failureCountField, \
disabledCountField, mtbfField, mttrField, unknownField, + \
currentTimeField); +
+ reloadSummaryData();
+
+ return form;
+ }
+
+ private void reloadSummaryData() {
+ GWTServiceLookup.getResourceService().getResourceAvailabilitySummary(resourceId,
+ new AsyncCallback<ResourceAvailabilitySummary>() {
+
+ @Override
+ public void onSuccess(ResourceAvailabilitySummary result) {
+
+ \
currentField.setValue(MSG.view_resource_monitor_availability_currentStatus_value( + \
getAvailabilityTypeMessage(result.getCurrent()), + \
TimestampCellFormatter.format(result.getLastChange().getTime()))); + \
availField.setValue(MeasurementConverterClient.format(result.getUpPercentage(), + \
MeasurementUnits.PERCENTAGE, true)); + \
availTimeField.setValue(MeasurementConverterClient.format((double) \
result.getUpTime(), + MeasurementUnits.MILLISECONDS, true));
+ \
downField.setValue(MeasurementConverterClient.format(result.getDownPercentage(), + \
MeasurementUnits.PERCENTAGE, true)); + \
downTimeField.setValue(MeasurementConverterClient.format((double) \
result.getDownTime(), + MeasurementUnits.MILLISECONDS, true));
+ \
disabledField.setValue(MeasurementConverterClient.format(result.getDisabledPercentage(),
+ MeasurementUnits.PERCENTAGE, true));
+ \
disabledTimeField.setValue(MeasurementConverterClient.format((double) \
result.getDisabledTime(), + MeasurementUnits.MILLISECONDS, \
true)); + failureCountField.setValue(result.getFailures());
+ disabledCountField.setValue(result.getDisabled());
+ mtbfField.setValue(MeasurementConverterClient.format((double) \
result.getMTBF(), + MeasurementUnits.MILLISECONDS, true));
+ mttrField.setValue(MeasurementConverterClient.format((double) \
result.getMTTR(), + MeasurementUnits.MILLISECONDS, true));
+
+ if (result.getUnknownTime() > 0L) {
+ \
unknownField.setValue(MSG.view_resource_monitor_availability_unknown(MeasurementConverterClient
+ .format((double) result.getUnknownTime(), \
MeasurementUnits.MILLISECONDS, true))); + } else {
+ unknownField.setValue("");
+ }
+
+ \
currentTimeField.setValue(MSG.view_resource_monitor_availability_currentAsOf(TimestampCellFormatter
+ .format(result.getCurrentTime())));
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ currentField.setValue(MSG.common_label_error());
+ CoreGUI.getErrorHandler()
+ \
.handleError(MSG.view_resource_monitor_availability_summaryError(), caught); + \
} + });
+ }
+
+ private String getAvailabilityTypeMessage(AvailabilityType availabilityType) {
+ switch (availabilityType) {
+ case UP:
+ return MSG.common_status_avail_up();
+ case DOWN:
+ return MSG.common_status_avail_down();
+ case DISABLED:
+ return MSG.common_status_avail_disabled();
+ case UNKNOWN:
+ default:
+ return MSG.common_status_avail_unknown();
+ }
+ }
+
+ private void prepareTooltip(FormItem item, String tooltip) {
+ item.setHoverWidth(400);
+ item.setPrompt(tooltip);
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
new file mode 100644
index 0000000..f912dee
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2014 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.coregui.client.inventory.resource.detail.monitoring.table;
+
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.AVERAGE_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MAX_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MIN_KEY;
+
+import org.rhq.coregui.client.CoreGUI;
+
+/**
+ * Typesafe field names used in consolidated metrics screen grids for Resource and \
ResourceGroup. + * Also associates the proper label with the value.
+ *
+ * @author Mike Thompson
+ */
+@SuppressWarnings("GwtInconsistentSerializableClass")
+public enum MetricsGridFieldName {
+
+ SPARKLINE("sparkline"), METRIC_LABEL("label", \
CoreGUI.getMessages().common_title_name()), ALERT_COUNT("alertCount", + \
CoreGUI.getMessages().common_title_alerts()), MAX_VALUE(MAX_KEY, \
CoreGUI.getMessages() + .common_title_monitor_maximum()), MIN_VALUE(MIN_KEY, \
CoreGUI.getMessages().common_title_monitor_minimum()), AVG_VALUE( + \
AVERAGE_KEY, CoreGUI.getMessages().common_title_monitor_average()), \
METRIC_DEF_ID("defId"), METRIC_SCHEDULE_ID( + "schedId"), \
METRIC_UNITS("units"), METRIC_NAME("name"), RESOURCE_GROUP_ID("resourceGroupId"), + \
RESOURCE_ID("resourceId"), LIVE_VALUE("live", \
CoreGUI.getMessages().view_resource_monitor_table_live()); +
+ private final String value;
+ private final String label;
+
+ MetricsGridFieldName(String value, String label) {
+ this.value = value;
+ this.label = label;
+ }
+
+ MetricsGridFieldName(String value) {
+ this.value = value;
+ this.label = "";
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
index efba122..7e84c3d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
@@ -41,7 +41,6 @@ import \
org.rhq.coregui.client.inventory.common.graph.graphtype.AvailabilityOverU import \
org.rhq.coregui.client.inventory.resource.detail.monitoring.ExpandedRowsMomento; \
import org.rhq.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
import org.rhq.coregui.client.util.BrowserUtility;
-import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.async.CountDownLatch;
import org.rhq.coregui.client.util.enhanced.EnhancedHLayout;
@@ -87,7 +86,7 @@ public class MetricsResourceView extends AbstractD3GraphListView \
implements this.resource = resource;
metricsTableView = new MetricsTableView(resource, this, expandedRows);
- final ResourceMetricAvailabilityView availabilityDetails = new \
ResourceMetricAvailabilityView(resource); + final MetricAvailabilityView \
availabilityDetails = new MetricAvailabilityView(resource.getId()); \
availabilityDetails.hide();
metricsTableView.setHeight100();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index 63a6619..6f0f7f7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -74,6 +74,8 @@ import org.rhq.coregui.client.util.BrowserUtility;
import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.message.Message;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional \
detailed d3 graph.
*
@@ -125,10 +127,8 @@ public class MetricsTableView extends \
Table<MetricsViewDataSource> implements Re addToDashboardButton.enable();
ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
if (null != selectedRecord) {
- //Log.debug("Selected Metric Label: "
- // + \
selectedRecord.getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL));
- selectedMetricDefinitionId = selectedRecord
- \
.getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID); + \
selectedMetricDefinitionId = selectedRecord.getAttributeAsInt(METRIC_DEF_ID + \
.getValue()); }
}
});
@@ -176,7 +176,7 @@ public class MetricsTableView extends \
Table<MetricsViewDataSource> implements Re
if (measurementDefinition.getId() == selectedMetricDefinitionId) \
{
Log.debug("Add to Dashboard -- Storing: " + \
measurementDefinition.getDisplayName() + " in " + selectedDashboard.getName());
- storeDashboardMetric(selectedDashboard, resource, \
measurementDefinition); + \
storeDashboardMetric(selectedDashboard, resource.getId(), measurementDefinition); \
break; }
}
@@ -233,11 +233,11 @@ public class MetricsTableView extends \
Table<MetricsViewDataSource> implements Re });
}
- private void storeDashboardMetric(Dashboard dashboard, Resource resource, \
MeasurementDefinition definition) { + private void storeDashboardMetric(Dashboard \
dashboard, int resourceId, MeasurementDefinition definition) {
DashboardPortlet dashboardPortlet = new \
DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
- ResourceD3GraphPortlet.KEY, 200);
+ ResourceD3GraphPortlet.KEY, 260);
dashboardPortlet.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, \
resource.getId())); + new \
PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resourceId)); \
dashboardPortlet.getConfiguration().put(
new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, \
definition.getId()));
@@ -278,7 +278,7 @@ public class MetricsTableView extends \
Table<MetricsViewDataSource> implements Re @Override
public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
\
metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refreshData();
}
@@ -287,7 +287,7 @@ public class MetricsTableView extends \
Table<MetricsViewDataSource> implements Re @Override
public void onRecordCollapse(RecordCollapseEvent \
recordCollapseEvent) {
\
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refresh();
new Timer() {
@Override
@@ -321,7 +321,7 @@ public class MetricsTableView extends \
Table<MetricsViewDataSource> implements Re ListGridRecord listGridRecord = \
getRecord(i); if (null != listGridRecord) {
int metricDefinitionId = listGridRecord
- \
.getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID); + \
.getAttributeAsInt(METRIC_DEF_ID.getValue()); if (null != metricsTableView && null \
!= expandedRows
&& \
metricsTableView.expandedRows.contains(metricDefinitionId)) { \
expandRecord(listGridRecord); @@ -330,18 +330,14 @@ public class MetricsTableView \
extends Table<MetricsViewDataSource> implements Re }
}
- public void expandOpenedRows(Set<Integer> selectedRows) {
- expandedRows = selectedRows;
- expandOpenedRows();
- }
@Override
/**
* If you expand a grid row then create a graph.
*/
protected Canvas getExpansionComponent(final ListGridRecord record) {
- final Integer definitionId = \
record.getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
- final Integer resourceId = \
record.getAttributeAsInt(MetricsViewDataSource.FIELD_RESOURCE_ID); + final \
Integer definitionId = record.getAttributeAsInt(METRIC_DEF_ID.getValue()); + \
final Integer resourceId = record.getAttributeAsInt(RESOURCE_ID.getValue()); VLayout \
vLayout = new VLayout(); vLayout.setPadding(5);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
index 4c9c7c1..248eee0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
@@ -61,6 +61,7 @@ import org.rhq.coregui.client.util.RPCDataSource;
import org.rhq.coregui.client.util.async.Command;
import org.rhq.coregui.client.util.async.CountDownLatch;
import org.rhq.coregui.client.util.preferences.MeasurementUserPreferences;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
/**
* A simple data source to read in metric data summaries for a resource.
@@ -75,19 +76,6 @@ public class MetricsViewDataSource extends \
RPCDataSource<MetricDisplaySummary, C
private static final int NUMBER_OF_METRIC_POINTS = 60;
- public static final String FIELD_SPARKLINE = "sparkline";
- public static final String FIELD_METRIC_LABEL = "label";
- public static final String FIELD_ALERT_COUNT = "alertCount";
- public static final String FIELD_MIN_VALUE = "min";
- public static final String FIELD_MAX_VALUE = "max";
- public static final String FIELD_AVG_VALUE = "avg";
- public static final String FIELD_LIVE_VALUE = "live";
- public static final String FIELD_METRIC_DEF_ID = "defId";
- public static final String FIELD_METRIC_SCHED_ID = "schedId";
- public static final String FIELD_METRIC_UNITS = "units";
- public static final String FIELD_METRIC_NAME = "name";
- public static final String FIELD_RESOURCE_ID = "resourceId";
-
private final Resource resource;
private List<MetricDisplaySummary> metricDisplaySummaries;
private List<List<MeasurementDataNumericHighLowComposite>> metricsDataList;
@@ -111,7 +99,7 @@ public class MetricsViewDataSource extends \
RPCDataSource<MetricDisplaySummary, C public ArrayList<ListGridField> \
getListGridFields() {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
- ListGridField sparklineField = new ListGridField(FIELD_SPARKLINE, \
MSG.chart_metrics_sparkline_header()); + ListGridField sparklineField = new \
ListGridField(SPARKLINE.getValue(), MSG.chart_metrics_sparkline_header()); \
sparklineField.setCellFormatter(new CellFormatter() { @Override
public String format(Object value, ListGridRecord record, int rowNum, \
int colNum) { @@ -119,8 +107,8 @@ public class MetricsViewDataSource extends \
RPCDataSource<MetricDisplaySummary, C return "";
}
String contents = "<span id='sparkline_" + resource.getId() + "-"
- + record.getAttributeAsInt(FIELD_METRIC_DEF_ID) + "' \
class='dynamicsparkline' width='70' "
- + "values='" + record.getAttribute(FIELD_SPARKLINE) + \
"'></span>"; + + \
record.getAttributeAsInt(METRIC_DEF_ID.getValue()) + "' class='dynamicsparkline' \
width='70' " + + "values='" + \
record.getAttribute(SPARKLINE.getValue()) + "'></span>"; return contents;
}
@@ -129,27 +117,27 @@ public class MetricsViewDataSource extends \
RPCDataSource<MetricDisplaySummary, C sparklineField.setWidth(80);
fields.add(sparklineField);
- ListGridField nameField = new ListGridField(FIELD_METRIC_LABEL, \
MSG.common_title_name()); + ListGridField nameField = new \
ListGridField(METRIC_LABEL.getValue(), METRIC_LABEL.getLabel()); \
nameField.setWidth("30%"); fields.add(nameField);
- ListGridField minField = new ListGridField(FIELD_MIN_VALUE, \
MSG.common_title_monitor_minimum()); + ListGridField minField = new \
ListGridField(MIN_VALUE.getValue(), MIN_VALUE.getLabel()); minField.setWidth("15%");
fields.add(minField);
- ListGridField maxField = new ListGridField(FIELD_MAX_VALUE, \
MSG.common_title_monitor_maximum()); + ListGridField maxField = new \
ListGridField(MAX_VALUE.getValue(), MAX_VALUE.getLabel()); maxField.setWidth("15%");
fields.add(maxField);
- ListGridField avgField = new ListGridField(FIELD_AVG_VALUE, \
MSG.common_title_monitor_average()); + ListGridField avgField = new \
ListGridField(AVG_VALUE.getValue(), AVG_VALUE.getLabel()); avgField.setWidth("15%");
fields.add(avgField);
- ListGridField liveField = new ListGridField(FIELD_LIVE_VALUE, \
MSG.view_resource_monitor_table_live()); + ListGridField liveField = new \
ListGridField(LIVE_VALUE.getValue(), LIVE_VALUE.getLabel()); \
liveField.setWidth("15%"); fields.add(liveField);
- ListGridField alertsField = new ListGridField(FIELD_ALERT_COUNT, \
MSG.common_title_alerts()); + ListGridField alertsField = new \
ListGridField(ALERT_COUNT.getValue(), ALERT_COUNT.getLabel()); \
alertsField.setWidth("10%"); fields.add(alertsField);
@@ -170,18 +158,18 @@ public class MetricsViewDataSource extends \
RPCDataSource<MetricDisplaySummary, C MeasurementUtility.formatSimpleMetrics(from);
ListGridRecord record = new ListGridRecord();
- record.setAttribute(FIELD_SPARKLINE, \
getCsvMetricsForSparkline(from.getDefinitionId()));
- record.setAttribute(FIELD_METRIC_LABEL, from.getLabel());
- record.setAttribute(FIELD_ALERT_COUNT, \
String.valueOf(from.getAlertCount()));
- record.setAttribute(FIELD_MIN_VALUE, \
getMetricStringValue(from.getMinMetric()));
- record.setAttribute(FIELD_MAX_VALUE, \
getMetricStringValue(from.getMaxMetric()));
- record.setAttribute(FIELD_AVG_VALUE, \
getMetricStringValue(from.getAvgMetric()));
- record.setAttribute(FIELD_LIVE_VALUE, buildLiveValue(from));
- record.setAttribute(FIELD_METRIC_DEF_ID, from.getDefinitionId());
- record.setAttribute(FIELD_METRIC_SCHED_ID, from.getScheduleId());
- record.setAttribute(FIELD_METRIC_UNITS, from.getUnits());
- record.setAttribute(FIELD_METRIC_NAME, from.getMetricName());
- record.setAttribute(FIELD_RESOURCE_ID, resource.getId());
+ record.setAttribute(SPARKLINE.getValue(), \
getCsvMetricsForSparkline(from.getDefinitionId())); + \
record.setAttribute(METRIC_LABEL.getValue(), from.getLabel()); + \
record.setAttribute(ALERT_COUNT.getValue(), String.valueOf(from.getAlertCount())); + \
record.setAttribute(MIN_VALUE.getValue(), getMetricStringValue(from.getMinMetric())); \
+ record.setAttribute(MAX_VALUE.getValue(), \
getMetricStringValue(from.getMaxMetric())); + \
record.setAttribute(AVG_VALUE.getValue(), getMetricStringValue(from.getAvgMetric())); \
+ record.setAttribute(LIVE_VALUE.getValue(), buildLiveValue(from)); + \
record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId()); + \
record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId()); + \
record.setAttribute(METRIC_UNITS.getValue(), from.getUnits()); + \
record.setAttribute(METRIC_NAME.getValue(), from.getMetricName()); + \
record.setAttribute(RESOURCE_ID.getValue(), resource.getId()); return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
deleted file mode 100644
index 5919f83..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.coregui.client.inventory.resource.detail.monitoring.table;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary;
-import org.rhq.coregui.client.CoreGUI;
-import org.rhq.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.coregui.client.util.MeasurementConverterClient;
-import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;
-
-/**
- * This shows the availability history for a resource.
- *
- * @author Jay Shaughnessy
- * @author John Mazzitelli
- * @author Mike Thompson
- */
-public class ResourceMetricAvailabilityView extends EnhancedVLayout {
-
- private Resource resource;
- private StaticTextItem currentField;
- private StaticTextItem availField;
- private StaticTextItem availTimeField;
- private StaticTextItem downField;
- private StaticTextItem downTimeField;
- private StaticTextItem disabledField;
- private StaticTextItem disabledTimeField;
- private StaticTextItem failureCountField;
- private StaticTextItem disabledCountField;
- private StaticTextItem mtbfField;
- private StaticTextItem mttrField;
- private StaticTextItem unknownField;
- private StaticTextItem currentTimeField;
-
- public ResourceMetricAvailabilityView(Resource resource) {
- super();
-
- this.resource = resource;
-
- setWidth100();
- setHeight(165);
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- addMember(createSummaryForm());
- }
-
- private DynamicForm createSummaryForm() {
- DynamicForm form = new DynamicForm();
- form.setWidth100();
- form.setAutoHeight();
- form.setMargin(10);
- form.setNumCols(4);
-
- // row 1
- currentField = new StaticTextItem("current", \
MSG.view_resource_monitor_availability_currentStatus());
- currentField.setWrapTitle(false);
- currentField.setColSpan(4);
-
- // row 2
- availField = new StaticTextItem("avail", MSG.common_title_availability());
- availField.setWrapTitle(false);
- prepareTooltip(availField, \
MSG.view_resource_monitor_availability_tooltip_up());
-
- availTimeField = new StaticTextItem("availTime", \
MSG.view_resource_monitor_availability_uptime());
- availTimeField.setWrapTitle(false);
- prepareTooltip(availTimeField, \
MSG.view_resource_monitor_availability_uptime_tooltip());
-
- // row 3
- downField = new StaticTextItem("down", \
MSG.common_status_avail_down_lower());
- downField.setWrapTitle(false);
- prepareTooltip(downField, \
MSG.view_resource_monitor_availability_tooltip_down());
-
- downTimeField = new StaticTextItem("downTime", \
MSG.view_resource_monitor_availability_downtime());
- downTimeField.setWrapTitle(false);
- prepareTooltip(downTimeField, \
MSG.view_resource_monitor_availability_downtime_tooltip());
-
- // row 4
- disabledField = new StaticTextItem("disabled", \
MSG.common_status_avail_disabled_lower());
- disabledField.setWrapTitle(false);
- prepareTooltip(disabledField, \
MSG.view_resource_monitor_availability_tooltip_disabled());
-
- disabledTimeField = new StaticTextItem("disabledTime", \
MSG.view_resource_monitor_availability_disabledTime());
- disabledTimeField.setWrapTitle(false);
- prepareTooltip(disabledTimeField, \
MSG.view_resource_monitor_availability_disabledTime_tooltip());
-
- // row 5
- failureCountField = new StaticTextItem("failureCount", \
MSG.view_resource_monitor_availability_numFailures());
- failureCountField.setWrapTitle(false);
- prepareTooltip(failureCountField, \
MSG.view_resource_monitor_availability_numFailures_tooltip());
-
- disabledCountField = new StaticTextItem("disabledCount", \
MSG.view_resource_monitor_availability_numDisabled());
- disabledCountField.setWrapTitle(false);
- prepareTooltip(disabledCountField, \
MSG.view_resource_monitor_availability_numDisabled_tooltip());
-
- // row 6
- mtbfField = new StaticTextItem("mtbf", \
MSG.view_resource_monitor_availability_mtbf());
- mtbfField.setWrapTitle(false);
- prepareTooltip(mtbfField, \
MSG.view_resource_monitor_availability_mtbf_tooltip());
-
- mttrField = new StaticTextItem("mttr", \
MSG.view_resource_monitor_availability_mttr());
- mttrField.setWrapTitle(false);
- prepareTooltip(mttrField, \
MSG.view_resource_monitor_availability_mttr_tooltip());
-
- // row 7
- unknownField = new StaticTextItem("unknown");
- unknownField.setWrapTitle(false);
- unknownField.setColSpan(4);
- unknownField.setShowTitle(false);
-
- // row 8
- currentTimeField = new StaticTextItem("currentTime");
- currentTimeField.setWrapTitle(false);
- currentTimeField.setColSpan(4);
- currentTimeField.setShowTitle(false);
-
- form.setItems(currentField, availField, availTimeField, downField, \
downTimeField, disabledField,
- disabledTimeField, failureCountField, disabledCountField, mtbfField, \
mttrField, unknownField,
- currentTimeField);
-
- reloadSummaryData();
-
- return form;
- }
-
- private void reloadSummaryData() {
- GWTServiceLookup.getResourceService().getResourceAvailabilitySummary(resource.getId(),
- new AsyncCallback<ResourceAvailabilitySummary>() {
-
- @Override
- public void onSuccess(ResourceAvailabilitySummary result) {
-
- \
currentField.setValue(MSG.view_resource_monitor_availability_currentStatus_value(
- getAvailabilityTypeMessage(result.getCurrent()),
- \
TimestampCellFormatter.format(result.getLastChange().getTime())));
- \
availField.setValue(MeasurementConverterClient.format(result.getUpPercentage(),
- MeasurementUnits.PERCENTAGE, true));
- \
availTimeField.setValue(MeasurementConverterClient.format((double) \
result.getUpTime(),
- MeasurementUnits.MILLISECONDS, true));
- \
downField.setValue(MeasurementConverterClient.format(result.getDownPercentage(),
- MeasurementUnits.PERCENTAGE, true));
- \
downTimeField.setValue(MeasurementConverterClient.format((double) \
result.getDownTime(),
- MeasurementUnits.MILLISECONDS, true));
- \
disabledField.setValue(MeasurementConverterClient.format(result.getDisabledPercentage(),
- MeasurementUnits.PERCENTAGE, true));
- \
disabledTimeField.setValue(MeasurementConverterClient.format((double) \
result.getDisabledTime(),
- MeasurementUnits.MILLISECONDS, true));
- failureCountField.setValue(result.getFailures());
- disabledCountField.setValue(result.getDisabled());
- mtbfField.setValue(MeasurementConverterClient.format((double) \
result.getMTBF(),
- MeasurementUnits.MILLISECONDS, true));
- mttrField.setValue(MeasurementConverterClient.format((double) \
result.getMTTR(),
- MeasurementUnits.MILLISECONDS, true));
-
- if (result.getUnknownTime() > 0L) {
- \
unknownField.setValue(MSG.view_resource_monitor_availability_unknown(MeasurementConverterClient
- .format((double) result.getUnknownTime(), \
MeasurementUnits.MILLISECONDS, true)));
- } else {
- unknownField.setValue("");
- }
-
- \
currentTimeField.setValue(MSG.view_resource_monitor_availability_currentAsOf(TimestampCellFormatter
- .format(result.getCurrentTime())));
- }
-
- @Override
- public void onFailure(Throwable caught) {
- currentField.setValue(MSG.common_label_error());
- CoreGUI.getErrorHandler()
- \
.handleError(MSG.view_resource_monitor_availability_summaryError(), \
caught);
- }
- });
- }
-
- private String getAvailabilityTypeMessage(AvailabilityType availabilityType) {
- switch (availabilityType) {
- case UP:
- return MSG.common_status_avail_up();
- case DOWN:
- return MSG.common_status_avail_down();
- case DISABLED:
- return MSG.common_status_avail_disabled();
- case UNKNOWN:
- default:
- return MSG.common_status_avail_unknown();
- }
- }
-
- private void prepareTooltip(FormItem item, String tooltip) {
- item.setHoverWidth(400);
- item.setPrompt(tooltip);
- }
-
-}
_______________________________________________
rhq-commits mailing list
rhq-commits@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/rhq-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic