summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java272
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java295
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java6
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java5
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java8
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java5
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/LiveGraphView.java11
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java7
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java17
9 files changed, 326 insertions, 300 deletions
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
index f0a2cab..96fd3d3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
@@ -87,6 +87,8 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
protected boolean currentlyLoading = false;
protected long start = -1;
protected long end = -1;
+ protected int lastN = -1;
+ protected int units = -1;
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "GroupMetrics";
@@ -222,8 +224,10 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
column.setHeight(10);//pack
//initialize to defaults
- end = System.currentTimeMillis();
- start = end - (1000L * 60 * 60 * 8);//last 8 hrs
+ end = -1;
+ start = -1;
+ lastN = -1;
+ units = -1;
//result timeframe if enabled
PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
@@ -244,13 +248,10 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
//Simple time settings
property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
if (property != null) {
- int lastN = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_LASTN,
+ lastN = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_LASTN,
Constant.METRIC_RANGE_LASTN_DEFAULT));
- int units = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_UNIT,
+ units = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_UNIT,
Constant.METRIC_RANGE_UNIT_DEFAULT));
- ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, units);
- start = Long.valueOf(beginEnd.get(0));
- end = Long.valueOf(beginEnd.get(1));
}
}
}
@@ -323,141 +324,150 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
.getId();
}
- //make the asynchronous call for all the measurement data
- GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(
- groupId, definitionArrayIds, start, end, 60,
- new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent metrics charting data for group ["
- + groupId + "]:" + caught.getMessage());
- setRefreshing(false);
- }
-
- @Override
- public void onSuccess(
- List<List<MeasurementDataNumericHighLowComposite>> results) {
- if (!results.isEmpty()) {
- boolean someChartedData = false;
- //iterate over the retrieved charting data
- for (int index = 0; index < displayOrder.length; index++) {
- //retrieve the correct measurement definition
- MeasurementDefinition md = measurementDefMap
- .get(displayOrder[index]);
-
- //load the data results for the given metric definition
- List<MeasurementDataNumericHighLowComposite> data = results
- .get(index);
-
- //locate last and minimum values.
- double lastValue = -1;
- double minValue = Double.MAX_VALUE;//
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- if (d.getValue() < minValue) {
- minValue = d.getValue();
- }
- lastValue = d.getValue();
+ AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>> callback = new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent metrics charting data for group ["
+ + groupId + "]:" + caught.getMessage());
+ setRefreshing(false);
+ }
+
+ @Override
+ public void onSuccess(
+ List<List<MeasurementDataNumericHighLowComposite>> results) {
+ if (!results.isEmpty()) {
+ boolean someChartedData = false;
+ //iterate over the retrieved charting data
+ for (int index = 0; index < displayOrder.length; index++) {
+ //retrieve the correct measurement definition
+ MeasurementDefinition md = measurementDefMap
+ .get(displayOrder[index]);
+
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite> data = results
+ .get(index);
+
+ //locate last and minimum values.
+ double lastValue = -1;
+ double minValue = Double.MAX_VALUE;//
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ if (d.getValue() < minValue) {
+ minValue = d.getValue();
}
+ lastValue = d.getValue();
}
+ }
- //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
- String commaDelimitedList = "";
+ //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
+ String commaDelimitedList = "";
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- commaDelimitedList += d.getValue() + ",";
- }
- }
- LocatableDynamicForm row = new LocatableDynamicForm(
- recentMeasurementsContent.extendLocatorId(md.getName()));
- row.setNumCols(3);
- HTMLFlow graph = new HTMLFlow();
- // String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
- // + commaDelimitedList + "</span>";
- String contents = "<span id='sparkline_" + index
- + "' class='dynamicsparkline' width='0' " + "values='"
- + commaDelimitedList + "'>...</span>";
- graph.setContents(contents);
- graph.setContentsType(ContentsType.PAGE);
- //diable scrollbars on span
- graph.setScrollbarSize(0);
-
- CanvasItem graphContainer = new CanvasItem();
- graphContainer.setShowTitle(false);
- graphContainer.setHeight(16);
- graphContainer.setWidth(60);
- graphContainer.setCanvas(graph);
-
- //Link/title element
- final String title = md.getDisplayName();
- // String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
- // + resourceId + "&m=" + md.getId();
- final String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricMultiResource&groupId="
- + groupId + "&m=" + md.getId();
- LinkItem link = AbstractActivityView.newLinkItem(title,
- destination);
- link.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- ChartViewWindow window = new ChartViewWindow(
- recentMeasurementsContent
- .extendLocatorId("ChartWindow"), title);
- //generate and include iframed content
- FullHTMLPane iframe = new FullHTMLPane(
- recentMeasurementsContent
- .extendLocatorId("View"), destination);
- // .extendLocatorId("View"),
- // AbstractActivityView.iframeLink(destination));
- window.addItem(iframe);
- window.show();
- }
- });
-
- //Value
- String convertedValue = lastValue + " " + md.getUnits();
- convertedValue = AbstractActivityView
- .convertLastValueForDisplay(lastValue, md);
- StaticTextItem value = AbstractActivityView
- .newTextItem(convertedValue);
-
- row.setItems(graphContainer, link, value);
- //if graph content returned
- if ((md.getName().trim().indexOf("Trait.") == -1)
- && (lastValue != -1)) {
- column.addMember(row);
- someChartedData = true;
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ commaDelimitedList += d.getValue() + ",";
}
}
- if (!someChartedData) {// when there are results but no chartable entries.
- LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(
- recentMeasurementsContent.extendLocatorId("None"),
- AbstractActivityView.RECENT_MEASUREMENTS_GROUP_NONE);
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent.extendLocatorId(md.getName()));
+ row.setNumCols(3);
+ HTMLFlow graph = new HTMLFlow();
+ // String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
+ // + commaDelimitedList + "</span>";
+ String contents = "<span id='sparkline_" + index
+ + "' class='dynamicsparkline' width='0' " + "values='"
+ + commaDelimitedList + "'>...</span>";
+ graph.setContents(contents);
+ graph.setContentsType(ContentsType.PAGE);
+ //diable scrollbars on span
+ graph.setScrollbarSize(0);
+
+ CanvasItem graphContainer = new CanvasItem();
+ graphContainer.setShowTitle(false);
+ graphContainer.setHeight(16);
+ graphContainer.setWidth(60);
+ graphContainer.setCanvas(graph);
+
+ //Link/title element
+ final String title = md.getDisplayName();
+ // String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
+ // + resourceId + "&m=" + md.getId();
+ final String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricMultiResource&groupId="
+ + groupId + "&m=" + md.getId();
+ LinkItem link = AbstractActivityView.newLinkItem(title,
+ destination);
+ link.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ ChartViewWindow window = new ChartViewWindow(
+ recentMeasurementsContent
+ .extendLocatorId("ChartWindow"), title);
+ //generate and include iframed content
+ FullHTMLPane iframe = new FullHTMLPane(
+ recentMeasurementsContent
+ .extendLocatorId("View"), destination);
+ // .extendLocatorId("View"),
+ // AbstractActivityView.iframeLink(destination));
+ window.addItem(iframe);
+ window.show();
+ }
+ });
+
+ //Value
+ String convertedValue = lastValue + " " + md.getUnits();
+ convertedValue = AbstractActivityView
+ .convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = AbstractActivityView
+ .newTextItem(convertedValue);
+
+ row.setItems(graphContainer, link, value);
+ //if graph content returned
+ if ((md.getName().trim().indexOf("Trait.") == -1)
+ && (lastValue != -1)) {
column.addMember(row);
- } else {
- //insert see more link
- LocatableDynamicForm row = new LocatableDynamicForm(
- recentMeasurementsContent
- .extendLocatorId("RecentMeasurementsContentSeeMore"));
- String link = LinkManager
- .getGroupMonitoringGraphsLink(EntityContext
- .forGroup(groupId));
- AbstractActivityView.addSeeMoreLink(row, link, column);
+ someChartedData = true;
}
- //call out to 3rd party javascript lib
- BrowserUtility.graphSparkLines();
- } else {
- LocatableDynamicForm row = AbstractActivityView
- .createEmptyDisplayRow(
- recentMeasurementsContent.extendLocatorId("None"),
- AbstractActivityView.RECENT_MEASUREMENTS_GROUP_NONE);
+ }
+ if (!someChartedData) {// when there are results but no chartable entries.
+ LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(
+ recentMeasurementsContent.extendLocatorId("None"),
+ AbstractActivityView.RECENT_MEASUREMENTS_GROUP_NONE);
column.addMember(row);
+ } else {
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent
+ .extendLocatorId("RecentMeasurementsContentSeeMore"));
+ String link = LinkManager
+ .getGroupMonitoringGraphsLink(EntityContext
+ .forGroup(groupId));
+ AbstractActivityView.addSeeMoreLink(row, link, column);
}
- setRefreshing(false);
+ //call out to 3rd party javascript lib
+ BrowserUtility.graphSparkLines();
+ } else {
+ LocatableDynamicForm row = AbstractActivityView
+ .createEmptyDisplayRow(
+ recentMeasurementsContent.extendLocatorId("None"),
+ AbstractActivityView.RECENT_MEASUREMENTS_GROUP_NONE);
+ column.addMember(row);
}
- });
+ setRefreshing(false);
+ }
+ };
+
+ //make the asynchronous call for all the measurement data
+ if (end != -1 && start != -1) {
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(
+ groupId, definitionArrayIds, start, end, 60, callback);
+ } else if (lastN != -1 && units != -1) {
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroupForLast(
+ groupId, definitionArrayIds, lastN, units, 60, callback);
+ } else {
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroupForLast(
+ groupId, definitionArrayIds, 8, MeasurementUtility.UNIT_HOURS, 60, callback);
+ }
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
index 16869ff..a2a9494 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
@@ -18,6 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.ContentsType;
@@ -31,6 +37,7 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;
+
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -57,8 +64,6 @@ import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import java.util.*;
-
/**This portlet allows the end user to customize the metric display
*
* @author Simeon Pinder
@@ -104,8 +109,10 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
column.setWidth100();
//initialize to defaults
- end = System.currentTimeMillis();
- start = end - (1000L * 60 * 60 * 8);//last 8 hrs
+ end = -1;
+ start = -1;
+ lastN = -1;
+ units = -1;
//result timeframe if enabled
PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
@@ -126,13 +133,10 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
//Simple time settings
property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
if (property != null) {
- int lastN = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_LASTN,
+ lastN = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_LASTN,
Constant.METRIC_RANGE_LASTN_DEFAULT));
- int units = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_UNIT,
+ units = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_UNIT,
Constant.METRIC_RANGE_UNIT_DEFAULT));
- ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, units);
- start = Long.valueOf(beginEnd.get(0));
- end = Long.valueOf(beginEnd.get(1));
}
}
}
@@ -189,153 +193,162 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay)
.getId();
}
-
- //make the asynchronous call for all the measurement data
- GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId,
- definitionArrayIds, start, end, 60,
- new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent metrics charting data for resource ["
- + resourceId + "]:" + caught.getMessage());
- setRefreshing(false);
- }
-
- @Override
- public void onSuccess(
- List<List<MeasurementDataNumericHighLowComposite>> results) {
- if (!results.isEmpty()) {
- boolean someChartedData = false;
- //iterate over the retrieved charting data
- for (int index = 0; index < displayOrder.length; index++) {
- //retrieve the correct measurement definition
- MeasurementDefinition md = measurementDefMap
- .get(displayOrder[index]);
-
- //load the data results for the given metric definition
- List<MeasurementDataNumericHighLowComposite> data = results
- .get(index);
-
- //locate last and minimum values.
- double lastValue = -1;
- double minValue = Double.MAX_VALUE;//
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- if (d.getValue() < minValue) {
- minValue = d.getValue();
- }
- lastValue = d.getValue();
+
+ AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>> callback = new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent metrics charting data for resource ["
+ + resourceId + "]:" + caught.getMessage());
+ setRefreshing(false);
+ }
+
+ @Override
+ public void onSuccess(
+ List<List<MeasurementDataNumericHighLowComposite>> results) {
+ if (!results.isEmpty()) {
+ boolean someChartedData = false;
+ //iterate over the retrieved charting data
+ for (int index = 0; index < displayOrder.length; index++) {
+ //retrieve the correct measurement definition
+ MeasurementDefinition md = measurementDefMap
+ .get(displayOrder[index]);
+
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite> data = results
+ .get(index);
+
+ //locate last and minimum values.
+ double lastValue = -1;
+ double minValue = Double.MAX_VALUE;//
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ if (d.getValue() < minValue) {
+ minValue = d.getValue();
}
+ lastValue = d.getValue();
}
+ }
- //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
- String commaDelimitedList = "";
+ //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
+ String commaDelimitedList = "";
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- commaDelimitedList += d.getValue() + ",";
- }
- }
- LocatableDynamicForm row = new LocatableDynamicForm(
- recentMeasurementsContent.extendLocatorId(md.getName()));
- row.setNumCols(3);
- row.setColWidths(65, "*", 100);
- row.setWidth100();
- row.setAutoHeight();
- row.setOverflow(Overflow.VISIBLE);
- HTMLFlow graph = new HTMLFlow();
- String contents = "<span id='sparkline_" + index
- + "' class='dynamicsparkline' width='0' " + "values='"
- + commaDelimitedList + "'>...</span>";
- graph.setContents(contents);
- graph.setContentsType(ContentsType.PAGE);
- //disable scrollbars on span
- graph.setScrollbarSize(0);
-
- CanvasItem graphContainer = new CanvasItem();
- graphContainer.setShowTitle(false);
- graphContainer.setHeight(16);
- graphContainer.setWidth(60);
- graphContainer.setCanvas(graph);
-
- //Link/title element
- final String title = md.getDisplayName();
- final String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
- + resourceId + "&m=" + md.getId();
-
- //have link launch modal window on click
- LinkItem link = AbstractActivityView.newLinkItem(title,
- destination);
- link.setTooltip(title);
- link.setTitleVAlign(VerticalAlignment.TOP);
- link.setAlign(Alignment.LEFT);
- link.setClipValue(true);
- link.setWrap(true);
- link.setHeight(26);
- link.setWidth("100%");
- link.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- ChartViewWindow window = new ChartViewWindow(
- recentMeasurementsContent
- .extendLocatorId("ChartWindow"), title);
- //generate and include iframed content
- FullHTMLPane iframe = new FullHTMLPane(
- recentMeasurementsContent.extendLocatorId("View"),
- destination);
- window.addItem(iframe);
- window.show();
- }
- });
-
- //Value
- String convertedValue;
- convertedValue = AbstractActivityView
- .convertLastValueForDisplay(lastValue, md);
- StaticTextItem value = AbstractActivityView
- .newTextItem(convertedValue);
- value.setVAlign(VerticalAlignment.TOP);
- value.setAlign(Alignment.RIGHT);
-
- row.setItems(graphContainer, link, value);
- row.setWidth100();
-
- //if graph content returned
- if ((md.getName().trim().indexOf("Trait.") == -1)
- && (lastValue != -1)) {
- column.addMember(row);
- someChartedData = true;
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ commaDelimitedList += d.getValue() + ",";
}
}
- if (!someChartedData) {// when there are results but no chartable entries.
- LocatableDynamicForm row = AbstractActivityView
- .createEmptyDisplayRow(
- recentMeasurementsContent.extendLocatorId("None"),
- AbstractActivityView.RECENT_MEASUREMENTS_NONE);
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent.extendLocatorId(md.getName()));
+ row.setNumCols(3);
+ row.setColWidths(65,"*",100);
+ row.setWidth100();
+ row.setAutoHeight();
+ row.setOverflow(Overflow.VISIBLE);
+ HTMLFlow graph = new HTMLFlow();
+ String contents = "<span id='sparkline_" + index
+ + "' class='dynamicsparkline' width='0' " + "values='"
+ + commaDelimitedList + "'>...</span>";
+ graph.setContents(contents);
+ graph.setContentsType(ContentsType.PAGE);
+ //disable scrollbars on span
+ graph.setScrollbarSize(0);
+
+ CanvasItem graphContainer = new CanvasItem();
+ graphContainer.setShowTitle(false);
+ graphContainer.setHeight(16);
+ graphContainer.setWidth(60);
+ graphContainer.setCanvas(graph);
+
+ //Link/title element
+ final String title = md.getDisplayName();
+ final String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
+ + resourceId + "&m=" + md.getId();
+
+ //have link launch modal window on click
+ LinkItem link = AbstractActivityView.newLinkItem(title,
+ destination);
+ link.setTooltip(title);
+ link.setTitleVAlign(VerticalAlignment.TOP);
+ link.setAlign(Alignment.LEFT);
+ link.setClipValue(true);
+ link.setWrap(true);
+ link.setHeight(26);
+ link.setWidth("100%");
+ link.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ ChartViewWindow window = new ChartViewWindow(
+ recentMeasurementsContent
+ .extendLocatorId("ChartWindow"), title);
+ //generate and include iframed content
+ FullHTMLPane iframe = new FullHTMLPane(
+ recentMeasurementsContent.extendLocatorId("View"),
+ destination);
+ window.addItem(iframe);
+ window.show();
+ }
+ });
+
+ //Value
+ String convertedValue;
+ convertedValue = AbstractActivityView
+ .convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = AbstractActivityView
+ .newTextItem(convertedValue);
+ value.setVAlign(VerticalAlignment.TOP);
+ value.setAlign(Alignment.RIGHT);
+
+ row.setItems(graphContainer, link, value);
+ row.setWidth100();
+
+ //if graph content returned
+ if ((md.getName().trim().indexOf("Trait.") == -1)
+ && (lastValue != -1)) {
column.addMember(row);
- } else {
- //insert see more link
- LocatableDynamicForm row = new LocatableDynamicForm(
- recentMeasurementsContent
- .extendLocatorId("RecentMeasurementsContentSeeMore"));
- String link = LinkManager
- .getResourceMonitoringGraphsLink(resourceId);
- AbstractActivityView.addSeeMoreLink(row, link, column);
+ someChartedData = true;
}
- //call out to 3rd party javascript lib
- BrowserUtility.graphSparkLines();
- } else {
+ }
+ if (!someChartedData) {// when there are results but no chartable entries.
LocatableDynamicForm row = AbstractActivityView
.createEmptyDisplayRow(
recentMeasurementsContent.extendLocatorId("None"),
AbstractActivityView.RECENT_MEASUREMENTS_NONE);
column.addMember(row);
+ } else {
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent
+ .extendLocatorId("RecentMeasurementsContentSeeMore"));
+ String link = LinkManager
+ .getResourceMonitoringGraphsLink(resourceId);
+ AbstractActivityView.addSeeMoreLink(row, link, column);
}
- setRefreshing(false);
+ //call out to 3rd party javascript lib
+ BrowserUtility.graphSparkLines();
+ } else {
+ LocatableDynamicForm row = AbstractActivityView
+ .createEmptyDisplayRow(
+ recentMeasurementsContent.extendLocatorId("None"),
+ AbstractActivityView.RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
}
- });
+ setRefreshing(false);
+ }
+ };
+
+ //make the asynchronous call for all the measurement data
+ if (end != -1 && start != -1) {
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(
+ resourceId, definitionArrayIds, start, end, 60, callback);
+ } else if (lastN != -1 && units != -1) {
+ GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(
+ resourceId, definitionArrayIds, lastN, units, 60, callback);
+ } else {
+ GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(
+ resourceId, definitionArrayIds, 8, MeasurementUtility.UNIT_HOURS, 60, callback);
+ }
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java
index 0488b0c..d056e97 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java
@@ -54,9 +54,15 @@ public interface MeasurementDataGWTService extends RemoteService {
List<List<MeasurementDataNumericHighLowComposite>> findDataForResource(int resourceId, int[] definitionIds,
long beginTime, long endTime, int numPoints) throws RuntimeException;
+
+ List<List<MeasurementDataNumericHighLowComposite>> findDataForResourceForLast(int resourceId, int[] definitionIds,
+ int lastN, int unit, int numPoints) throws RuntimeException;
List<List<MeasurementDataNumericHighLowComposite>> findDataForCompatibleGroup(int groupId, int[] definitionIds,
long beginTime, long endTime, int numPoints) throws RuntimeException;
+
+ List<List<MeasurementDataNumericHighLowComposite>> findDataForCompatibleGroupForLast(int groupId, int[] definitionIds,
+ int lastN, int unit, int numPoints) throws RuntimeException;
PageList<MeasurementDefinition> findMeasurementDefinitionsByCriteria(MeasurementDefinitionCriteria criteria)
throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
index 8445a46..385e557 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
@@ -323,12 +323,9 @@ public abstract class AbstractMetricGraphView extends LocatableVLayout {
}
}));
- long max = System.currentTimeMillis();
- long min = max - (1000L * 60 * 60 * 8);
-
int xTicks = getDefaultWidth() / 140;
- plotOptions.addXAxisOptions(new AxisOptions().setTicks(xTicks).setMinimum(min).setMaximum(max)
+ plotOptions.addXAxisOptions(new AxisOptions().setTicks(xTicks)
.setTickFormatter(new TickFormatter() {
public String formatTickValue(double tickValue, Axis axis) {
com.google.gwt.i18n.client.DateTimeFormat dateFormat = DateTimeFormat
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
index 23f84ea..fe8b398 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
@@ -36,6 +36,7 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMetricGraphView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
@@ -95,10 +96,9 @@ public class ResourceGroupMetricGraphView extends AbstractMetricGraphView {
if (def.getId() == getDefinitionId()) {
setDefinition(def);
- GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(
- getEntityId(), new int[] { getDefinitionId() },
- System.currentTimeMillis() - (1000L * 60 * 60 * 8),
- System.currentTimeMillis(), 60,
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroupForLast(
+ getEntityId(), new int[] { getDefinitionId() }, 8,
+ MeasurementUtility.UNIT_HOURS, 60,
new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
index 7a68ba2..1e99fb5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
@@ -42,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectLi
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityBarView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
/**
* @author Greg Hinkle
@@ -101,8 +102,8 @@ public class GraphListView extends LocatableVLayout implements ResourceSelectLis
measDefIdArray[i] = measurementDefinitions.get(i).getId();
}
- GWTServiceLookup.getMeasurementDataService().findDataForResource(resource.getId(), measDefIdArray,
- System.currentTimeMillis() - (1000L * 60 * 60 * 8), System.currentTimeMillis(), 60,
+ GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(resource.getId(), measDefIdArray,
+ 8, MeasurementUtils.UNIT_HOURS, 60,
new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_loadFailed(),
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/LiveGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/LiveGraphView.java
index 330eaf0..11d7b55 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/LiveGraphView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/LiveGraphView.java
@@ -246,14 +246,6 @@ public class LiveGraphView extends LocatableVLayout {
handler.add(new DataPoint(d.getTimestamp(), d.getValue()));
plot.redraw();
-
- if (d.getTimestamp() > max) {
- max = System.currentTimeMillis();
- min = max - (1000L * 60);
-
- // plotOptions.setXAxisOptions(new AxisOptions().setMinimum(min).setMaximum(max));
- }
-
}
});
}
@@ -268,9 +260,6 @@ public class LiveGraphView extends LocatableVLayout {
}
}));
- min = System.currentTimeMillis();
- max = System.currentTimeMillis() + (1000L * 60);
-
plotOptions.addXAxisOptions(new AxisOptions().setTicks(8).setTickFormatter(new TickFormatter() {
public String formatTickValue(double tickValue, Axis axis) {
DateTimeFormat dateFormat = DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java
index d051b92..76f2d1e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMetricGrap
import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
/**
* @author Greg Hinkle
@@ -109,10 +110,8 @@ public class ResourceMetricGraphView extends AbstractMetricGraphView {
if (def.getId() == getDefinitionId()) {
setDefinition(def);
- GWTServiceLookup.getMeasurementDataService().findDataForResource(getEntityId(),
- new int[] { getDefinitionId() },
- System.currentTimeMillis() - (1000L * 60 * 60 * 8),
- System.currentTimeMillis(), 60,
+ GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(getEntityId(),
+ new int[] { getDefinitionId() }, 8, MeasurementUtils.UNIT_HOURS, 60,
new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
index f014c94..5e40890 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
@@ -39,11 +39,11 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
-import org.rhq.enterprise.server.measurement.CallTimeDataManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementOOBManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
+import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -55,7 +55,6 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
private static final long serialVersionUID = 1L;
private MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager();
- private CallTimeDataManagerLocal callTimeDataManager = LookupUtil.getCallTimeDataManager();
private MeasurementOOBManagerLocal measurementOOBManager = LookupUtil.getOOBManager();
private MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
@@ -99,6 +98,12 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
throw getExceptionToThrowToClient(t);
}
}
+
+ public List<List<MeasurementDataNumericHighLowComposite>> findDataForResourceForLast(int resourceId, int[] definitionIds,
+ int lastN, int unit, int numPoints) throws RuntimeException {
+ List<Long> beginEnd = MeasurementUtils.calculateTimeFrame(lastN, unit);
+ return findDataForResource(resourceId, definitionIds, beginEnd.get(0), beginEnd.get(1), numPoints);
+ }
public List<List<MeasurementDataNumericHighLowComposite>> findDataForCompatibleGroup(int groupId,
int[] definitionIds, long beginTime, long endTime, int numPoints) throws RuntimeException {
@@ -114,7 +119,13 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
throw getExceptionToThrowToClient(t);
}
}
-
+
+ public List<List<MeasurementDataNumericHighLowComposite>> findDataForCompatibleGroupForLast(int groupId,
+ int[] definitionIds, int lastN, int unit, int numPoints) throws RuntimeException {
+ List<Long> beginEnd = MeasurementUtils.calculateTimeFrame(lastN, unit);
+ return findDataForCompatibleGroup(groupId, definitionIds, beginEnd.get(0), beginEnd.get(1), numPoints);
+ }
+
public PageList<MeasurementDefinition> findMeasurementDefinitionsByCriteria(MeasurementDefinitionCriteria criteria)
throws RuntimeException {
try {