modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
| 41 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
| 62 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/CommonMetricsTableView.java
| 404 ----------
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/MetricsTableView.java
| 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
| 56 -
modules/enterprise/remoting/cli/pom.xml
| 19
modules/enterprise/remoting/cli/src/etc/Remoting_Setup.txt
| 43 -
modules/enterprise/remoting/cli/src/etc/build.xml
| 80 -
modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat
| 16
modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh
| 18
modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat
| 32
modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
| 40
modules/enterprise/remoting/cli/src/etc/rhq-cli.bat
| 51 +
modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
| 104 +-
modules/enterprise/remoting/cli/src/etc/toRun.txt
| 3
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java
| 33
modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
| 2
modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProviderTest.java
| 67 +
modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java
| 10
modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java
| 9
22 files changed, 458 insertions(+), 725 deletions(-)
New commits:
commit 203903abf68f5a62a84c52d5d857f1251dcf4fc3
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Dec 13 14:08:13 2013 -0800
[BZ 1034512] Fix bug avail refresh issue when navigating certain paths.
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
index ed26dad..1e07e7a 100644
---
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
@@ -131,7 +131,6 @@ public class MetricsGroupView extends AbstractD3GraphListView
implements
private void addAvailabilityGraph() {
- if(lastResourceGroupId.equals(resourceGroup.getId())) {
expandCollapseHLayout.removeMember(availabilityGraph);
availabilityGraph.destroy();
@@ -141,7 +140,6 @@ public class MetricsGroupView extends AbstractD3GraphListView
implements
queryAvailability(EntityContext.forGroup(resourceGroup.getId()),
CustomDateRangeState.getInstance().getStartTime(),
CustomDateRangeState.getInstance().getEndTime(), null);
- }
}
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 ea18153..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
@@ -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, 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()));
commit 83a449919639de7ce158638acdee4ced5b3b9023
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Dec 13 13:59:55 2013 -0800
[BZ 1034512] Fix a refresh issue with the sparkline graph if a graph row is expanded.
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
index 442067a..89d4f67 100644
---
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
@@ -19,6 +19,9 @@
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;
@@ -58,6 +61,7 @@ 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;
@@ -74,9 +78,6 @@ 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.METRIC_DEF_ID;
-import static
org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.RESOURCE_GROUP_ID;
-
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional
detailed d3 graph.
*
@@ -125,11 +126,12 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
@Override
public void onSelectionChanged(SelectionEvent selectionEvent) {
- addToDashboardButton.enable();
- ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
- if (null != selectedRecord) {
- selectedMetricDefinitionId = selectedRecord
- .getAttributeAsInt(METRIC_DEF_ID.getValue());
+ if (resourceGroup.getGroupCategory() == GroupCategory.COMPATIBLE) {
+ addToDashboardButton.enable();
+ ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
+ if (null != selectedRecord) {
+ selectedMetricDefinitionId =
selectedRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ }
}
}
});
@@ -242,14 +244,15 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
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()));
+ 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);
+ caught);
}
public void onSuccess(Dashboard result) {
@@ -288,7 +291,7 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
@Override
public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- METRIC_DEF_ID.getValue()));
+ METRIC_DEF_ID.getValue()));
refresh();
new Timer() {
@Override
@@ -320,8 +323,7 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
for (int i = startRow; i < endRow; i++) {
ListGridRecord listGridRecord = getRecord(i);
if (null != listGridRecord) {
- int metricDefinitionId = listGridRecord
- .getAttributeAsInt(METRIC_DEF_ID.getValue());
+ int metricDefinitionId =
listGridRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
if (null != metricsTableView && null != expandedRows
&&
metricsTableView.expandedRows.contains(metricDefinitionId)) {
expandRecord(listGridRecord);
@@ -336,8 +338,7 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
*/
protected Canvas getExpansionComponent(final ListGridRecord record) {
final Integer definitionId =
record.getAttributeAsInt(METRIC_DEF_ID.getValue());
- final Integer resourceGroupId = record
- .getAttributeAsInt(RESOURCE_GROUP_ID.getValue());
+ final Integer resourceGroupId =
record.getAttributeAsInt(RESOURCE_GROUP_ID.getValue());
VLayout vLayout = new VLayout();
vLayout.setPadding(5);
@@ -384,7 +385,12 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
@Override
public void run() {
graphView.drawJsniChart();
- BrowserUtility.graphSparkLines();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
}
}.schedule(150);
commit cf71a218e08650623b2308e6e2dda16906e781a0
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Dec 13 09:47:43 2013 -0800
[BZ 1034512] Replace the grid field name constants with a more type-safe enum.
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
index bd9762b..442067a 100644
---
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
@@ -74,6 +74,9 @@ 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.METRIC_DEF_ID;
+import static
org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.RESOURCE_GROUP_ID;
+
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional
detailed d3 graph.
*
@@ -125,10 +128,8 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
addToDashboardButton.enable();
ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
if (null != selectedRecord) {
- //Log.debug("Selected Metric Label: "
- // +
selectedRecord.getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL));
selectedMetricDefinitionId = selectedRecord
-
.getAttributeAsInt(MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID);
+ .getAttributeAsInt(METRIC_DEF_ID.getValue());
}
}
});
@@ -278,7 +279,7 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
@Override
public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
- MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refreshData();
}
@@ -287,7 +288,7 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
@Override
public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refresh();
new Timer() {
@Override
@@ -320,7 +321,7 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
ListGridRecord listGridRecord = getRecord(i);
if (null != listGridRecord) {
int metricDefinitionId = listGridRecord
-
.getAttributeAsInt(MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID);
+ .getAttributeAsInt(METRIC_DEF_ID.getValue());
if (null != metricsTableView && null != expandedRows
&&
metricsTableView.expandedRows.contains(metricDefinitionId)) {
expandRecord(listGridRecord);
@@ -334,9 +335,9 @@ public class MetricsGroupTableView extends
Table<MetricsGroupViewDataSource> imp
* If you expand a grid row then create a graph.
*/
protected Canvas getExpansionComponent(final ListGridRecord record) {
- final Integer definitionId =
record.getAttributeAsInt(MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID);
+ final Integer definitionId =
record.getAttributeAsInt(METRIC_DEF_ID.getValue());
final Integer resourceGroupId = record
- .getAttributeAsInt(MetricsGroupViewDataSource.FIELD_RESOURCE_GROUP_ID);
+ .getAttributeAsInt(RESOURCE_GROUP_ID.getValue());
VLayout vLayout = new VLayout();
vLayout.setPadding(5);
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
index 101e70d..a5f1353 100644
---
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
@@ -19,9 +19,6 @@
package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
-import static org.rhq.core.domain.measurement.DataType.COMPLEX;
-import static org.rhq.core.domain.measurement.DataType.MEASUREMENT;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -41,7 +38,6 @@ 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.MetricDisplayConstants;
import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -55,6 +51,10 @@ 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
@@ -68,18 +68,6 @@ public class MetricsGroupViewDataSource extends
RPCDataSource<MetricDisplaySumma
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_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_GROUP_ID = "resourceGroupId";
-
private final ResourceGroup resourceGroup;
private List<MetricDisplaySummary> metricDisplaySummaries;
private List<List<MeasurementDataNumericHighLowComposite>>
metricsDataList;
@@ -98,7 +86,7 @@ public class MetricsGroupViewDataSource extends
RPCDataSource<MetricDisplaySumma
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) {
@@ -106,8 +94,8 @@ public class MetricsGroupViewDataSource extends
RPCDataSource<MetricDisplaySumma
return "";
}
String contents = "<span id='sparkline_" +
resourceGroup.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;
}
@@ -116,23 +104,23 @@ public class MetricsGroupViewDataSource extends
RPCDataSource<MetricDisplaySumma
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 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);
@@ -153,17 +141,17 @@ public class MetricsGroupViewDataSource extends
RPCDataSource<MetricDisplaySumma
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_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_GROUP_ID, resourceGroup.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(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;
}
@@ -231,7 +219,7 @@ public class MetricsGroupViewDataSource extends
RPCDataSource<MetricDisplaySumma
}
});
- organizeMeasurementDefitionOrder(resourceGroup);
+ organizeMeasurementDefinitionOrder(resourceGroup);
queryMetricDisplaySummaries(definitionArrayIds,
CustomDateRangeState.getInstance().getStartTime(),
CustomDateRangeState.getInstance().getEndTime(), countDownLatch);
@@ -267,7 +255,7 @@ public class MetricsGroupViewDataSource extends
RPCDataSource<MetricDisplaySumma
}
- private void organizeMeasurementDefitionOrder(ResourceGroup resourceGroup) {
+ private void organizeMeasurementDefinitionOrder(ResourceGroup resourceGroup) {
Set<MeasurementDefinition> definitions =
getMetricDefinitions(resourceGroup);
//build id mapping for measurementDefinition instances Ex. Free Memory ->
MeasurementDefinition[100071]
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/CommonMetricsTableView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/CommonMetricsTableView.java
deleted file mode 100644
index c814b97..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/CommonMetricsTableView.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * 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.resource.detail.monitoring.table;
-
-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.Resource;
-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.resource.graph.ResourceD3GraphPortlet;
-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 CommonMetricsTableView<T extends Resource> extends
Table<MetricsViewDataSource> implements Refreshable {
-
- private final T resource;
- 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 CommonMetricsTableView(T resource, AbstractD3GraphListView
abstractD3GraphListView,
- Set<Integer> expandedRows) {
- super();
- this.resource = resource;
- this.abstractD3GraphListView = abstractD3GraphListView;
- dashboardMenuMap = new LinkedHashMap<String, String>();
- dashboardMap = new LinkedHashMap<Integer, Dashboard>();
- setDataSource(new MetricsViewDataSource(resource));
- 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, resource);
- metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- @Override
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- 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);
- }
- }
- });
-
- 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 :
resource.getResourceType().getMetricDefinitions()) {
- if (measurementDefinition.getId() == selectedMetricDefinitionId) {
- Log.debug("Add to Dashboard -- Storing: " +
measurementDefinition.getDisplayName() + " in "
- + selectedDashboard.getName());
- storeDashboardMetric(selectedDashboard, resource,
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, Resource resource,
MeasurementDefinition definition) {
- DashboardPortlet dashboardPortlet = new
DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
- ResourceD3GraphPortlet.KEY, 200);
- dashboardPortlet.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID,
resource.getId()));
- dashboardPortlet.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.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) {
- CoreGUI.getMessageCenter().notify(
- new
Message(MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result.getName()),
- 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 CommonMetricsTableView metricsTableView;
- private Resource resource;
-
- public MetricsTableListGrid(final CommonMetricsTableView metricsTableView, final
Resource resource) {
- super();
- this.resource = resource;
- 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(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
- refreshData();
- }
-
- });
- addRecordCollapseHandler(new RecordCollapseHandler() {
- @Override
- public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
-
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
- 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(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
- if (null != metricsTableView && null != expandedRows
- &&
metricsTableView.expandedRows.contains(metricDefinitionId)) {
- expandRecord(listGridRecord);
- }
- }
- }
- }
-
- 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);
- VLayout vLayout = new VLayout();
- vLayout.setPadding(5);
-
- final String chartId = "rChart-" + resourceId + "-" +
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().findDataForResource(resourceId,
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 [" + resourceId + "]:"
- + 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 :
resource.getResourceType().getMetricDefinitions()) {
- if (definition.getId() == definitionId) {
- measurementDefinition = definition;
- break;
- }
- }
-
- MetricGraphData metricGraphData =
MetricGraphData.createForResource(resourceId,
- resource.getName(), measurementDefinition,
measurementList, null);
- 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();
- BrowserUtility.graphSparkLines();
- }
- }.schedule(150);
-
- } else {
- Log.warn("No chart data retrieving for resource ["
+ resourceId + "-" + definitionId + "]");
- }
- }
- });
-
- return vLayout;
- }
- }
-
-}
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/MetricsTableView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index 8c0cc13..ea18153 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());
}
}
});
@@ -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;
}
commit 6123aeeb10388f8dec4983d8ac83e80fa46ecfee
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Dec 13 17:39:57 2013 +0100
[BZ 1042892] Don't use ${} notation for shell variables in CLI scripts.
As of BZ 959603, the files are subject to maven resource filtering and
so it can happen that the build server passes a variable to the build
process that clashes with the variable name defined in the script.
(Yes, this actually happened on our Jenkins server that passed
"-DCLASSPATH=" to the maven process for some reason, which resulted in
wonderful corruption of the rhq-cli.sh script).
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
index 112ec66..80f24c5 100755
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
@@ -3,6 +3,14 @@
#===========================================================================
#
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# IMPORTANT: Avoid enclosing shell variables in braces using the ${XXX}
+# notation. This file is subject to maven resource variable expansion
+# during the build and so it can happen that the build environment
+# could corrupt this file by expanding variables that clash with
+# the names defined herein.
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
# RHQ_CLI_DEBUG - If this is defined, the script will emit debug
# messages. It will also enable debug
# messages to be emitted from the cli itself.
@@ -41,7 +49,7 @@
# to the CLI's defaults, then you will want to
# use RHQ_CLI_ADDITIONAL_JAVA_OPTS instead.
#
-#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
+#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=$RHQ_CLI_MODULES_DIR"
# RHQ_CLI_JAVA_ENDORSED_DIRS - Java VM command line option to set the
# endorsed dirs for the CLI's VM. If this
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
index 8399b50..b0980e6 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
@@ -11,6 +11,14 @@
# set via rhq-client-env.sh, which is sourced by this script.
# =============================================================================
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# IMPORTANT: Avoid enclosing shell variables in braces using the ${XXX}
+# notation. This file is subject to maven resource variable expansion
+# during the build and so it can happen that the build environment
+# could corrupt this file by expanding variables that clash with
+# the names defined herein.
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
# ----------------------------------------------------------------------
# Subroutine that simply dumps a message iff debug mode is enabled
# ----------------------------------------------------------------------
@@ -42,16 +50,17 @@ esac
_DOLLARZERO=`readlink "$0" 2>/dev/null || echo "$0"`
RHQ_CLI_BIN_DIR_PATH=`dirname "$_DOLLARZERO"`
-if [ -f "${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh" ]; then
- debug_msg "Loading environment script:
${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
- . "${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh" $*
+if [ -f "$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh" ]; then
+ debug_msg "Loading environment script:
$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh"
+ . "$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh" $*
else
- debug_msg "No environment script found at:
${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
+ debug_msg "No environment script found at:
$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh"
fi
# this variable is set during the build and defines the desired default behavior for
directory changing
# we do want to change the dir in RHQ, but possibly don't want to do that in JBoss ON
for backwards compatibility
# reasons.
+# (yes, this USES ${} in the source (not in the distribution) because we seed the default
value from the build)
RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT=${rhq.cli.change-dir-on-start-default}
if [ -z "$RHQ_CLI_CHANGE_DIR_ON_START" ]; then
RHQ_CLI_CHANGE_DIR_ON_START="$RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT"
@@ -61,24 +70,24 @@ fi
# Previous versions always changed directory.
if [ -n "$RHQ_CLI_CHANGE_DIR_ON_START" -a
"$RHQ_CLI_CHANGE_DIR_ON_START" != "false" ]; then
if [ -z "$RHQ_CLI_HOME" ]; then
- cd "${RHQ_CLI_BIN_DIR_PATH}/.."
+ cd "$RHQ_CLI_BIN_DIR_PATH/.."
else
- cd "${RHQ_CLI_HOME}" || {
- echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}"
+ cd "$RHQ_CLI_HOME" || {
+ echo "Cannot go to the RHQ_CLI_HOME directory: $RHQ_CLI_HOME"
exit 1
}
fi
RHQ_CLI_HOME=`pwd`
else
if [ -z "$RHQ_CLI_HOME" ]; then
- RHQ_CLI_HOME="${RHQ_CLI_BIN_DIR_PATH}/.."
+ RHQ_CLI_HOME="$RHQ_CLI_BIN_DIR_PATH/.."
fi
#get an absolute path
RHQ_CLI_HOME=`readlink -f "$RHQ_CLI_HOME"`
if [ ! -d "$RHQ_CLI_HOME" ]; then
- echo "RHQ_CLI_HOME detected or defined as [${RHQ_CLI_HOME}] doesn't seem
to exist or is not a directory"
+ echo "RHQ_CLI_HOME detected or defined as [$RHQ_CLI_HOME] doesn't seem
to exist or is not a directory"
exit 1
fi
fi
@@ -90,7 +99,7 @@ debug_msg "RHQ_CLI_HOME: $RHQ_CLI_HOME"
# sample modules.
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_MODULES_DIR" ]; then
- RHQ_CLI_MODULES_DIR="${RHQ_CLI_HOME}/samples/modules"
+ RHQ_CLI_MODULES_DIR="$RHQ_CLI_HOME/samples/modules"
fi
# ----------------------------------------------------------------------
@@ -110,7 +119,7 @@ fi
if [ -z "$RHQ_CLI_JAVA_EXE_FILE_PATH" ]; then
if [ -z "$RHQ_CLI_JAVA_HOME" ]; then
- RHQ_CLI_JAVA_HOME="${RHQ_CLI_HOME}/jre"
+ RHQ_CLI_JAVA_HOME="$RHQ_CLI_HOME/jre"
if [ -d "$RHQ_CLI_JAVA_HOME" ]; then
debug_msg "Using the embedded JRE"
else
@@ -119,7 +128,7 @@ if [ -z "$RHQ_CLI_JAVA_EXE_FILE_PATH" ]; then
fi
fi
debug_msg "RHQ_CLI_JAVA_HOME: $RHQ_CLI_JAVA_HOME"
- RHQ_CLI_JAVA_EXE_FILE_PATH=${RHQ_CLI_JAVA_HOME}/bin/java
+ RHQ_CLI_JAVA_EXE_FILE_PATH="$RHQ_CLI_JAVA_HOME/bin/java"
fi
debug_msg "RHQ_CLI_JAVA_EXE_FILE_PATH: $RHQ_CLI_JAVA_EXE_FILE_PATH"
@@ -133,14 +142,14 @@ fi
# Prepare the classpath (take into account possible spaces in dir names)
# ----------------------------------------------------------------------
-CLASSPATH="${RHQ_CLI_HOME}/conf"
-_JAR_FILES=`cd "${RHQ_CLI_HOME}/lib";ls -1 *.jar`
+CLASSPATH="$RHQ_CLI_HOME/conf"
+_JAR_FILES=`cd "$RHQ_CLI_HOME/lib";ls -1 *.jar`
for _JAR in $_JAR_FILES ; do
- _JAR="${RHQ_CLI_HOME}/lib/${_JAR}"
+ _JAR="$RHQ_CLI_HOME/lib/$_JAR"
if [ -z "$CLASSPATH" ]; then
- CLASSPATH="${_JAR}"
+ CLASSPATH="$_JAR"
else
- CLASSPATH="${CLASSPATH}:${_JAR}"
+ CLASSPATH="$CLASSPATH:$_JAR"
fi
debug_msg "CLASSPATH entry: $_JAR"
done
@@ -151,7 +160,7 @@ debug_msg "CLASSPATH entry: $_JAR"
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_JAVA_OPTS" ]; then
- RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
+ RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=$RHQ_CLI_MODULES_DIR"
fi
debug_msg "RHQ_CLI_JAVA_OPTS: $RHQ_CLI_JAVA_OPTS"
@@ -159,7 +168,7 @@ if [ "$RHQ_CLI_JAVA_ENDORSED_DIRS" = "none" ];
then
debug_msg "Not explicitly setting java.endorsed.dirs"
else
if [ -z "$RHQ_CLI_JAVA_ENDORSED_DIRS" ]; then
- RHQ_CLI_JAVA_ENDORSED_DIRS="${RHQ_CLI_HOME}/lib/endorsed"
+ RHQ_CLI_JAVA_ENDORSED_DIRS="$RHQ_CLI_HOME/lib/endorsed"
fi
# convert the path if on Windows
@@ -167,14 +176,14 @@ else
RHQ_CLI_JAVA_ENDORSED_DIRS=`cygpath --windows --path
"$RHQ_CLI_JAVA_ENDORSED_DIRS"`
fi
debug_msg "RHQ_CLI_JAVA_ENDORSED_DIRS: $RHQ_CLI_JAVA_ENDORSED_DIRS"
-
_JAVA_ENDORSED_DIRS_OPT="-Djava.endorsed.dirs=\"${RHQ_CLI_JAVA_ENDORSED_DIRS}\""
+
_JAVA_ENDORSED_DIRS_OPT="-Djava.endorsed.dirs=\"$RHQ_CLI_JAVA_ENDORSED_DIRS\""
fi
if [ "$RHQ_CLI_JAVA_LIBRARY_PATH" = "none" ]; then
debug_msg "Not explicitly setting java.library.path"
else
if [ -z "$RHQ_CLI_JAVA_LIBRARY_PATH" ]; then
- RHQ_CLI_JAVA_LIBRARY_PATH="${RHQ_CLI_HOME}/lib"
+ RHQ_CLI_JAVA_LIBRARY_PATH="$RHQ_CLI_HOME/lib"
fi
# convert the path if on Windows
@@ -182,7 +191,7 @@ else
RHQ_CLI_JAVA_LIBRARY_PATH=`cygpath --windows --path
"$RHQ_CLI_JAVA_LIBRARY_PATH"`
fi
debug_msg "RHQ_CLI_JAVA_LIBRARY_PATH: $RHQ_CLI_JAVA_LIBRARY_PATH"
-
_JAVA_LIBRARY_PATH_OPT="-Djava.library.path=\"${RHQ_CLI_JAVA_LIBRARY_PATH}\""
+
_JAVA_LIBRARY_PATH_OPT="-Djava.library.path=\"$RHQ_CLI_JAVA_LIBRARY_PATH\""
fi
debug_msg "RHQ_CLI_ADDITIONAL_JAVA_OPTS: $RHQ_CLI_ADDITIONAL_JAVA_OPTS"
@@ -201,8 +210,8 @@ if [ -n "$RHQ_CLI_DEBUG" ]; then
fi
# create the logs directory
-if [ ! -d "${RHQ_CLI_HOME}/logs" ]; then
- mkdir "${RHQ_CLI_HOME}/logs"
+if [ ! -d "$RHQ_CLI_HOME/logs" ]; then
+ mkdir "$RHQ_CLI_HOME/logs"
fi
# convert some of the paths if we are on Windows
@@ -220,15 +229,15 @@ fi
debug_msg "Executing the CLI with this command line:"
exit_code=0
if [ -z "$RHQ_CLI_CMDLINE_OPTS" ]; then
- debug_msg "${RHQ_CLI_JAVA_EXE_FILE_PATH} ${_JAVA_ENDORSED_DIRS_OPT}
${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS}
${_LOG_CONFIG} -cp ${CLASSPATH} org.rhq.enterprise.client.ClientMain $@"
- "${RHQ_CLI_JAVA_EXE_FILE_PATH}" ${_JAVA_ENDORSED_DIRS_OPT}
${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS}
${_LOG_CONFIG} -cp "${CLASSPATH}" org.rhq.enterprise.client.ClientMain
"$@"
+ debug_msg "$RHQ_CLI_JAVA_EXE_FILE_PATH $_JAVA_ENDORSED_DIRS_OPT
$_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp
$CLASSPATH org.rhq.enterprise.client.ClientMain $@"
+ "$RHQ_CLI_JAVA_EXE_FILE_PATH" $_JAVA_ENDORSED_DIRS_OPT
$_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp
"$CLASSPATH" org.rhq.enterprise.client.ClientMain "$@"
exit_code=$?
else
- debug_msg "${RHQ_CLI_JAVA_EXE_FILE_PATH} ${_JAVA_ENDORSED_DIRS_OPT}
${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS}
${_LOG_CONFIG} -cp ${CLASSPATH} org.rhq.enterprise.client.ClientMain
${RHQ_CLI_CMDLINE_OPTS}"
- "${RHQ_CLI_JAVA_EXE_FILE_PATH}" ${_JAVA_ENDORSED_DIRS_OPT}
${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS}
${_LOG_CONFIG} -cp "${CLASSPATH}" org.rhq.enterprise.client.ClientMain
${RHQ_CLI_CMDLINE_OPTS}
+ debug_msg "$RHQ_CLI_JAVA_EXE_FILE_PATH $_JAVA_ENDORSED_DIRS_OPT
$_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp
$CLASSPATH org.rhq.enterprise.client.ClientMain $RHQ_CLI_CMDLINE_OPTS"
+ "$RHQ_CLI_JAVA_EXE_FILE_PATH" $_JAVA_ENDORSED_DIRS_OPT
$_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp
"$CLASSPATH" org.rhq.enterprise.client.ClientMain $RHQ_CLI_CMDLINE_OPTS
exit_code=$?
fi
debug_msg "$0 done."
-exit ${exit_code}
+exit $exit_code
commit 54f1ba2671403d2d03be92fe788af6c56e8a77af
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Dec 13 10:08:04 2013 +0100
No need to print the stack trace here - many systems do not have libvirt installed.
diff --git
a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java
b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java
index 749c4c1..98aca93 100644
---
a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java
+++
b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java
@@ -35,7 +35,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.virt.LibVirtConnection.HVInfo;
/**
- * Discovers Host and Guest information using
+ * Discovers Host and Guest information using
*/
public class VirtualizationHostDiscoveryComponent implements ResourceDiscoveryComponent,
ManualAddFacet {
@@ -68,7 +68,12 @@ public class VirtualizationHostDiscoveryComponent implements
ResourceDiscoveryCo
res.getPluginConfiguration().put(new
PropertySimple("connectionURI", virt.getConnectionURI()));
virt.close();
} catch (Throwable t) {
- log.warn("Can not load libvirt: " + t.getMessage(), t);
+ String message = t.getMessage();
+ if (t.getCause()!=null) {
+ message += ": " + t.getCause().getMessage();
+ }
+ log.warn("Can not load libvirt: " + message);
+
}
return res;
commit ccfecb8ea65625758ceaf277892a67e580bf7197
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Dec 12 22:17:25 2013 +0100
Check if the parent can be cast to JMXComponent before doing so.
diff --git
a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java
b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java
index 4d1eecf..b3fabfa 100644
---
a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java
+++
b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java
@@ -23,6 +23,7 @@
package org.rhq.plugins.jbosscache;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -43,10 +44,10 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
/**
* Discover JBossCache instances. The only way to detect them are to
* look for "*:cache-interceptor=CacheMgmtInterceptor,*" or
"*:treecache-interceptor=CacheMgmtInterceptor,*"
- * This is done in {@link MBeanResourceDiscoveryComponent}. We postprocess the result
here to
+ * This is done in {@link MBeanResourceDiscoveryComponent}. We postprocess the result
here to
* get the base MBean name (without the property for detection) to be able to use this
later and also
* for display purposes, as this is the MBean name the user set up in his MBean.
- *
+ *
* @author Heiko W. Rupp
*/
public class JBossCacheDiscoveryComponent extends
MBeanResourceDiscoveryComponent<JMXComponent<?>> {
@@ -60,6 +61,11 @@ public class JBossCacheDiscoveryComponent extends
MBeanResourceDiscoveryComponen
public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) {
ResourceContext parentCtx = context.getParentResourceContext();
+
+ if (!(parentCtx.getParentResourceComponent() instanceof JMXComponent)) {
+ return Collections.emptySet();
+ }
+
JMXComponent<JBossASServerComponent<?>> gparentComponent =
(JMXComponent<JBossASServerComponent<?>>)
parentCtx.getParentResourceComponent();
Set<DiscoveredResourceDetails> discovered =
super.performDiscovery(context.getDefaultPluginConfiguration(), gparentComponent,
context.getResourceType(), false);
commit 91aae3c93d39aba6d745b10a1833a361e9043809
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 12 22:43:55 2013 +0100
Better testability in the ModulesDirectoryScriptSourceProvider.
Also changed the default module path from "./samples/modules" to
"./modules". This should be safe with the fix for BZ 959603 which
causes the CLI to always pass the system property to load the modules
from. The new default path is less coupled with the FS layout of the CLI
distribution.
diff --git
a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java
b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java
index 0e46abe..6040e8e 100644
---
a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java
+++
b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java
@@ -30,13 +30,38 @@ import java.net.URI;
*/
public class ModulesDirectoryScriptSourceProvider extends FileSystemScriptSourceProvider
{
- private static final File ROOT_DIR = new
File(System.getProperty("rhq.scripting.modules.root-dir",
"./samples/modules"));
private static final String SCHEME = "modules";
-
+
+ private File rootDir;
+
+ /**
+ * Creates a new instance of module script source provider that looks for the module
sources in a directory
+ * specified by the "rhq.scripting.modules.root-dir" system property. If
none such exists, the default value
+ * is assumed to be "./modules".
+ */
public ModulesDirectoryScriptSourceProvider() {
+ this(new File(System.getProperty("rhq.scripting.modules.root-dir",
"./modules")));
+ }
+
+ /**
+ * Provided for testing purposes. A script source provider is only instantiated
through its no-arg constructor
+ * in the scripting environment.
+ *
+ * @param rootDir the root directory under which to locate module sources
+ */
+ public ModulesDirectoryScriptSourceProvider(File rootDir) {
super(SCHEME);
+ this.rootDir = rootDir;
}
-
+
+ public File getRootDir() {
+ return rootDir;
+ }
+
+ public void setRootDir(File rootDir) {
+ this.rootDir = rootDir;
+ }
+
@Override
protected File getFile(URI location) {
String path = location.getPath();
@@ -44,6 +69,6 @@ public class ModulesDirectoryScriptSourceProvider extends
FileSystemScriptSource
//remove the leading /
path = path.substring(1);
- return new File(ROOT_DIR, path);
+ return new File(rootDir, path);
}
}
diff --git
a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProviderTest.java
b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProviderTest.java
new file mode 100644
index 0000000..4060d07
--- /dev/null
+++
b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProviderTest.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.enterprise.client.script;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.junit.BeforeClass;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Lukas Krejci
+ * @since 4.10.0
+ */
+@Test
+public class ModulesDirectoryScriptSourceProviderTest {
+
+ private File scriptFile;
+
+ @BeforeClass
+ public void createScriptFile() throws IOException {
+ scriptFile = File.createTempFile("modules-test", ".js", new
File("."));
+ PrintWriter wrt = new PrintWriter(new FileOutputStream(scriptFile));
+ try {
+ wrt.write("var a = 2;");
+ } finally {
+ wrt.close();
+ }
+ }
+
+ @AfterClass
+ public void deleteScriptFile() {
+ scriptFile.delete();
+ }
+
+ public void testLoad() throws URISyntaxException {
+ ModulesDirectoryScriptSourceProvider provider = new
ModulesDirectoryScriptSourceProvider(new File("."));
+
+ File f = provider.getFile(new URI("modules:/" +
scriptFile.getName()));
+
+ assertEquals(f, scriptFile, "Unexpected file loaded");
+ }
+}
commit 62a923a74661305cf4532525ec36a2c7d7a2a719
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 12 23:10:14 2013 +0100
[BZ 959603] - Don't change CWD on CLI startup.
Since the very beginning of CLI, RHQ always changed the CWD to
$RHQ_CLI_HOME when starting up, which is rather strange and
non-standard.
To keep the backwards compatibility, the behavior can be toggled on
or off.
The default behavior can be changed in the build by setting the
rhq.cli.change-dir-on-start-default
property. In RHQ, this defaults to "false", causing RHQ to NOT change
directories when starting up the CLI anymore.
Further, the behavior can be toggled by the user by setting the
RHQ_CLI_CHANGE_DIR_ON_START environment variable to "true" (or any
other value but "false" actually) or "false" explicitly.
Additionally, a new environment variable called "RHQ_CLI_MODULES_DIR"
was added. This was necessary to not break the loading of the
provided CommonJS modules available in the
$RHQ_CLI_HOME/samples/modules directory if the CLI was started from
another directory.
By adding the new RHQ_CLI_MODULES_DIR, which is initialized to the
correct value if not provided externally, we correctly load the
sample modules with the additional benefit of easier change of the
modules location for the user (previously this was only possible
through
RHQ_CLI_ADDITIONAL_JAVA_OPTS="-Drhq.scripting.modules.root-dir=..."
, while now one only needs RHQ_CLI_MODULES_DIR=...).
diff --git a/modules/enterprise/remoting/cli/pom.xml
b/modules/enterprise/remoting/cli/pom.xml
index 7515110..296b490 100644
--- a/modules/enterprise/remoting/cli/pom.xml
+++ b/modules/enterprise/remoting/cli/pom.xml
@@ -13,7 +13,11 @@
<name>RHQ Enterprise Remote CLI</name>
<description>RHQ Enterprise Remote Command Line Interface</description>
-
+
+ <properties>
+
<rhq.cli.change-dir-on-start-default>false</rhq.cli.change-dir-on-start-default>
+ </properties>
+
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -78,7 +82,18 @@
</dependencies>
<build>
- <plugins>
+ <resources>
+ <resource>
+ <directory>src/etc</directory>
+ <filtering>true</filtering>
+
<targetPath>${project.build.outputDirectory}/../etc</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+
+ <plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat
b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat
index d5d1189..dcf1ec8 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat
@@ -37,7 +37,7 @@ rem CLI's defaults. If you only want to add
options
rem to the CLI's defaults, then you will want to
rem use RHQ_CLI_ADDITIONAL_JAVA_OPTS instead.
rem
-rem set RHQ_CLI_JAVA_OPTS=-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
+rem set RHQ_CLI_JAVA_OPTS=-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir="%RHQ_CLI_MODULES_DIR%"
rem RHQ_CLI_JAVA_ENDORSED_DIRS - Java VM command line option to set the
rem endorsed dirs for the CLI's VM. If this
@@ -74,3 +74,33 @@ rem line options and the ones specified
here will
rem be passed to the CLI.
rem
rem set RHQ_CLI_CMDLINE_OPTS=
+
+rem RHQ_CLI_CHANGE_DIR_ON_START - By setting this variable to true (or any
+rem other value than "false") you can make
RHQ
+rem change the directory to $RHQ_CLI_HOME when
+rem starting the CLI. When this variable is set
+rem to false, the current working directory is
+rem NOT changed when starting the CLI.
+rem
+rem If not set, this variable is understood
+rem to be: ${rhq.cli.change-dir-on-start-default}
+rem set RHQ_CLI_CHANGE_DIR_ON_START=true
+
+rem RHQ_CLI_MODULES_DIR - The default location from which to load CommonJS
+rem modules available through the "modules:/" scheme
+rem is $RHQ_CLI_HOME/samples/modules.
+rem Setting this variable to another value, causes
+rem the modules to be loaded from another location.
+rem
+rem Notice that this can be a relative path, too.
+rem For example, setting:
+rem RHQ_CLI_MODULES_DIR=./modules
+rem would cause the CLI to load modules from the
+rem "modules" subdirectory of whichever current
+rem working directory it is started from.
+rem (See RHQ_CLI_JAVA_OPTS and
+rem RHQ_CLI_CHANGE_DIR_ON_START variables above for
+rem further details of this approach).
+rem
+rem set RHQ_CLI_MODULE_DIR=Z:\company-wide\rhq\cli\modules
+
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
index 2c0affa..112ec66 100755
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
@@ -41,7 +41,7 @@
# to the CLI's defaults, then you will want to
# use RHQ_CLI_ADDITIONAL_JAVA_OPTS instead.
#
-#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true"
+#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
# RHQ_CLI_JAVA_ENDORSED_DIRS - Java VM command line option to set the
# endorsed dirs for the CLI's VM. If this
@@ -78,3 +78,33 @@
# be passed to the CLI.
#
#RHQ_CLI_CMDLINE_OPTS=""
+
+# RHQ_CLI_CHANGE_DIR_ON_START - By setting this variable to true (or any
+# other value than "false") you can make RHQ
+# change the directory to $RHQ_CLI_HOME when
+# starting the CLI. When this variable is set
+# to false, the current working directory is
+# NOT changed when starting the CLI.
+#
+# If not set, this variable is understood
+# to be: ${rhq.cli.change-dir-on-start-default}
+#RHQ_CLI_CHANGE_DIR_ON_START=true
+
+# RHQ_CLI_MODULES_DIR - The default location from which to load CommonJS
+# modules available through the "modules:/" scheme
+# is $RHQ_CLI_HOME/samples/modules.
+# Setting this variable to another value, causes
+# the modules to be loaded from another location.
+#
+# Notice that this can be a relative path, too.
+# For example, setting:
+# RHQ_CLI_MODULES_DIR=./modules
+# would cause the CLI to load modules from the
+# "modules" subdirectory of whichever current
+# working directory it is started from.
+# (See RHQ_CLI_JAVA_OPTS and
+# RHQ_CLI_CHANGE_DIR_ON_START variables above for
+# further details of this approach).
+#
+#RHQ_CLI_MODULE_DIR=/opt/company-wide/rhq/cli/modules
+
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli.bat
b/modules/enterprise/remoting/cli/src/etc/rhq-cli.bat
index 8c96ed7..13dd762 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli.bat
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli.bat
@@ -20,13 +20,6 @@ if "%RHQ_CLI_DEBUG%" == "false" (
set RHQ_CLI_DEBUG=
)
-rem ----------------------------------------------------------------------
-rem Change directory so the current directory is the CLI home.
-rem Here we assume this script is a child directory of the CLI home
-rem We also assume our custom environment script is located in the same
-rem place as this script.
-rem ----------------------------------------------------------------------
-
set RHQ_CLI_BIN_DIR_PATH=%~dp0
if exist "%RHQ_CLI_BIN_DIR_PATH%\rhq-cli-env.bat" (
@@ -36,11 +29,38 @@ if exist "%RHQ_CLI_BIN_DIR_PATH%\rhq-cli-env.bat" (
if defined RHQ_CLI_DEBUG echo No environment script found at:
%RHQ_CLI_BIN_DIR_PATH%\rhq-cli-env.bat
)
-rem if debug variable is set, it is assumed to be on, unless its value is false
+rem this variable is set during the build and defines the desired default behavior for
directory changing
+rem we do want to change the dir in RHQ, but possibly don't want to do that in JBoss
ON for backwards compatibility
+rem reasons.
+set RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT=${rhq.cli.change-dir-on-start-default}
+
+if not defined RHQ_CLI_CHANGE_DIR_ON_START (
+ set RHQ_CLI_CHANGE_DIR_ON_START=%RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT%
+)
+
+rem RHQ_CLI_CHANGE_DIR_ON_START behaves the same as RHQ_CLI_DEBUG - if set, it is assumed
on, unless equal to false
+if "%RHQ_CLI_CHANGE_DIR_ON_START%" == "false" (
+ set RHQ_CLI_CHANGE_DIR_ON_START=
+)
+
+rem if debug variable is set, it is assumed to be on, unless its value is false (do this
again after we've loaded
+rem the env script)
if "%RHQ_CLI_DEBUG%" == "false" (
set RHQ_CLI_DEBUG=
)
+rem ----------------------------------------------------------------------
+rem Change directory so the current directory is the CLI home.
+rem Here we assume this script is a child directory of the CLI home
+rem We also assume our custom environment script is located in the same
+rem place as this script.
+rem ----------------------------------------------------------------------
+
+rem since RHQ 4.10.0 we don't change the directory to the RHQ_CLI_HOME by default
+if not defined RHQ_CLI_CHANGE_DIR_ON_START (
+ pushd .
+)
+
if not defined RHQ_CLI_HOME (
cd "%RHQ_CLI_BIN_DIR_PATH%\.."
) else (
@@ -52,9 +72,22 @@ if not defined RHQ_CLI_HOME (
set RHQ_CLI_HOME=%CD%
+rem since RHQ 4.10.0 we don't change the directory to the RHQ_CLI_HOME by default
+if not defined RHQ_CLI_CHANGE_DIR_ON_START (
+ popd
+)
+
if defined RHQ_CLI_DEBUG echo RHQ_CLI_HOME: %RHQ_CLI_HOME%
rem ----------------------------------------------------------------------
+rem Prepare the modules:/ script source provider to by default load our
+rem sample modules.
+rem ----------------------------------------------------------------------
+if not defined RHQ_CLI_MODULES_DIR (
+ set RHQ_CLI_MODULES_DIR="%RHQ_CLI_HOME%\samples\modules"
+)
+
+rem ----------------------------------------------------------------------
rem Find the Java executable and verify we have a VM available
rem Note that RHQ_CLI_JAVA_* props are still handled for back compat
rem ----------------------------------------------------------------------
@@ -105,7 +138,7 @@ rem Prepare the VM command line options to be passed in
rem ----------------------------------------------------------------------
if not defined RHQ_CLI_JAVA_OPTS (
- set RHQ_CLI_JAVA_OPTS=-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
+ set RHQ_CLI_JAVA_OPTS=-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir="%RHQ_CLI_MODULES_DIR%"
)
if defined RHQ_CLI_DEBUG echo RHQ_CLI_JAVA_OPTS: %RHQ_CLI_JAVA_OPTS%
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
index 9fce451..8399b50 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
@@ -49,20 +49,51 @@ else
debug_msg "No environment script found at:
${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
fi
-if [ -z "$RHQ_CLI_HOME" ]; then
- cd "${RHQ_CLI_BIN_DIR_PATH}/.."
-else
- cd "${RHQ_CLI_HOME}" || {
- echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}"
- exit 1
- }
+# this variable is set during the build and defines the desired default behavior for
directory changing
+# we do want to change the dir in RHQ, but possibly don't want to do that in JBoss ON
for backwards compatibility
+# reasons.
+RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT=${rhq.cli.change-dir-on-start-default}
+if [ -z "$RHQ_CLI_CHANGE_DIR_ON_START" ]; then
+ RHQ_CLI_CHANGE_DIR_ON_START="$RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT"
fi
-RHQ_CLI_HOME=`pwd`
+# Only change the directory on start when told so. This is new in RHQ 4.10.0.
+# Previous versions always changed directory.
+if [ -n "$RHQ_CLI_CHANGE_DIR_ON_START" -a
"$RHQ_CLI_CHANGE_DIR_ON_START" != "false" ]; then
+ if [ -z "$RHQ_CLI_HOME" ]; then
+ cd "${RHQ_CLI_BIN_DIR_PATH}/.."
+ else
+ cd "${RHQ_CLI_HOME}" || {
+ echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}"
+ exit 1
+ }
+ fi
+ RHQ_CLI_HOME=`pwd`
+else
+ if [ -z "$RHQ_CLI_HOME" ]; then
+ RHQ_CLI_HOME="${RHQ_CLI_BIN_DIR_PATH}/.."
+ fi
+
+ #get an absolute path
+ RHQ_CLI_HOME=`readlink -f "$RHQ_CLI_HOME"`
+
+ if [ ! -d "$RHQ_CLI_HOME" ]; then
+ echo "RHQ_CLI_HOME detected or defined as [${RHQ_CLI_HOME}] doesn't seem
to exist or is not a directory"
+ exit 1
+ fi
+fi
debug_msg "RHQ_CLI_HOME: $RHQ_CLI_HOME"
# ----------------------------------------------------------------------
+# Prepare the modules:/ script source provider to by default load our
+# sample modules.
+# ----------------------------------------------------------------------
+if [ -z "$RHQ_CLI_MODULES_DIR" ]; then
+ RHQ_CLI_MODULES_DIR="${RHQ_CLI_HOME}/samples/modules"
+fi
+
+# ----------------------------------------------------------------------
# If we are on a Mac and JAVA_HOME is not set, then set it to /usr
# as this is the default location.
# ----------------------------------------------------------------------
@@ -113,8 +144,6 @@ for _JAR in $_JAR_FILES ; do
fi
debug_msg "CLASSPATH entry: $_JAR"
done
-_JAR="${RHQ_CLI_HOME}/jbossws-native-dist/deploy/lib/jbossws-client.jar"
-CLASSPATH="${CLASSPATH}:${_JAR}"
debug_msg "CLASSPATH entry: $_JAR"
# ----------------------------------------------------------------------
@@ -122,7 +151,7 @@ debug_msg "CLASSPATH entry: $_JAR"
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_JAVA_OPTS" ]; then
- RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true"
+ RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
fi
debug_msg "RHQ_CLI_JAVA_OPTS: $RHQ_CLI_JAVA_OPTS"
diff --git a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
index 1836e9f..a752037 100644
--- a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
+++ b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
@@ -26,7 +26,7 @@
<target name="prepare-bin-dir">
<echo>*** Populating bin scripts...</echo>
<copy verbose="true" toDir="${bin.home}">
- <fileset dir="${basedir}/src/etc/" includes="rhq-cli*.*"
/>
+ <fileset dir="${basedir}/target/etc/"
includes="rhq-cli*.*" />
</copy>
<chmod dir="${bin.home}" perm="ug+rx"
includes="*.sh" />
</target>
commit 8c9d4c7aa2b894f1d3ddbe7b8d65f3fb45c2ba74
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 12 13:43:56 2013 +0100
Removing old WS client files from CLI codebase
diff --git a/modules/enterprise/remoting/cli/src/etc/Remoting_Setup.txt
b/modules/enterprise/remoting/cli/src/etc/Remoting_Setup.txt
deleted file mode 100644
index 10bf3dc..0000000
--- a/modules/enterprise/remoting/cli/src/etc/Remoting_Setup.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-# Steps to build and run Remoting CLI:
-
-i) Checkout RHQ
-
-ii) Enable [rhq_source]/modules/enterprise/client/src/main/java as a java source
directory for your ide. For eclipse users, 'use as source folder'
-
-iii) Build RHQ from [rhq_source] and enable the Webservice endpoints by passing in the
following additional parameter at build time:
- -Drhq.server.enable.ws
-
-iv) Run rhq as normal and after startup, verify that your webservices are deployed at
http://[server]:7080/jbossws/services
-
-v) Until we figure out how to correctly fit this client side portion into the maven
build, or even if, the following will need to be done in your IDE/Dev environment to get
the client side JAXB generated types to run the following steps successfully. Jay is
tasked with Maven-izing it.
- a) Open up a shell and navigate to [rhq_source]/modules/enterprise/client/src/ and run
generate-jaxb-client-types.sh/bat script to generate all JAXB types to ./output directory.
- b) Add ./output directory to the top of your classpath setup in your IDE.
- c) Add the XStream 1.2.2 library from your maven repository to the classpath for your
project as well.
- d) Download JLine 0.9.94 library and add it to the classpath for your project as
well.
-
-vi) Run the test suite (currently incomplete and we'll be enhancing it as we move
forward) by:
- a)Log into the RHQ GUI client and create a new WS test user, u:ws-test p:ws-test and
the "Super User" Role.
- b)You should be able to startup XMLClientMainTest.java from you IDE and run it as a
junit test.
-
-
-Notes:
--i) Take extra care that the classes that you are using for the exposed SLSBs are coming
out of the 'org.rhq.enterprise.server.ws' package only. Any components that are
using types NOT from these client side JAXB elements is using server side types which we
do NOT want to do. We need to continue to operate as a pure JAXB client so that we most
closely mimic the operating environment for all WS* clients.
-
-ii) Sometimes it is helpful when debugging the webservice interface to see what the
client side or server side type actually looks like as XML. XStream, while inefficient
for serializing arbitrary java object trees, is much less picky about serializing these
object trees so you can get a quick picture of a given object. JAXB typically will not
serialize unless you do some extra coding.
-
-
-iii) After jaxb type generation may need to:
-
- A)
-Navigate to org.rhq.enterprise.server.ws.ContentManagerRemote.getPackageTypes and change
-
-throws ResourceTypeNotFoundException_Exception
- to
-throws ResourceTypeNotFoundException
-
- B) Navigate to and change
-public class ResourceTypeNotFoundException {
- to
-public class ResourceTypeNotFoundException extends Throwable {
-
- C) Delete the ResourceTypeNotFoundException_Exception class.
diff --git a/modules/enterprise/remoting/cli/src/etc/build.xml
b/modules/enterprise/remoting/cli/src/etc/build.xml
deleted file mode 100644
index 6aa91c1..0000000
--- a/modules/enterprise/remoting/cli/src/etc/build.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<project name="RHQ Remoting" basedir="."
default="jar">
-
- <!--location that JAXB remote ws types are compiled to -->
- <property name="rhq-jaxb-types-location"
- location="${basedir}/output"/>
-
- <!--location that RHQ client classes are compiled to -->
- <property name="rhq-remote-classes"
- location="${basedir}/bin"/>
-
- <!--location for JLine dependency -->
- <property name="jline-jar"
- location="C:/installers/Jline/jline-0.9.94/jline-0.9.94.jar"/>
-
- <!-- -->
- <property name="repo" location="C:/Documents and
Settings/Simeon/.m2/repository"/>
-
- <!--location for Gnu-Getopt dependency -->
- <property name="gnu-jar"
- location="${repo}/gnu-getopt/getopt/1.0.13/getopt-1.0.13.jar"/>
-
- <!--location for Gnu-Getopt dependency -->
- <property name="i18-jar"
- location="${repo}/i18nlog/i18nlog/1.0.10/i18nlog-1.0.10.jar"/>
-
- <property name="runLocation" value="${basedir}/run"/>
-
- <path id="project.class.path">
- <pathelement location="${runLocation}/getopt-1.0.13.jar"/>
- <pathelement location="${runLocation}/remoting.jar"/>
- <pathelement location="${runLocation}/jline-0.9.94.jar"/>
- <pathelement location="${runLocation}/i18nlog-1.0.10.jar"/>
-<!-- <pathelement path="${java.class.path}/"/>
- <pathelement path="${additional.path}"/> -->
- </path>
-
-
- <!--This target bundles up the remoting elements as an
- executable jar
- -->
- <target name="jar" description="Make executable jar">
- <delete file="${runLocation}/remoting.jar"/>
- <jar destfile="${runLocation}/remoting.jar"
- basedir="${rhq-remote-classes}"
- includes="org/rhq/**"
- excludes="**/WsFindGroupsCommand.class"
- />
-
- <!-- Copy all necessary jars to that location too -->
- <copy tofile="${runLocation}/jline-0.9.94.jar"
file="${jline-jar}"/>
- <copy tofile="${runLocation}/getopt-1.0.13.jar"
file="${gnu-jar}"/>
- <copy tofile="${runLocation}/i18nlog-1.0.10.jar"
file="${i18-jar}"/>
- <copy tofile="${runLocation}/toRun.txt"
file="${basedir}/toRun.txt"/>
-<!-- <copy todir="${runLocation}">
- <fileset dir="src_dir" excludes="**/*.java"/>
- </copy> -->
-
- </target>
-
- <target name="zip" depends="jar">
- <delete file="${runLocation}/bundle.zip"/>
- <zip destfile="${runLocation}/bundle.zip"
- basedir="${runLocation}"
- />
- </target>
-
- <target name="run">
- <java classname="org.rhq.enterprise.client.ClientMain">
- <!-- <arg value="-h"/> -->
- <classpath refid="project.class.path">
- <!-- <pathelement refid="project.class.path"/>
- <pathelement path="${java.class.path}"/> -->
-
- </classpath>
- </java>
-
-
- </target>
-
-</project>
diff --git a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat
b/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat
deleted file mode 100644
index 68e8706..0000000
--- a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat
+++ /dev/null
@@ -1,16 +0,0 @@
-rem This script should consume all the wsdls and compile the JAXB types all
-rem into one directory.
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k
http://127.0.0.1:7080/rhq-rhq-server/RoleManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k
http://127.0.0.1:7080/rhq-rhq-server/ContentManagerBean?wsdl -p
org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k
http://127.0.0.1:7080/rhq-rhq-server/SubjectManagerBean?wsdl -p
org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k
http://127.0.0.1:7080/rhq-rhq-server/OperationManagerBean?wsdl -p
org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k
http://127.0.0.1:7080/rhq-rhq-server/RepoManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k
http://127.0.0.1:7080/rhq-rhq-server/ConfigurationManagerBean?wsdl -p
org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k
http://127.0.0.1:7080/rhq-rhq-server/ResourceManagerBean?wsdl -p
org.rhq.enterprise.server.ws
\ No newline at end of file
diff --git a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh
b/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh
deleted file mode 100644
index f83293b..0000000
--- a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-# This script should consume all the wsdls and compile the JAXB types all
-# into one directory.
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k
http://localhost:7080/rhq-rhq-server/RoleManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k
http://localhost:7080/rhq-rhq-server/ContentManagerBean?wsdl -p
org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k
http://localhost:7080/rhq-rhq-server/SubjectManagerBean?wsdl -p
org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k
http://localhost:7080/rhq-rhq-server/OperationManagerBean?wsdl -p
org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k
http://localhost:7080/rhq-rhq-server/RepoManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k
http://localhost:7080/rhq-rhq-server/ConfigurationManagerBean?wsdl -p
org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k
http://localhost:7080/rhq-rhq-server/ResourceManagerBean?wsdl -p
org.rhq.enterprise.server.ws
\ No newline at end of file
diff --git a/modules/enterprise/remoting/cli/src/etc/toRun.txt
b/modules/enterprise/remoting/cli/src/etc/toRun.txt
deleted file mode 100644
index a86a75b..0000000
--- a/modules/enterprise/remoting/cli/src/etc/toRun.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-java -cp getopt-1.0.13.jar:remoting.jar:jline-0.9.94.jar:i18nlog-1.0.9.jar
org.rhq.enterprise.client.ClientMain
-
-java -cp getopt-1.0.13.jar;remoting.jar;jline-0.9.94.jar;i18nlog-1.0.9.jar
org.rhq.enterprise.client.ClientMain
\ No newline at end of file