modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java | 12 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java | 117 ++++++++--
modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_cs.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_de.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ja.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ko.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_pt.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ru.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_zh.properties | 2
10 files changed, 106 insertions(+), 39 deletions(-)
New commits:
commit 08fe551f9040218f73dda72b35e0823cc09cdcec
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Mon Oct 21 11:13:44 2013 -0700
[BZ 961366] - Error on clicking 'Get Live Value' button for a metric on resource->Monitoring->Tables tab. Now Adding Live Values to metrics screen after discussing design with UXD. Removed Live values button as live values have replaced last values.
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 1172eb7..61797df 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
@@ -109,18 +109,6 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
setListGridFields(fields.toArray(new ListGridField[0]));
if (!rendered) {
- addTableAction(MSG.view_measureTable_getLive(), new TableAction() {
- @Override
- public boolean isEnabled(ListGridRecord[] selection) {
- return true;
- }
-
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- refresh();
- }
- });
-
addExtraWidget(addToDashboardComponent, false);
addToDashboardComponent.disableAddToDashboardButton();
metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
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 0f89b36..e154727 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
@@ -3,11 +3,14 @@ package org.rhq.coregui.client.inventory.resource.detail.monitoring.table;
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.google.gwt.user.client.rpc.IncompatibleRemoteServiceException;
+import com.google.gwt.user.client.rpc.InvocationException;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
@@ -17,8 +20,10 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementSchedule;
+import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
@@ -28,6 +33,7 @@ import org.rhq.coregui.client.UserSessionManager;
import org.rhq.coregui.client.gwt.GWTServiceLookup;
import org.rhq.coregui.client.util.BrowserUtility;
import org.rhq.coregui.client.util.Log;
+import org.rhq.coregui.client.util.MeasurementConverterClient;
import org.rhq.coregui.client.util.MeasurementUtility;
import org.rhq.coregui.client.util.RPCDataSource;
import org.rhq.coregui.client.util.async.Command;
@@ -52,7 +58,7 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
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_LAST_VALUE = "last";
+ 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";
@@ -61,7 +67,10 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
private final Resource resource;
private List<MetricDisplaySummary> metricDisplaySummaries;
private List<List<MeasurementDataNumericHighLowComposite>> metricsDataList;
+ private Set<MeasurementData> liveMeasurementDataSet;
private int[] definitionArrayIds;
+ private int[] scheduleIds;
+ private HashMap<Integer, MeasurementUnits> scheduleToMeasurementUnitMap = new HashMap<Integer, MeasurementUnits>();
private final MeasurementUserPreferences measurementUserPrefs;
public MetricsViewDataSource(Resource resource) {
@@ -112,7 +121,7 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
avgField.setWidth("15%");
fields.add(avgField);
- ListGridField lastField = new ListGridField(FIELD_LAST_VALUE, MSG.view_resource_monitor_table_last());
+ ListGridField lastField = new ListGridField(FIELD_LIVE_VALUE, MSG.view_resource_monitor_table_last());
lastField.setWidth("15%");
fields.add(lastField);
@@ -143,7 +152,7 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
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_LAST_VALUE, getMetricStringValue(from.getLastMetric()));
+ 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());
@@ -152,12 +161,34 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
return record;
}
+ private String buildLiveValue(MetricDisplaySummary from) {
+ StringBuilder sb = new StringBuilder();
+ for (MeasurementData measurementData : liveMeasurementDataSet) {
+ if (from.getScheduleId() == measurementData.getScheduleId()) {
+ double doubleValue;
+ if (measurementData.getValue() instanceof Number) {
+ doubleValue = ((Number) measurementData.getValue()).doubleValue();
+ } else {
+ doubleValue = Double.parseDouble(measurementData.getValue().toString());
+ }
+
+ String value = MeasurementConverterClient.formatToSignificantPrecision(new double[] { doubleValue },
+ MeasurementUnits.valueOf(from.getUnits()), true)[0];
+
+ sb.append(value);
+
+ break;
+ }
+ }
+
+ return sb.toString();
+ }
+
private String getCsvMetricsForSparkline(int definitionId) {
StringBuilder sb = new StringBuilder();
List<MeasurementDataNumericHighLowComposite> selectedMetricsList = getMeasurementsForMeasurementDefId(definitionId);
- for (int i = 0; i < selectedMetricsList.size(); i++) {
- MeasurementDataNumericHighLowComposite measurementData = selectedMetricsList.get(i);
+ for (MeasurementDataNumericHighLowComposite measurementData : selectedMetricsList) {
if (!Double.isNaN(measurementData.getValue())) {
sb.append((int) measurementData.getValue());
sb.append(",");
@@ -170,15 +201,15 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
// 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(",")){
+ if (!sb.toString().contains(",")) {
// append another value just so we have 2 values and it will graph
- return "0,"+sb.toString();
+ return "0," + sb.toString();
}
return sb.toString();
}
- List<MeasurementDataNumericHighLowComposite> getMeasurementsForMeasurementDefId(int definitionId) {
+ private List<MeasurementDataNumericHighLowComposite> getMeasurementsForMeasurementDefId(int definitionId) {
int selectedIndex = 0;
// find the ordinal position as specified when querying the metrics
@@ -209,26 +240,23 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
DataType.MEASUREMENT, null, true, new AsyncCallback<ArrayList<MeasurementSchedule>>() {
@Override
public void onSuccess(ArrayList<MeasurementSchedule> measurementSchedules) {
- int[] scheduleIds = new int[measurementSchedules.size()];
+ scheduleIds = new int[measurementSchedules.size()];
int i = 0;
for (MeasurementSchedule measurementSchedule : measurementSchedules) {
scheduleIds[i++] = measurementSchedule.getId();
}
+ // This latch is the last thing that gets executed after we have executed the
+ // 2 queries in Parallel
final CountDownLatch countDownLatch = CountDownLatch.create(2, new Command() {
@Override
public void execute() {
- response.setData(buildRecords(metricDisplaySummaries));
- processResponse(request.getRequestId(), response);
+ // we needed the ResourceMetrics query and Metric Display Summary
+ // to finish before we can query the live metrics and populate the
+ // result response
+ queryLiveMetrics(request, response);
- new Timer() {
-
- @Override
- public void run() {
- BrowserUtility.graphSparkLines();
- }
- }.schedule(150);
}
});
@@ -245,6 +273,46 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
});
}
+ private void queryLiveMetrics(final DSRequest request, final DSResponse response) {
+
+ // actually go out and ask the agents for the data
+ GWTServiceLookup.getMeasurementDataService(60000).findLiveData(resource.getId(), definitionArrayIds,
+ new AsyncCallback<Set<MeasurementData>>() {
+ @Override
+ public void onSuccess(Set<MeasurementData> result) {
+ if (result == null) {
+ result = new HashSet<MeasurementData>(0);
+ }
+ liveMeasurementDataSet = result;
+ response.setData(buildRecords(metricDisplaySummaries));
+ processResponse(request.getRequestId(), response);
+
+ new Timer() {
+
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+
+ /**
+ * Called when an asynchronous call fails to complete normally. {@link IncompatibleRemoteServiceException}s, {@link
+ * InvocationException}s, or checked exceptions thrown by the service method are examples of the type of failures that
+ * can be passed to this method.
+ * <p/>
+ * <p> If <code>caught</code> is an instance of an {@link IncompatibleRemoteServiceException} the application should
+ * try to get into a state where a browser refresh can be safely done. </p>
+ *
+ * @param caught failure encountered while executing a remote procedure call
+ */
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Cannot load metrics", caught);
+ }
+ });
+ }
+
private void queryMetricDisplaySummaries(int[] scheduleIds, Long startTime, Long endTime,
final CountDownLatch countDownLatch) {
GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForResource(resource.getId(),
@@ -269,10 +337,19 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
this.metricDisplaySummaries = metricDisplaySummaries;
}
- public void queryResourceMetrics(final Resource resource, Long startTime, Long endTime,
+ public void queryResourceMetrics(final Resource resource, final Long startTime, final Long endTime,
final CountDownLatch countDownLatch) {
Set<MeasurementDefinition> definitions = resource.getResourceType().getMetricDefinitions();
+ // create a mapping of schedules ids to MeasurementUnits
+ for (MeasurementDefinition definition : definitions) {
+ if (null != definition.getSchedules()) {
+ for (MeasurementSchedule schedule : definition.getSchedules()) {
+ scheduleToMeasurementUnitMap.put(schedule.getId(), definition.getUnits());
+ }
+ }
+ }
+
//build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
for (MeasurementDefinition definition : definitions) {
@@ -311,4 +388,6 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
});
}
+
}
+
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages.properties
index b2666e1..1dd8911 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages.properties
@@ -2085,7 +2085,7 @@ view_resource_monitor_graphs_lookupFailed = Failed to find resource for graph
view_resource_monitor_graphs_noneAvailable = No graphs available
view_resource_monitor_schedules_title = Resource Metric Collection Schedules
view_resource_monitor_table_avg = Average
-view_resource_monitor_table_last = Last
+view_resource_monitor_table_last = Live Value
view_resource_monitor_table_max = Maximum
view_resource_monitor_table_min = Minimum
view_resource_title_component_errors_cleanup = After addressing the issue, you will need to delete the message below to clear the 'managed component error' icon from the previous screen.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_cs.properties
index 52538f1..7a305d8 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_cs.properties
@@ -2101,7 +2101,7 @@ view_resource_monitor_graphs_lookupFailed = Nepodařilo se nalézt zdroj pro gra
view_resource_monitor_graphs_noneAvailable = Žádné grafy nejsou dostupné
view_resource_monitor_schedules_title = Rozvrhy sběru metrik pro zdroj
view_resource_monitor_table_avg = Průměr
-view_resource_monitor_table_last = Poslední
+##view_resource_monitor_table_last = Live Value
view_resource_monitor_table_max = Maximum
view_resource_monitor_table_min = Minimum
##view_resource_title_component_errors_cleanup = After addressing the issue, you will need to delete the message below to clear the 'managed component error' icon from the previous screen.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_de.properties
index dd6d32e..b4c1424 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_de.properties
@@ -1938,7 +1938,7 @@ view_resource_monitor_calltime_minimum = Minimum
view_resource_monitor_graphs_noneAvailable = Keine Charts verf\u00FCgbar
view_resource_monitor_schedules_title = Zeitplan f\u00FCr das Sammeln von Metriken
view_resource_monitor_table_avg = Durchschnitt
-view_resource_monitor_table_last = Letzter
+##view_resource_monitor_table_last = Live Value
view_resource_monitor_table_max = Maximum
view_resource_monitor_table_min = Minimum
view_resource_title_component_errors_tooltip = Zeigt Fehler der gemanagten Ressource. Klicken für Details
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ja.properties
index 0b75a34..2e2763d 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ja.properties
@@ -2070,7 +2070,7 @@ view_resource_monitor_graphs_lookupFailed = グラフのためのリソースの
view_resource_monitor_graphs_noneAvailable = 利用できるグラフはありません
view_resource_monitor_schedules_title = リソースメトリック収集スケジュール
view_resource_monitor_table_avg = 平均
-view_resource_monitor_table_last = 最新
+##view_resource_monitor_table_last = Live Value
view_resource_monitor_table_max = 最大
view_resource_monitor_table_min = 最小
view_resource_title_component_errors_cleanup = 問題に取り組んだ後は、以下のメッセージを削除して全画面の'管理コンポーネントエラー'をクリアする必要があります。
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ko.properties
index a8f44b4..d640aa9 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ko.properties
@@ -1769,7 +1769,7 @@ view_resource_monitor_graphs_lookupFailed = 그래프를 위한 리소스를 찾
view_resource_monitor_graphs_noneAvailable = 유효한 그래프가 없습니다
view_resource_monitor_schedules_title = 리소스 통계 수집 일정
view_resource_monitor_table_avg = 평균
-view_resource_monitor_table_last = 최신
+##view_resource_monitor_table_last = Live Value
view_resource_monitor_table_max = 최대
view_resource_monitor_table_min = 최소
view_resource_title_component_errors_cleanup = 이 문제를 해결 한 후에는 이전 화면에서 '관리 구성 요소 오류'아이콘을 삭제하려면 아래의 메시지를 삭제해야합니다.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_pt.properties
index dc645ab..c8ab1b8 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_pt.properties
@@ -2183,7 +2183,7 @@ view_resource_monitor_graphs_lookupFailed = Failed to find resource for graph
view_resource_monitor_graphs_noneAvailable = No graphs available
view_resource_monitor_schedules_title = Resource Metric Collection Schedules
view_resource_monitor_table_avg = Average
-view_resource_monitor_table_last = Last
+##view_resource_monitor_table_last = Live Value
view_resource_monitor_table_max = Maximum
view_resource_monitor_table_min = Minimum
##view_resource_title_component_errors_cleanup = After addressing the issue, you will need to delete the message below to clear the 'managed component error' icon from the previous screen.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ru.properties
index 7af2d80..fa5d9d4 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_ru.properties
@@ -1947,7 +1947,7 @@
#view_resource_monitor_graphs_noneAvailable = No graphs available
#view_resource_monitor_schedules_title = Resource Metric Collection Schedules
#view_resource_monitor_table_avg = Average
-#view_resource_monitor_table_last = Last
+#view_resource_monitor_table_last = Live Value
#view_resource_monitor_table_max = Maximum
#view_resource_monitor_table_min = Minimum
#view_resource_title_component_errors_cleanup = After addressing the issue, you will need to delete the message below to clear the 'managed component error' icon from the previous screen.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_zh.properties
index b80027b..ac873e4 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_zh.properties
@@ -2073,7 +2073,7 @@ view_resource_monitor_graphs_lookupFailed = Failed to find resource for graph
view_resource_monitor_graphs_noneAvailable = \u6ca1\u6709\u53ef\u7528\u56fe
view_resource_monitor_schedules_title = Resource Metric Collection Schedules
view_resource_monitor_table_avg = \u5e73\u5747
-view_resource_monitor_table_last = Last
+##view_resource_monitor_table_last = Live Value
view_resource_monitor_table_max = \u6700\u5927
view_resource_monitor_table_min = \u6700\u5c0f
##view_resource_title_component_errors_cleanup = After addressing the issue, you will need to delete the message below to clear the 'managed component error' icon from the previous screen.