[rhq] 2 commits - modules/enterprise modules/plugins
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonMetricView.java | 251 ------
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonView.java | 279 ++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonView2.java | 411 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersHealthView.java | 67 -
modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java | 36
5 files changed, 226 insertions(+), 818 deletions(-)
New commits:
commit 92464e194758c39ee5f5123e616b7dce6a13948c
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Nov 22 16:34:27 2013 -0500
Change getAvailability() such that if EMS throws an exception
we don't pass it back to the avail checker. This loads
the logs when JMX components are down. Instead, log the
problem at debug and return DOWN.
diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
index c0be3d4..35b0ccb 100644
--- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
+++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
@@ -95,11 +95,13 @@ public class MBeanResourceComponent<T extends JMXComponent<?>> implements Measur
/**
* @deprecated do not use this - use {@link #getEmsBean()} instead
*/
+ @Deprecated
protected EmsBean bean;
/**
* @deprecated do not use this - use {@link #getResourceContext()} instead
*/
+ @Deprecated
protected ResourceContext<T> resourceContext;
/**
@@ -124,10 +126,10 @@ public class MBeanResourceComponent<T extends JMXComponent<?>> implements Measur
* Gets the loaded MBean. This will attempt to {@link #loadBean() load} the bean if it
* is not yet loaded. This might still return <code>null</code> if the MBean could
* not be loaded.
- *
+ *
* @return the loaded MBean
* @throws IllegalStateException if it could not be loaded
- *
+ *
* @see #loadBean()
*/
public EmsBean getEmsBean() {
@@ -148,7 +150,7 @@ public class MBeanResourceComponent<T extends JMXComponent<?>> implements Measur
/**
* Sets the MBean that this component considers loaded.
- *
+ *
* @param bean the new MBean representing the component resource
*/
protected void setEmsBean(EmsBean bean) {
@@ -167,10 +169,10 @@ public class MBeanResourceComponent<T extends JMXComponent<?>> implements Measur
* Loads the MBean in a default way. This default mechanism is to look in the
* plugin configuration for a key of {@link #OBJECT_NAME_PROP} and uses that
* as the object name to load via {@link #loadBean(String)}.
- *
+ *
* Subclasses are free to override this method in order to provide its own
* default loading mechanism.
- *
+ *
* @return the bean that is loaded
*/
protected EmsBean loadBean() {
@@ -184,7 +186,7 @@ public class MBeanResourceComponent<T extends JMXComponent<?>> implements Measur
* Loads the bean with the given object name.
*
* Subclasses are free to override this method in order to load the bean.
- *
+ *
* @param objectName the name of the bean to load
* @return the bean that is loaded
*/
@@ -216,23 +218,27 @@ public class MBeanResourceComponent<T extends JMXComponent<?>> implements Measur
*/
public AvailabilityType getAvailability() {
try {
- if (isMBeanAvailable()) {
- return AvailabilityType.UP;
- } else {
- return AvailabilityType.DOWN;
- }
+ return isMBeanAvailable() ? AvailabilityType.UP : AvailabilityType.DOWN;
+
} catch (RuntimeException e) {
if (this.bean != null) {
// Retry by connecting to a new parent connection (this bean might have been connected to by an old
// provider that's since been recreated).
this.bean = null;
- if (isMBeanAvailable()) {
- return AvailabilityType.UP;
- } else {
+ try {
+ return isMBeanAvailable() ? AvailabilityType.UP : AvailabilityType.DOWN;
+
+ } catch (RuntimeException e2) {
+ if (log.isDebugEnabled() ) {
+ log.debug("Avail check retry failed, MBean not available", e2);
+ }
return AvailabilityType.DOWN;
}
} else {
- throw e;
+ if (log.isDebugEnabled() ) {
+ log.debug("Avail check failed, MBean not available", e);
+ }
+ return AvailabilityType.DOWN;
}
}
}
commit 35c901b6e74bcafa140eb08a97c0fb62a97b9447
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Nov 22 13:45:22 2013 -0500
[951927] There are useless controls in "Compare Metrics" window
subsequent commit:
- return to a single "Compare Metrics" button that now
invokes the new view, relegating the old portal war view,
and the 1st proposed new view to the trash heap.
- remove the footer on the new view because total rows
does not make sense for the grouped view (and there is no
way currently to tell Table to just keep the footer and
hide "Total Rows".
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonMetricView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonMetricView.java
deleted file mode 100644
index d8361b3..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonMetricView.java
+++ /dev/null
@@ -1,251 +0,0 @@
-package org.rhq.coregui.client.inventory.groups.detail.monitoring.table;
-
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.INVENTORY_STATUS;
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.TYPE_ID;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.types.Autofit;
-import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.HoverCustomizer;
-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.layout.Layout;
-
-import org.rhq.core.domain.criteria.Criteria;
-import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
-import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
-import org.rhq.core.domain.resource.InventoryStatus;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.coregui.client.LinkManager;
-import org.rhq.coregui.client.components.table.IconField;
-import org.rhq.coregui.client.components.table.Table;
-import org.rhq.coregui.client.inventory.groups.detail.monitoring.table.GroupMembersComparisonMetricView.GroupMembersComparisonMetricDataSource;
-import org.rhq.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
-import org.rhq.coregui.client.util.MeasurementUtility;
-import org.rhq.coregui.client.util.RPCDataSource;
-import org.rhq.coregui.client.util.StringUtility;
-
-public class GroupMembersComparisonMetricView extends Table<GroupMembersComparisonMetricDataSource> {
-
- List<MetricDisplaySummary> summaries;
- private GroupMembersComparisonMetricDataSource dataSource;
-
- public GroupMembersComparisonMetricView(List<MetricDisplaySummary> summaries) {
- super(null, true);
-
- this.summaries = summaries;
-
- setAutoHeight();
- setOverflow(Overflow.VISIBLE);
- setShowFilterForm(false);
- setShowHeader(false);
- setShowFooter(false);
-
- setDataSource(getDataSource());
- }
-
- @Override
- public GroupMembersComparisonMetricDataSource getDataSource() {
- if (null == dataSource) {
- dataSource = new GroupMembersComparisonMetricDataSource();
- }
-
- return dataSource;
- }
-
- @Override
- protected void configureTable() {
- ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields();
- getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()]));
-
- super.configureTable();
- }
-
- @Override
- protected void configureTableContents(Layout contents) {
- contents.setWidth100();
- contents.setHeight100();
- contents.setOverflow(Overflow.VISIBLE);
- }
-
- @Override
- protected void configureListGrid(ListGrid grid) {
- grid.setDefaultHeight(1);
- grid.setAutoFitData(Autofit.VERTICAL);
- }
-
- public class GroupMembersComparisonMetricDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
-
- public static final String FIELD_MIN_VALUE = "min";
- public static final String FIELD_MAX_VALUE = "max";
- public static final String FIELD_AVG_VALUE = "avg";
- public static final String FIELD_LAST_VALUE = "last";
-
- public ArrayList<ListGridField> getListGridFields() {
- ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
-
- IconField iconField = new IconField();
- iconField.setShowHover(true);
- iconField.setHoverCustomizer(new HoverCustomizer() {
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
- String resCat = record.getAttribute(CATEGORY.propertyName());
- switch (ResourceCategory.valueOf(resCat)) {
- case PLATFORM:
- return MSG.common_title_platform();
- case SERVER:
- return MSG.common_title_server();
- case SERVICE:
- return MSG.common_title_service();
- }
- return null;
- }
- });
- fields.add(iconField);
-
- ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
- nameField.setCellFormatter(new CellFormatter() {
- public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
- String invStatus = record.getAttribute(INVENTORY_STATUS.propertyName());
- if (InventoryStatus.COMMITTED == InventoryStatus.valueOf(invStatus)) {
- String url = LinkManager.getResourceLink(record.getAttributeAsInt("id"));
- String name = StringUtility.escapeHtml(value.toString());
- return LinkManager.getHref(url, name);
- } else {
- return value.toString();
- }
- }
- });
- nameField.setShowHover(true);
- nameField.setHoverCustomizer(new HoverCustomizer() {
- public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
- }
- });
- fields.add(nameField);
-
- ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
- fields.add(ancestryField);
-
- ListGridField minField = new ListGridField(FIELD_MIN_VALUE, MSG.common_title_monitor_minimum());
- minField.setWidth("15%");
- fields.add(minField);
-
- ListGridField maxField = new ListGridField(FIELD_MAX_VALUE, MSG.common_title_monitor_maximum());
- maxField.setWidth("15%");
- fields.add(maxField);
-
- ListGridField avgField = new ListGridField(FIELD_AVG_VALUE, MSG.common_title_monitor_average());
- avgField.setWidth("15%");
- fields.add(avgField);
-
- ListGridField lastField = new ListGridField(FIELD_LAST_VALUE, MSG.view_resource_monitor_table_last());
- lastField.setWidth("15%");
- fields.add(lastField);
-
- return fields;
- }
-
- @Override
- protected Criteria getFetchCriteria(DSRequest request) {
- return null;
- }
-
- @Override
- protected void executeFetch(DSRequest request, DSResponse response, Criteria criteria) {
- dataRetrieved(summaries, response, request);
- }
-
- protected void dataRetrieved(final List<MetricDisplaySummary> result, final DSResponse response,
- final DSRequest request) {
- HashSet<Integer> typesSet = new HashSet<Integer>();
- HashSet<String> ancestries = new HashSet<String>();
- for (MetricDisplaySummary mds : result) {
- Resource resource = mds.getResource();
- ResourceType type = resource.getResourceType();
- if (type != null) {
- typesSet.add(type.getId());
- }
- ancestries.add(resource.getAncestry());
- }
-
- // In addition to the types of the result resources, get the types of their ancestry
- typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
-
- ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
- typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- // SmartGWT has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
- AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
-
- Record[] records = buildRecords(result);
- for (Record record : records) {
- // replace type id with type name
- Integer typeId = record.getAttributeAsInt(TYPE.propertyName());
- ResourceType type = types.get(typeId);
- if (type != null) {
- record.setAttribute(TYPE.propertyName(), type.getName());
- record.setAttribute(TYPE_ID.propertyName(), type.getId());
- }
-
- // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
- // Store the types map off the records so we can build a detailed hover string as needed.
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
-
- // Build the decoded ancestry Strings now for display
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
- }
- response.setData(records);
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- public ListGridRecord copyValues(MetricDisplaySummary from) {
- ListGridRecord record = new ListGridRecord();
- Resource resource = from.getResource();
-
- record.setAttribute("id", resource.getId());
- record.setAttribute(NAME.propertyName(), resource.getName());
- record.setAttribute(INVENTORY_STATUS.propertyName(), resource.getInventoryStatus());
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
- record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
-
- MeasurementUtility.formatSimpleMetrics(from);
-
- record.setAttribute(FIELD_MIN_VALUE, getMetricStringValue(from.getMinMetric()));
- record.setAttribute(FIELD_MAX_VALUE, getMetricStringValue(from.getMaxMetric()));
- record.setAttribute(FIELD_AVG_VALUE, getMetricStringValue(from.getAvgMetric()));
- record.setAttribute(FIELD_LAST_VALUE, getMetricStringValue(from.getLastMetric()));
-
- return record;
- }
-
- protected String getMetricStringValue(MetricDisplayValue value) {
- return (value != null) ? value.toString() : "";
- }
-
- @Override
- public MetricDisplaySummary copyValues(Record from) {
- return null;
- }
-
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonView.java
index e0ac080..3de72b2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonView.java
@@ -19,9 +19,16 @@
*/
package org.rhq.coregui.client.inventory.groups.detail.monitoring.table;
+import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
+import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.INVENTORY_STATUS;
+import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
+import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
+import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.TYPE_ID;
+
import java.util.ArrayList;
import java.util.Date;
import java.util.EnumSet;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -31,26 +38,33 @@ import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.SortSpecifier;
-import com.smartgwt.client.types.EmbeddedPosition;
-import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.GroupStartOpen;
import com.smartgwt.client.types.SortDirection;
-import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.GroupValueFunction;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
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.CellClickEvent;
-import com.smartgwt.client.widgets.grid.events.CellClickHandler;
+import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.DisplayType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
+import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.ImageManager;
+import org.rhq.coregui.client.LinkManager;
import org.rhq.coregui.client.UserSessionManager;
+import org.rhq.coregui.client.components.table.IconField;
import org.rhq.coregui.client.components.table.Table;
import org.rhq.coregui.client.gwt.GWTServiceLookup;
import org.rhq.coregui.client.inventory.common.detail.summary.AbstractActivityView.ChartViewWindow;
@@ -58,8 +72,12 @@ import org.rhq.coregui.client.inventory.common.graph.ButtonBarDateTimeRangeEdito
import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
import org.rhq.coregui.client.inventory.common.graph.Refreshable;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.table.GroupMembersComparisonView.GroupMembersComparisonDataSource;
+import org.rhq.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
+import org.rhq.coregui.client.util.MeasurementUtility;
import org.rhq.coregui.client.util.RPCDataSource;
+import org.rhq.coregui.client.util.StringUtility;
import org.rhq.coregui.client.util.preferences.MeasurementUserPreferences;
/**
@@ -67,20 +85,19 @@ import org.rhq.coregui.client.util.preferences.MeasurementUserPreferences;
*/
public class GroupMembersComparisonView extends Table<GroupMembersComparisonDataSource> implements Refreshable { //, AutoRefresh {
- private static SortSpecifier DEFAULT_SORT_SPECIFIER = new SortSpecifier(
- GroupMembersComparisonDataSource.FIELD_NAME, SortDirection.ASCENDING);
+ private static SortSpecifier DEFAULT_SORT_SPECIFIER_1 = new SortSpecifier(
+ GroupMembersComparisonDataSource.FIELD_METRIC_NAME, SortDirection.ASCENDING);
+ private static SortSpecifier DEFAULT_SORT_SPECIFIER_2 = new SortSpecifier(NAME.propertyName(),
+ SortDirection.ASCENDING);
protected ButtonBarDateTimeRangeEditor buttonBarDateTimeRangeEditor;
- //protected Timer refreshTimer;
private final ResourceGroupComposite groupComposite;
private final int[] resourceIds;
private final GroupMembersComparisonDataSource dataSource;
- private Map<MeasurementDefinition, List<MetricDisplaySummary>> comparisonData;
-
public GroupMembersComparisonView(ResourceGroupComposite groupComposite, int[] resourceIds) {
- super(null, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER });
+ super(null, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER_1, DEFAULT_SORT_SPECIFIER_2 });
this.groupComposite = groupComposite;
this.resourceIds = resourceIds;
@@ -94,7 +111,7 @@ public class GroupMembersComparisonView extends Table<GroupMembersComparisonData
@Override
public void refreshData() {
- if (isVisible()) { // && !isRefreshing()) {
+ if (isVisible()) {
refreshDateTimeRangeEditor();
refresh();
}
@@ -124,33 +141,10 @@ public class GroupMembersComparisonView extends Table<GroupMembersComparisonData
@Override
protected void configureTable() {
- addTopWidget(buttonBarDateTimeRangeEditor);
- refreshDateTimeRangeEditor();
-
ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields();
-
- //add cell click handler to execute on Table data entries.
- getListGrid().addCellClickHandler(new CellClickHandler() {
- @Override
- public void onCellClick(CellClickEvent event) {
- Record record = event.getRecord();
- Object source = event.getSource();
-
- String title = record.getAttribute(GroupMembersComparisonDataSource.FIELD_NAME);
- ChartViewWindow window = new ChartViewWindow("", title);
- int defId = record.getAttributeAsInt(FIELD_ID);
-
- ResourceGroup group = groupComposite.getResourceGroup();
- boolean isAutogroup = group.getAutoGroupParentResource() != null;
- CompositeGroupD3GraphListView graph = new CompositeGroupD3MultiLineGraph(group.getId(), defId,
- isAutogroup);
- window.addItem(graph);
- graph.populateData();
- window.show();
- }
- });
-
getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()]));
+
+ addTopWidget(buttonBarDateTimeRangeEditor);
}
/**
@@ -161,46 +155,115 @@ public class GroupMembersComparisonView extends Table<GroupMembersComparisonData
public GroupMembersComparisonListGrid() {
super();
- setShowRecordComponents(true);
- setShowRecordComponentsByCell(false);
- setRecordComponentPosition(EmbeddedPosition.EXPAND);
setShowAllRecords(true);
- }
+ setGroupByField(GroupMembersComparisonDataSource.FIELD_METRIC_NAME);
+ setGroupStartOpen(GroupStartOpen.ALL);
+ setCanCollapseGroup(false);
- @Override
- protected Canvas createRecordComponent(ListGridRecord record, Integer colNum) {
- MeasurementDefinition measurementDefinition = (MeasurementDefinition) record
- .getAttributeAsObject(GroupMembersComparisonDataSource.FIELD_OBJECT);
-
- return new GroupMembersComparisonMetricView(comparisonData.get(measurementDefinition));
+ // this grouped view can't display a useful total rows value, so show nothing
+ setShowFooter(false);
}
}
- public class GroupMembersComparisonDataSource extends RPCDataSource<MeasurementDefinition, Criteria> {
+ public class GroupMembersComparisonDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
+ public static final String FIELD_MIN_VALUE = "min";
+ public static final String FIELD_MAX_VALUE = "max";
+ public static final String FIELD_AVG_VALUE = "avg";
+ public static final String FIELD_LAST_VALUE = "last";
+
+ public static final String FIELD_METRIC_NAME = "metricName";
+ public static final String FIELD_ICON = "icon";
+
+ public static final String ATTR_RESOURCE_ID = "resourceId";
+ public static final String ATTR_DEFINITION_ID = "definitionId";
- public static final String FIELD_OBJECT = "object";
- public static final String FIELD_NAME = "name";
private final MeasurementUserPreferences measurementUserPrefs;
public GroupMembersComparisonDataSource() {
measurementUserPrefs = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
}
- /**
- * The view that contains the list grid which will display this datasource's data will call this
- * method to get the field information which is used to control the display of the data.
- *
- * @return list grid fields used to display the datasource data
- */
public ArrayList<ListGridField> getListGridFields() {
- ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);
-
- ListGridField nameField = new ListGridField(FIELD_NAME, MSG.common_title_name());
- nameField.setType(ListGridFieldType.LINK);
- nameField.setTarget("javascript");
- nameField.setWidth("*");
+ ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
+
+ ListGridField metricNameField = new ListGridField(FIELD_METRIC_NAME, MSG.common_title_name());
+ metricNameField.setHidden(true);
+
+ metricNameField.setGroupValueFunction(new GroupValueFunction() {
+ public Object getGroupValue(Object value, ListGridRecord record, ListGridField field, String fieldName,
+ ListGrid grid) {
+ // just create a group for each metric display name
+ return value;
+ }
+ });
+
+ fields.add(metricNameField);
+
+ IconField iconField = new IconField(FIELD_ICON);
+ iconField.setWidth(25);
+
+ // click an icon, win a chart
+ iconField.addRecordClickHandler(new RecordClickHandler() {
+ @Override
+ public void onRecordClick(RecordClickEvent event) {
+ Record record = event.getRecord();
+
+ String title = record.getAttribute(NAME.propertyName());
+ ChartViewWindow window = new ChartViewWindow("", title);
+ int defId = record.getAttributeAsInt(GroupMembersComparisonDataSource.ATTR_DEFINITION_ID);
+
+ ResourceGroup group = groupComposite.getResourceGroup();
+ boolean isAutogroup = group.getAutoGroupParentResource() != null;
+ CompositeGroupD3GraphListView graph = new CompositeGroupD3MultiLineGraph(group.getId(), defId,
+ isAutogroup);
+ window.addItem(graph);
+ graph.populateData();
+ window.show();
+ }
+ });
+
+ fields.add(iconField);
+
+ ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
+ nameField.setCellFormatter(new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String invStatus = record.getAttribute(INVENTORY_STATUS.propertyName());
+ if (InventoryStatus.COMMITTED == InventoryStatus.valueOf(invStatus)) {
+ String url = LinkManager.getResourceLink(record.getAttributeAsInt(ATTR_RESOURCE_ID));
+ String name = StringUtility.escapeHtml(value.toString());
+ return LinkManager.getHref(url, name);
+ } else {
+ return value.toString();
+ }
+ }
+ });
+ nameField.setShowHover(true);
+ nameField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
fields.add(nameField);
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
+ fields.add(ancestryField);
+
+ ListGridField minField = new ListGridField(FIELD_MIN_VALUE, MSG.common_title_monitor_minimum());
+ minField.setWidth("15%");
+ fields.add(minField);
+
+ ListGridField maxField = new ListGridField(FIELD_MAX_VALUE, MSG.common_title_monitor_maximum());
+ maxField.setWidth("15%");
+ fields.add(maxField);
+
+ ListGridField avgField = new ListGridField(FIELD_AVG_VALUE, MSG.common_title_monitor_average());
+ avgField.setWidth("15%");
+ fields.add(avgField);
+
+ ListGridField lastField = new ListGridField(FIELD_LAST_VALUE, MSG.view_resource_monitor_table_last());
+ lastField.setWidth("15%");
+ fields.add(lastField);
+
return fields;
}
@@ -236,10 +299,6 @@ public class GroupMembersComparisonView extends Table<GroupMembersComparisonData
long begin = measurementUserPrefs.getMetricRangePreferences().begin;
long end = measurementUserPrefs.getMetricRangePreferences().end;
- if (null != comparisonData) {
- comparisonData.clear();
- comparisonData = null;
- }
GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForMetricsCompare(
resourceIds, definitionIds, begin, end,
new AsyncCallback<Map<MeasurementDefinition, List<MetricDisplaySummary>>>() {
@@ -249,33 +308,105 @@ public class GroupMembersComparisonView extends Table<GroupMembersComparisonData
}
public void onSuccess(Map<MeasurementDefinition, List<MetricDisplaySummary>> result) {
- comparisonData = result;
- response.setData(buildRecords(result.keySet()));
- processResponse(request.getRequestId(), response);
+ List<MetricDisplaySummary> all = new ArrayList<MetricDisplaySummary>();
+ for (MeasurementDefinition key : result.keySet()) {
+ all.addAll(result.get(key));
+ }
+ dataRetrieved(all, response, request);
}
});
}
});
}
+ protected void dataRetrieved(final List<MetricDisplaySummary> result, final DSResponse response,
+ final DSRequest request) {
+
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (MetricDisplaySummary mds : result) {
+ Resource resource = mds.getResource();
+ ResourceType type = resource.getResourceType();
+ if (type != null) {
+ typesSet.add(type.getId());
+ }
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // SmartGWT has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // replace type id with type name
+ Integer typeId = record.getAttributeAsInt(TYPE.propertyName());
+ ResourceType type = types.get(typeId);
+ if (type != null) {
+ record.setAttribute(TYPE.propertyName(), type.getName());
+ record.setAttribute(TYPE_ID.propertyName(), type.getId());
+ }
+
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
+ }
+ response.setData(records);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
@Override
protected Criteria getFetchCriteria(DSRequest request) {
return null;
}
@Override
- public ListGridRecord copyValues(MeasurementDefinition from) {
+ public ListGridRecord copyValues(MetricDisplaySummary from) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute("object", from);
- record.setAttribute(FIELD_ID, from.getId());
- record.setAttribute(FIELD_NAME, from.getDisplayName());
+ record.setAttribute(FIELD_ID, from.getMetricName() + "_" + from.getResourceId());
+ record.setAttribute(FIELD_METRIC_NAME, from.getLabel());
+
+ Resource resource = from.getResource();
+
+ record.setAttribute(NAME.propertyName(), resource.getName());
+ record.setAttribute(INVENTORY_STATUS.propertyName(), resource.getInventoryStatus());
+ record.setAttribute(CATEGORY.propertyName(), resource.getResourceType().getCategory().name());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+
+ MeasurementUtility.formatSimpleMetrics(from);
+
+ record.setAttribute(FIELD_MIN_VALUE, getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(FIELD_MAX_VALUE, getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(FIELD_AVG_VALUE, getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(FIELD_LAST_VALUE, getMetricStringValue(from.getLastMetric()));
+
+ record.setAttribute(FIELD_ICON, ImageManager.getMonitorIcon());
+
+ record.setAttribute(ATTR_RESOURCE_ID, from.getResourceId());
+ record.setAttribute(ATTR_DEFINITION_ID, from.getDefinitionId());
return record;
}
+ protected String getMetricStringValue(MetricDisplayValue value) {
+ return (value != null) ? value.toString() : "";
+ }
+
@Override
- public MeasurementDefinition copyValues(Record from) {
+ public MetricDisplaySummary copyValues(Record from) {
return null;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonView2.java
deleted file mode 100644
index 06ff2ee..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersComparisonView2.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.coregui.client.inventory.groups.detail.monitoring.table;
-
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.INVENTORY_STATUS;
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
-import static org.rhq.coregui.client.inventory.resource.ResourceDataSourceField.TYPE_ID;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.SortSpecifier;
-import com.smartgwt.client.types.GroupStartOpen;
-import com.smartgwt.client.types.SortDirection;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.GroupValueFunction;
-import com.smartgwt.client.widgets.grid.HoverCustomizer;
-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.RecordClickEvent;
-import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
-
-import org.rhq.core.domain.criteria.Criteria;
-import org.rhq.core.domain.measurement.DataType;
-import org.rhq.core.domain.measurement.DisplayType;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
-import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
-import org.rhq.core.domain.resource.InventoryStatus;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
-import org.rhq.coregui.client.CoreGUI;
-import org.rhq.coregui.client.ImageManager;
-import org.rhq.coregui.client.LinkManager;
-import org.rhq.coregui.client.UserSessionManager;
-import org.rhq.coregui.client.components.table.IconField;
-import org.rhq.coregui.client.components.table.Table;
-import org.rhq.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.coregui.client.inventory.common.detail.summary.AbstractActivityView.ChartViewWindow;
-import org.rhq.coregui.client.inventory.common.graph.ButtonBarDateTimeRangeEditor;
-import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
-import org.rhq.coregui.client.inventory.common.graph.Refreshable;
-import org.rhq.coregui.client.inventory.groups.detail.monitoring.table.GroupMembersComparisonView2.GroupMembersComparisonDataSource;
-import org.rhq.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
-import org.rhq.coregui.client.util.MeasurementUtility;
-import org.rhq.coregui.client.util.RPCDataSource;
-import org.rhq.coregui.client.util.StringUtility;
-import org.rhq.coregui.client.util.preferences.MeasurementUserPreferences;
-
-/**
- * @author Jay Shaughnessy
- */
-public class GroupMembersComparisonView2 extends Table<GroupMembersComparisonDataSource> implements Refreshable { //, AutoRefresh {
-
- private static SortSpecifier DEFAULT_SORT_SPECIFIER_1 = new SortSpecifier(
- GroupMembersComparisonDataSource.FIELD_METRIC_NAME, SortDirection.ASCENDING);
- private static SortSpecifier DEFAULT_SORT_SPECIFIER_2 = new SortSpecifier(NAME.propertyName(),
- SortDirection.ASCENDING);
-
- protected ButtonBarDateTimeRangeEditor buttonBarDateTimeRangeEditor;
-
- private final ResourceGroupComposite groupComposite;
- private final int[] resourceIds;
- private final GroupMembersComparisonDataSource dataSource;
-
- public GroupMembersComparisonView2(ResourceGroupComposite groupComposite, int[] resourceIds) {
- super(null, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER_1, DEFAULT_SORT_SPECIFIER_2 });
-
- this.groupComposite = groupComposite;
- this.resourceIds = resourceIds;
-
- dataSource = new GroupMembersComparisonDataSource();
- setDataSource(dataSource);
- //disable full-screen fields, just use auto refresh
- setShowFooterRefresh(false);
- buttonBarDateTimeRangeEditor = new ButtonBarDateTimeRangeEditor(this);
- }
-
- @Override
- public void refreshData() {
- if (isVisible()) {
- refreshDateTimeRangeEditor();
- refresh();
- }
- }
-
- private void refreshDateTimeRangeEditor() {
- Date now = new Date();
- long timeRange = CustomDateRangeState.getInstance().getTimeRange();
- Date newStartDate = new Date(now.getTime() - timeRange);
- buttonBarDateTimeRangeEditor.showUserFriendlyTimeRange(newStartDate.getTime(), now.getTime());
- }
-
- @Override
- public GroupMembersComparisonDataSource getDataSource() {
- return this.dataSource;
- }
-
- @Override
- protected void configureTableFilters() {
- // currently no table filters
- }
-
- @Override
- protected ListGrid createListGrid() {
- return new GroupMembersComparisonListGrid();
- }
-
- @Override
- protected void configureTable() {
- ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields();
- getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()]));
-
- addTopWidget(buttonBarDateTimeRangeEditor);
- }
-
- /**
- * The list grid with metric per row and embedded component for the selected resources
- */
- private class GroupMembersComparisonListGrid extends ListGrid {
-
- public GroupMembersComparisonListGrid() {
- super();
-
- setShowAllRecords(true);
- setGroupByField(GroupMembersComparisonDataSource.FIELD_METRIC_NAME);
- setGroupStartOpen(GroupStartOpen.ALL);
- setCanCollapseGroup(false);
- }
- }
-
- public class GroupMembersComparisonDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
- public static final String FIELD_MIN_VALUE = "min";
- public static final String FIELD_MAX_VALUE = "max";
- public static final String FIELD_AVG_VALUE = "avg";
- public static final String FIELD_LAST_VALUE = "last";
-
- public static final String FIELD_METRIC_NAME = "metricName";
- public static final String FIELD_ICON = "icon";
-
- public static final String ATTR_RESOURCE_ID = "resourceId";
- public static final String ATTR_DEFINITION_ID = "definitionId";
-
- private final MeasurementUserPreferences measurementUserPrefs;
-
- public GroupMembersComparisonDataSource() {
- measurementUserPrefs = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
- }
-
- public ArrayList<ListGridField> getListGridFields() {
- ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
-
- ListGridField metricNameField = new ListGridField(FIELD_METRIC_NAME, MSG.common_title_name());
- metricNameField.setHidden(true);
-
- metricNameField.setGroupValueFunction(new GroupValueFunction() {
- public Object getGroupValue(Object value, ListGridRecord record, ListGridField field, String fieldName,
- ListGrid grid) {
- // just create a group for each metric display name
- return value;
- }
- });
-
- fields.add(metricNameField);
-
- IconField iconField = new IconField(FIELD_ICON);
- iconField.setWidth(25);
-
- // click an icon, win a chart
- iconField.addRecordClickHandler(new RecordClickHandler() {
- @Override
- public void onRecordClick(RecordClickEvent event) {
- Record record = event.getRecord();
-
- String title = record.getAttribute(NAME.propertyName());
- ChartViewWindow window = new ChartViewWindow("", title);
- int defId = record.getAttributeAsInt(GroupMembersComparisonDataSource.ATTR_DEFINITION_ID);
-
- ResourceGroup group = groupComposite.getResourceGroup();
- boolean isAutogroup = group.getAutoGroupParentResource() != null;
- CompositeGroupD3GraphListView graph = new CompositeGroupD3MultiLineGraph(group.getId(), defId,
- isAutogroup);
- window.addItem(graph);
- graph.populateData();
- window.show();
- }
- });
-
- fields.add(iconField);
-
- ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
- nameField.setCellFormatter(new CellFormatter() {
- public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
- String invStatus = record.getAttribute(INVENTORY_STATUS.propertyName());
- if (InventoryStatus.COMMITTED == InventoryStatus.valueOf(invStatus)) {
- String url = LinkManager.getResourceLink(record.getAttributeAsInt(ATTR_RESOURCE_ID));
- String name = StringUtility.escapeHtml(value.toString());
- return LinkManager.getHref(url, name);
- } else {
- return value.toString();
- }
- }
- });
- nameField.setShowHover(true);
- nameField.setHoverCustomizer(new HoverCustomizer() {
- public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
- }
- });
- fields.add(nameField);
-
- ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
- fields.add(ancestryField);
-
- ListGridField minField = new ListGridField(FIELD_MIN_VALUE, MSG.common_title_monitor_minimum());
- minField.setWidth("15%");
- fields.add(minField);
-
- ListGridField maxField = new ListGridField(FIELD_MAX_VALUE, MSG.common_title_monitor_maximum());
- maxField.setWidth("15%");
- fields.add(maxField);
-
- ListGridField avgField = new ListGridField(FIELD_AVG_VALUE, MSG.common_title_monitor_average());
- avgField.setWidth("15%");
- fields.add(avgField);
-
- ListGridField lastField = new ListGridField(FIELD_LAST_VALUE, MSG.view_resource_monitor_table_last());
- lastField.setWidth("15%");
- fields.add(lastField);
-
- return fields;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
- final ResourceGroup group = groupComposite.getResourceGroup();
- // Load the fully fetched ResourceType.
- ResourceType groupType = group.getResourceType();
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(groupType.getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(ResourceType type) {
- group.setResourceType(type);
- //metric definitions
- Set<MeasurementDefinition> definitions = type.getMetricDefinitions();
- ArrayList<MeasurementDefinition> filteredDefinitions = new ArrayList<MeasurementDefinition>();
-
- // TODO: make this a filter to allow summary or detail
- boolean summaryOnly = false;
-
- for (MeasurementDefinition d : definitions) {
- if (DataType.MEASUREMENT == d.getDataType()
- && (!summaryOnly || (d.getDisplayType() != DisplayType.SUMMARY))) {
- filteredDefinitions.add(d);
- }
- }
-
- int[] definitionIds = new int[filteredDefinitions.size()];
- int i = 0;
- for (MeasurementDefinition d : filteredDefinitions) {
- definitionIds[i++] = d.getId();
- }
-
- long begin = measurementUserPrefs.getMetricRangePreferences().begin;
- long end = measurementUserPrefs.getMetricRangePreferences().end;
- GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForMetricsCompare(
- resourceIds, definitionIds, begin, end,
- new AsyncCallback<Map<MeasurementDefinition, List<MetricDisplaySummary>>>() {
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Cannot load comparison data", caught);
- }
-
- public void onSuccess(Map<MeasurementDefinition, List<MetricDisplaySummary>> result) {
- List<MetricDisplaySummary> all = new ArrayList<MetricDisplaySummary>();
- for (MeasurementDefinition key : result.keySet()) {
- all.addAll(result.get(key));
- }
- dataRetrieved(all, response, request);
- }
- });
- }
- });
- }
-
- protected void dataRetrieved(final List<MetricDisplaySummary> result, final DSResponse response,
- final DSRequest request) {
-
- HashSet<Integer> typesSet = new HashSet<Integer>();
- HashSet<String> ancestries = new HashSet<String>();
- for (MetricDisplaySummary mds : result) {
- Resource resource = mds.getResource();
- ResourceType type = resource.getResourceType();
- if (type != null) {
- typesSet.add(type.getId());
- }
- ancestries.add(resource.getAncestry());
- }
-
- // In addition to the types of the result resources, get the types of their ancestry
- typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
-
- ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
- typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- // SmartGWT has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
- AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
-
- Record[] records = buildRecords(result);
- for (Record record : records) {
- // replace type id with type name
- Integer typeId = record.getAttributeAsInt(TYPE.propertyName());
- ResourceType type = types.get(typeId);
- if (type != null) {
- record.setAttribute(TYPE.propertyName(), type.getName());
- record.setAttribute(TYPE_ID.propertyName(), type.getId());
- }
-
- // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
- // Store the types map off the records so we can build a detailed hover string as needed.
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
-
- // Build the decoded ancestry Strings now for display
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
- }
- response.setData(records);
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- protected Criteria getFetchCriteria(DSRequest request) {
- return null;
- }
-
- @Override
- public ListGridRecord copyValues(MetricDisplaySummary from) {
-
- ListGridRecord record = new ListGridRecord();
- record.setAttribute(FIELD_ID, from.getMetricName() + "_" + from.getResourceId());
- record.setAttribute(FIELD_METRIC_NAME, from.getLabel());
-
- Resource resource = from.getResource();
-
- record.setAttribute(NAME.propertyName(), resource.getName());
- record.setAttribute(INVENTORY_STATUS.propertyName(), resource.getInventoryStatus());
- record.setAttribute(CATEGORY.propertyName(), resource.getResourceType().getCategory().name());
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
- record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
-
- MeasurementUtility.formatSimpleMetrics(from);
-
- record.setAttribute(FIELD_MIN_VALUE, getMetricStringValue(from.getMinMetric()));
- record.setAttribute(FIELD_MAX_VALUE, getMetricStringValue(from.getMaxMetric()));
- record.setAttribute(FIELD_AVG_VALUE, getMetricStringValue(from.getAvgMetric()));
- record.setAttribute(FIELD_LAST_VALUE, getMetricStringValue(from.getLastMetric()));
-
- record.setAttribute(FIELD_ICON, ImageManager.getMonitorIcon());
-
- record.setAttribute(ATTR_RESOURCE_ID, from.getResourceId());
- record.setAttribute(ATTR_DEFINITION_ID, from.getDefinitionId());
-
- return record;
- }
-
- protected String getMetricStringValue(MetricDisplayValue value) {
- return (value != null) ? value.toString() : "";
- }
-
- @Override
- public MetricDisplaySummary copyValues(Record from) {
- return null;
- }
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersHealthView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersHealthView.java
index e3d76cc..0ffa3a2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersHealthView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/table/GroupMembersHealthView.java
@@ -25,7 +25,6 @@ import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
-import org.rhq.coregui.client.components.FullHTMLPane;
import org.rhq.coregui.client.components.table.TableAction;
import org.rhq.coregui.client.inventory.common.detail.summary.AbstractActivityView.ChartViewWindow;
import org.rhq.coregui.client.inventory.groups.detail.inventory.MembersView;
@@ -58,50 +57,12 @@ public class GroupMembersHealthView extends MembersView {
//add extra list grid field for alerts
setListGridFields(fields.toArray(new ListGridField[fields.size()]));
- //add chart selected metric action
addTableAction(MSG.common_title_compareMetrics(), new TableAction() {
@Override
public boolean isEnabled(ListGridRecord[] selection) {
return selection != null && selection.length > 1;
}
- // TODO: REMOVE THIS OLD BUTTON ONCE THE NEW ONE IS VALIDATED !!!
- // - FIX BUTTON NAME BELOW WHEN REMOVING !!!
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- if (selection == null || selection.length == 0) {
- return;
- }
- // keyed on metric name - string[0] is the metric label, [1] is the units
- int[] resourceIds = new int[selection.length];
- int i = 0;
- for (ListGridRecord record : selection) {
- Integer defId = record.getAttributeAsInt(FIELD_ID);
- resourceIds[i++] = defId.intValue();
- }
-
- //build portal.war chart page to iFrame
- String destination = "/portal/resource/common/monitor/Visibility.do?mode=compareMetrics&&groupId="
- + groupComposite.getResourceGroup().getId();
- for (int rId : resourceIds) {
- destination += "&r=" + rId;
- }
- ChartViewWindow window = new ChartViewWindow("", MSG.common_title_compareMetrics());
- //generate and include iframed content
- FullHTMLPane iframe = new FullHTMLPane(destination);
- window.addItem(iframe);
- window.show();
- GroupMembersHealthView.this.refreshTableInfo();
- }
- });
-
- // TODO, fix button name!
- addTableAction(MSG.common_title_compareMetrics() + "- New!", new TableAction() {
- @Override
- public boolean isEnabled(ListGridRecord[] selection) {
- return selection != null && selection.length > 1;
- }
-
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
if (selection == null || selection.length == 0) {
@@ -123,34 +84,6 @@ public class GroupMembersHealthView extends MembersView {
}
});
- // TODO, fix button name!
- addTableAction(MSG.common_title_compareMetrics() + "- Newest!", new TableAction() {
- @Override
- public boolean isEnabled(ListGridRecord[] selection) {
- return selection != null && selection.length > 1;
- }
-
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- if (selection == null || selection.length == 0) {
- return;
- }
- // keyed on metric name - string[0] is the metric label, [1] is the units
- int[] resourceIds = new int[selection.length];
- int i = 0;
- for (ListGridRecord record : selection) {
- Integer defId = record.getAttributeAsInt(FIELD_ID);
- resourceIds[i++] = defId.intValue();
- }
-
- ChartViewWindow window = new ChartViewWindow("", MSG.common_title_compareMetrics());
- GroupMembersComparisonView2 view = new GroupMembersComparisonView2(groupComposite, resourceIds);
- window.addItem(view);
- window.show();
- GroupMembersHealthView.this.refreshTableInfo();
- }
- });
-
}
public boolean isCanModifyMembers() {
10 years, 6 months
[rhq] Branch 'release/jon3.2.x' - modules/enterprise
by mazz
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java | 17 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java | 44 +++++-----
2 files changed, 35 insertions(+), 26 deletions(-)
New commits:
commit 892b278064e03d2b22ea05f4c68275b1d47435d7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 22 14:37:39 2013 -0500
Test code work for OperationManagerBeanTest
- This change mainy affects test code involving operation execution but
is actually a tweak to overlord session handling in general. Ensure that
when operations execute as overlord they use the shared overlord session.
Furthermore, don't let the shared overlord session be invalidated by a call
to logout, only by session expiration.
(cherry picked from commit 5c7499fd0e887f0608ca8e53b8abd7922d9ded85 as part of the work for BZ 1029095)
Conflicts:
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
index de5c625..f36fd57 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
@@ -33,20 +33,20 @@ import org.rhq.enterprise.server.util.LookupUtil;
* purpose is to provide session IDs to logged in {@link Subject}s. It will timeout those sessions regardless of any
* container-provided session-timeout mechanism.
* <p>
- * Because this is a very security-sensitive class, any public method requires the caller to
+ * Because this is a very security-sensitive class, any public method requires the caller to
* have the {@link AllowEjbAccessPermission} as any other calls to the EJB layer. This is so that the
* malicious users can't trick the EJB layer into thinking that some users are logged in or log out other
* users.
* <p>
* Also, for security reasons, this class is final so that malicious code can't subclass it and modify its
* behavior.
- *
+ *
* <p>This object is a {@link #getInstance() singleton}.</p>
*/
public final class SessionManager {
-
+
private static final AllowRhqServerInternalsAccessPermission ACCESS_PERMISSION = new AllowRhqServerInternalsAccessPermission();
-
+
/**
* Our source for random session IDs.
*/
@@ -90,7 +90,7 @@ public final class SessionManager {
/**
* Return the singleton object.
- *
+ *
* @return the {@link SessionManager}
*/
public static SessionManager getInstance() {
@@ -305,9 +305,10 @@ public final class SessionManager {
return copy;
}
-
+
private static void checkPermission() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(ACCESS_PERMISSION);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
index 194a5f9..97d91ca 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
@@ -302,7 +302,7 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
* @see org.rhq.enterprise.server.auth.SubjectManagerRemote#getSubjectByName(String)
*/
public Subject getSubjectByName(String username) {
- //TODO: this method needs to be modified to require a Subject and probably MANAGE_SECURITY
+ //TODO: this method needs to be modified to require a Subject and probably MANAGE_SECURITY
// permissions to defend against unrestricted access to subjects.
SubjectCriteria c = new SubjectCriteria();
@@ -430,11 +430,11 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
/**This method is applied to Subject instances that may require LDAP auth/authz processing.
* Called from both SLSB and SubjectGWTServiceImpl and:
* -if Subject passed in has Principal(not LDAP account) then we immediately return Subject as no processing needed.
- * -if Subject for LDAP account
- *
+ * -if Subject for LDAP account
+ *
* @param subject Authenticated subject.
* @return same or new Subject returned from LDAP processing.
- * @throws LoginException
+ * @throws LoginException
*/
public Subject processSubjectForLdap(Subject subject, String subjectPassword) throws LoginException {
if (subject != null) {//null check
@@ -481,7 +481,7 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
// We've verified that this user has valid session, and is using ldap. Safe to elevate search here.
PageList<Subject> subjectsLocated = findSubjectsByCriteria(getOverlord(), subjectCriteria);
//if subject variants located then take the first one with a principal otherwise do nothing
- //To defend against the case where they create an account with the same name but not
+ //To defend against the case where they create an account with the same name but not
//case as an rhq sysadmin or higher perms, then make them relogin with same creds entered.
if ((!subjectsLocated.isEmpty())
&& (!subjectsLocated.get(0).getName().equals(subject.getName()))) {//then case insensitive username matches found. Try to use instead.
@@ -530,7 +530,7 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
+ "] with LDAP groups [" + groupNames + "]...");
ldapManager.assignRolesToLdapSubject(subject.getId(), groupNames);
}
- } else {//ldap not configured. Somehow authenticated for LDAP without ldap being configured. Error. Bail
+ } else {//ldap not configured. Somehow authenticated for LDAP without ldap being configured. Error. Bail
throw new LoginException("You are authenticated for LDAP, but LDAP is not configured.");
}
}
@@ -543,7 +543,7 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
*/
public void logout(Subject subject) {
try {
- // make sure the Subject is valid by pairing the name and sessionId
+ // make sure the Subject is valid by pairing the name and sessionId
Subject s = getSubjectByNameAndSessionId(subject.getName(), subject.getSessionId());
sessionManager.invalidate(s.getSessionId());
} catch (Exception e) {
@@ -640,6 +640,12 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
*/
public Subject loginUnauthenticated(String username) throws LoginException {
+ // we currently use a shared session for overlord. ensure we use the shared session if the overlord user is
+ // requested.
+ if ("admin".equals(username)) {
+ return getOverlord();
+ }
+
Subject subject = getSubjectByName(username);
if (subject == null) {
@@ -650,7 +656,7 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
throw new LoginException("User account has been disabled. [" + username + "]");
}
- // make sure we return the Subject returned from this call, which may differ from the one passed in
+ // make sure we return the Subject returned from this call, which may differ from the one passed in
subject = sessionManager.put(subject, 1000L * 60 * 2); // 2mins only
return subject;
}
@@ -699,7 +705,8 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
if (log.isDebugEnabled()) {
log.error("Error deleting owned group " + Arrays.toString(ownedGroupIds), t);
} else {
- log.error("Error deleting owned group " + Arrays.toString(ownedGroupIds) + ": " + t.getMessage());
+ log.error("Error deleting owned group " + Arrays.toString(ownedGroupIds) + ": "
+ + t.getMessage());
}
}
}
@@ -708,7 +715,8 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
SavedSearchCriteria savedSearchCriteria = new SavedSearchCriteria();
savedSearchCriteria.addFilterSubjectId(doomedSubjectId);
savedSearchCriteria.clearPaging();
- PageList<SavedSearch> savedSearches = savedSearchManager.findSavedSearchesByCriteria(subject, savedSearchCriteria);
+ PageList<SavedSearch> savedSearches = savedSearchManager.findSavedSearchesByCriteria(subject,
+ savedSearchCriteria);
for (SavedSearch savedSearch : savedSearches) {
savedSearchManager.deleteSavedSearch(subject, savedSearch.getId());
}
@@ -863,23 +871,23 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
// http://www.openldap.org/devel/gitweb.cgi?p=openldap.git;a=blob;f=servers/...
Map<String, String> ldapUserAttributes = ldapManager.findLdapUserDetails(subject.getName());
- String givenName = (ldapUserAttributes.get("givenName") != null) ?
- ldapUserAttributes.get("givenName") : ldapUserAttributes.get("gn");
+ String givenName = (ldapUserAttributes.get("givenName") != null) ? ldapUserAttributes.get("givenName")
+ : ldapUserAttributes.get("gn");
subject.setFirstName(givenName);
- String surname = (ldapUserAttributes.get("sn") != null) ?
- ldapUserAttributes.get("sn") : ldapUserAttributes.get("surname");
+ String surname = (ldapUserAttributes.get("sn") != null) ? ldapUserAttributes.get("sn") : ldapUserAttributes
+ .get("surname");
subject.setLastName(surname);
String telephoneNumber = ldapUserAttributes.get("telephoneNumber");
subject.setPhoneNumber(telephoneNumber);
- String mail = (ldapUserAttributes.get("mail") != null) ?
- ldapUserAttributes.get("mail") : ldapUserAttributes.get("rfc822Mailbox");
+ String mail = (ldapUserAttributes.get("mail") != null) ? ldapUserAttributes.get("mail") : ldapUserAttributes
+ .get("rfc822Mailbox");
subject.setEmailAddress(mail);
- String organizationalUnit = (ldapUserAttributes.get("ou") != null) ?
- ldapUserAttributes.get("ou") : ldapUserAttributes.get("organizationalUnitName");
+ String organizationalUnit = (ldapUserAttributes.get("ou") != null) ? ldapUserAttributes.get("ou")
+ : ldapUserAttributes.get("organizationalUnitName");
subject.setDepartment(organizationalUnit);
return;
10 years, 6 months
[rhq] Branch 'release/jon3.2.x' - modules/enterprise
by mazz
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java | 17 ++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
New commits:
commit 13e8b144a59eb585ad168634654cb072eee280a7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 22 12:38:32 2013 -0500
BZ 1029095 - don't invalidate any session that is overlord
(cherry picked from commit c9b36a8f543968c2a172e1e79322f525e27253cc)
Conflicts:
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
index 07da23e..de5c625 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
@@ -188,7 +188,20 @@ public final class SessionManager {
*/
public synchronized void invalidate(int sessionId) {
checkPermission();
- _cache.remove(new Integer(sessionId));
+
+ Integer sessionIdObj = new Integer(sessionId);
+
+ // we currently use a shared session for overlord. don't log it out as it could affect another caller's use
+ // of the overlord user. The session will expire if unused by any caller for the overlord timeout period.
+ AuthSession session = _cache.get(sessionIdObj);
+ if (session != null) {
+ Subject doomedSubject = session.getSubject(false);
+ if (doomedSubject.getId() == OVERLORD_SUBJECT_ID) {
+ return;
+ }
+ }
+
+ _cache.remove(sessionIdObj);
// while we are here, let's go through the entire session cache and remove expired sessions
purgeTimedOutSessions();
@@ -297,4 +310,4 @@ public final class SessionManager {
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
}
-}
\ No newline at end of file
+}
10 years, 6 months
[rhq] 3 commits - modules/core modules/enterprise
by mazz
modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java | 7 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java | 14 +++++--
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java | 18 ++++++++++
3 files changed, 35 insertions(+), 4 deletions(-)
New commits:
commit 32f0b9caab102c598f58df781cac474c52bed79b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 22 12:27:02 2013 -0500
BZ 1029095 - synchronize getOverlord to hopefully restrict the number of overlord sessions created
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
index c50d5ca..9a95500 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
@@ -256,7 +256,7 @@ public final class SessionManager {
return session.getLastAccess();
}
- public Subject getOverlord() {
+ public synchronized Subject getOverlord() {
checkPermission();
if (overlordSubject == null) {
overlordSubject = LookupUtil.getSubjectManager().getSubjectById(OVERLORD_SUBJECT_ID);
commit c9b36a8f543968c2a172e1e79322f525e27253cc
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 22 12:26:30 2013 -0500
BZ 1029095 - don't invalidate any session that is overlord
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
index d6b5177..c50d5ca 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java
@@ -189,13 +189,19 @@ public final class SessionManager {
public synchronized void invalidate(int sessionId) {
checkPermission();
+ Integer sessionIdObj = new Integer(sessionId);
+
// we currently use a shared session for overlord. don't log it out as it could affect another caller's use
// of the overlord user. The session will expire if unused by any caller for the overlord timeout period.
- if (overlordSubject != null && (overlordSubject.getSessionId() == sessionId)) {
- return;
+ AuthSession session = _cache.get(sessionIdObj);
+ if (session != null) {
+ Subject doomedSubject = session.getSubject(false);
+ if (doomedSubject.getId() == OVERLORD_SUBJECT_ID) {
+ return;
+ }
}
- _cache.remove(new Integer(sessionId));
+ _cache.remove(sessionIdObj);
// while we are here, let's go through the entire session cache and remove expired sessions
purgeTimedOutSessions();
commit 3c816b28513a6cd1b5bd7c45bc32ca456ca91055
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 22 12:24:08 2013 -0500
BZ 1033667 - make sure we set the execute bit on the appropriate agent files if we needed to copy the agent across partitions
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java b/modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java
index 6788e7c..e047e97 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java
@@ -131,6 +131,13 @@ public class FileUtil {
BufferedInputStream is = new BufferedInputStream(new FileInputStream(inFile));
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(outFile));
StreamUtil.copy(is, os);
+
+ // TODO do we care to restore execute bit? For coping large number of files via copyDirectory, will this make things slow?
+ // if (inFile.canExecute()) {
+ // outFile.setExecutable(true);
+ // }
+ // TODO do we care to restore the last mod time on the destination file?
+ //outFile.setLastModified(inFile.lastModified());
}
public static void copyDirectory(File inDir, File outDir) throws IOException {
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java
index 5c9d1c2..5a762cd 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java
@@ -45,6 +45,7 @@ import org.rhq.core.util.PropertiesFileUpdate;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.file.FileReverter;
import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.file.FileVisitor;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.server.control.ControlCommand;
import org.rhq.server.control.RHQControlException;
@@ -659,6 +660,23 @@ public class Upgrade extends AbstractInstall {
FileUtil.purge(agentBasedir, true); // clear the way for the new upgraded agent
if (!oldAgentDir.renameTo(agentBasedir)) {
FileUtil.copyDirectory(oldAgentDir, agentBasedir);
+
+ // we need to retain the execute bits for the executable scripts and libraries
+ FileVisitor visitor = new FileVisitor() {
+ @Override
+ public void visit(File file) {
+ String filename = file.getName();
+ if (filename.contains(".so") || filename.contains(".sl")
+ || filename.contains(".dylib")) {
+ file.setExecutable(true);
+ } else if (filename.endsWith(".sh")) {
+ file.setExecutable(true);
+ }
+ }
+ };
+
+ FileUtil.forEachFile(new File(agentBasedir, "bin"), visitor);
+ FileUtil.forEachFile(new File(agentBasedir, "lib"), visitor);
}
}
10 years, 6 months
[rhq] Changes to 'bug/949065'
by Thomas Segismont
New branch 'bug/949065' available with the following commits:
commit e8be3e6b2e72532dabb4048835149964a0366268
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Nov 21 15:45:20 2013 +0100
Bug 991149 - Refactor Plugin Container Services initialization
10 years, 6 months
[rhq] Branch 'bug/949065' - modules/core
by Thomas Segismont
modules/core/plugin-container/pom.xml | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java | 3
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 93 +++++-----
modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java | 21 +-
4 files changed, 67 insertions(+), 52 deletions(-)
New commits:
commit 40ea9b375ee454f1b006703466a3b641d01e23cc
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Fri Nov 22 15:47:42 2013 +0100
Fix test failures
diff --git a/modules/core/plugin-container/pom.xml b/modules/core/plugin-container/pom.xml
index af1533f..f2e6732 100644
--- a/modules/core/plugin-container/pom.xml
+++ b/modules/core/plugin-container/pom.xml
@@ -331,7 +331,7 @@
<rhq.version>${project.version}</rhq.version>
</systemPropertyVariables>
- <excludedGroups>arquillian</excludedGroups>
+ <excludedGroups>arquillian,${rhq.testng.excludedGroups}</excludedGroups>
<!-- need to point the library path to the location of the native libraries -->
<argLine>${jacoco.unit-test.args} -Dorg.hyperic.sigar.path=${project.build.directory}/jboss-sigar</argLine>
<!--
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
index 3f646b2..1705504 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
@@ -703,6 +703,9 @@ public class PluginContainer {
* @return true if the executor service terminated, or false if it is still shutting down
*/
public static boolean shutdownExecutorService(ExecutorService executorService, boolean now) {
+ if (executorService == null) {
+ throw new NullPointerException("executorService is null");
+ }
return getInstance().shutdownExecutorService0(executorService, now);
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index b0c1736..e815501 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -50,6 +50,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
import org.rhq.core.clientapi.agent.discovery.DiscoveryAgentService;
@@ -169,8 +170,8 @@ public class InventoryManager extends AgentService implements ContainerService,
private final PluginContainerConfiguration configuration;
- private final ScheduledThreadPoolExecutor inventoryThreadPoolExecutor;
- private final ScheduledThreadPoolExecutor availabilityThreadPoolExecutor;
+ private ScheduledThreadPoolExecutor inventoryThreadPoolExecutor;
+ private ScheduledThreadPoolExecutor availabilityThreadPoolExecutor;
// The executors are Callable
private final AutoDiscoveryExecutor serverScanExecutor;
@@ -234,30 +235,16 @@ public class InventoryManager extends AgentService implements ContainerService,
super(DiscoveryAgentService.class, streamRemoter);
this.configuration = configuration;
if (pluginManager == null)
- throw new NullPointerException("pluginManager");
+ throw new NullPointerException("pluginManager is null");
this.pluginManager = pluginManager;
this.pluginFactory = new PluginComponentFactory(this, pluginManager);
this.eventManager = eventManager;
- this.serviceScanExecutor = new RuntimeDiscoveryExecutor(this, configuration);
- this.serverScanExecutor = new AutoDiscoveryExecutor(null, this);
-
- this.discoveryComponentProxyFactory = new DiscoveryComponentProxyFactory(pluginFactory);
-
- this.agent = new Agent(this.configuration.getContainerName(), null, 0, null, null);
-
- //make sure the avail collectors are available before we instantiate any
- //resource context - either from disk or from anywhere else.
- availabilityCollectors = new AvailabilityCollectorThreadPool();
- availabilityCollectors.initialize();
-
- // Never run more than one avail check at a time.
- availabilityThreadPoolExecutor = new ScheduledThreadPoolExecutor(AVAIL_THREAD_POOL_CORE_POOL_SIZE,
- new LoggingThreadFactory(AVAIL_THREAD_POOL_NAME, true));
availabilityExecutor = new AvailabilityExecutor(this);
-
- // Never run more than one discovery scan at a time (service and service scans share the same pool).
- inventoryThreadPoolExecutor = new ScheduledThreadPoolExecutor(1, new LoggingThreadFactory(
- INVENTORY_THREAD_POOL_NAME, true));
+ serviceScanExecutor = new RuntimeDiscoveryExecutor(this, configuration);
+ serverScanExecutor = new AutoDiscoveryExecutor(null, this);
+ discoveryComponentProxyFactory = new DiscoveryComponentProxyFactory(pluginFactory);
+ agent = new Agent(this.configuration.getContainerName(), null, 0, null, null);
+ availabilityCollectors = new AvailabilityCollectorThreadPool();
}
/**
@@ -271,40 +258,60 @@ public class InventoryManager extends AgentService implements ContainerService,
* InventoryManager calls PluginComponentFactory which then calls ClassLoaderManager to load classes.
*/
public void initialize() {
- log.info("Initializing Inventory Manager...");
+ inventoryLock.writeLock().lock();
- if (configuration.isInsideAgent()) {
- loadFromDisk();
- }
+ try {
+ log.info("Initializing Inventory Manager...");
+
+ discoveryComponentProxyFactory.initialize();
+
+ //make sure the avail collectors are available before we instantiate any
+ //resource context - either from disk or from anywhere else.
+ availabilityCollectors.initialize();
- // Discover the platform first thing.
- executePlatformScan();
+ if (configuration.isInsideAgent()) {
+ loadFromDisk();
+ }
+
+ // Discover the platform first thing.
+ executePlatformScan();
- // Initialize measurement manager
- measurementManager = new MeasurementManager(configuration, getStreamRemoter(), this);
+ // Initialize measurement manager
+ measurementManager = new MeasurementManager(configuration, getStreamRemoter(), this);
- //try the resource upgrade before we have any schedulers set up
- //so that we don't get any interventions from concurrently running
- //discoveries.
- activateAndUpgradeResources();
+ //try the resource upgrade before we have any schedulers set up
+ //so that we don't get any interventions from concurrently running
+ //discoveries.
+ activateAndUpgradeResources();
- // Only schedule periodic discovery scans and avail checks if we are running inside the RHQ Agent (versus
- // inside EmbJopr).
- if (configuration.isInsideAgent()) {
- // After an initial delay (5s by default), periodically run an availability check (every 1m by default).
- availabilityThreadPoolExecutor.scheduleWithFixedDelay(availabilityExecutor,
+ // Never run more than one avail check at a time.
+ availabilityThreadPoolExecutor = new ScheduledThreadPoolExecutor(AVAIL_THREAD_POOL_CORE_POOL_SIZE,
+ new LoggingThreadFactory(AVAIL_THREAD_POOL_NAME, true));
+
+ // Never run more than one discovery scan at a time (service and service scans share the same pool).
+ inventoryThreadPoolExecutor = new ScheduledThreadPoolExecutor(1, new LoggingThreadFactory(
+ INVENTORY_THREAD_POOL_NAME, true));
+
+ // Only schedule periodic discovery scans and avail checks if we are running inside the RHQ Agent (versus
+ // inside EmbJopr).
+ if (configuration.isInsideAgent()) {
+ // After an initial delay (5s by default), periodically run an availability check (every 1m by default).
+ availabilityThreadPoolExecutor.scheduleWithFixedDelay(availabilityExecutor,
configuration.getAvailabilityScanInitialDelay(), configuration.getAvailabilityScanPeriod(),
TimeUnit.SECONDS);
- // After an initial delay (10s by default), periodically run a server discovery scan (every 15m by default).
- inventoryThreadPoolExecutor.scheduleWithFixedDelay(serverScanExecutor,
+ // After an initial delay (10s by default), periodically run a server discovery scan (every 15m by default).
+ inventoryThreadPoolExecutor.scheduleWithFixedDelay(serverScanExecutor,
configuration.getServerDiscoveryInitialDelay(), configuration.getServerDiscoveryPeriod(),
TimeUnit.SECONDS);
- // After an initial delay (20s by default), periodically run a service discovery scan (every 1d by default).
- inventoryThreadPoolExecutor.scheduleWithFixedDelay(serviceScanExecutor,
+ // After an initial delay (20s by default), periodically run a service discovery scan (every 1d by default).
+ inventoryThreadPoolExecutor.scheduleWithFixedDelay(serviceScanExecutor,
configuration.getServiceDiscoveryInitialDelay(), configuration.getServiceDiscoveryPeriod(),
TimeUnit.SECONDS);
+ }
+ } finally {
+ inventoryLock.writeLock().unlock();
}
log.info("Inventory Manager initialized.");
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java
index 000dc1e..f0f3d3b 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/DiscoveryComponentProxyFactory.java
@@ -64,15 +64,9 @@ public class DiscoveryComponentProxyFactory {
private final Log log = LogFactory.getLog(DiscoveryComponentProxyFactory.class);
private static final String DAEMON_THREAD_POOL_NAME = "ResourceDiscoveryComponent.invoker.daemon";
- private final ExecutorService daemonThreadPool;
+ private ExecutorService daemonThreadPool = null;
private final Set<ResourceType> blacklist = new HashSet<ResourceType>();
private final PluginComponentFactory pluginComponentFactory;
-
- public DiscoveryComponentProxyFactory(PluginComponentFactory pluginComponentFactory) {
- this.pluginComponentFactory = pluginComponentFactory;
- LoggingThreadFactory daemonFactory = new LoggingThreadFactory(DAEMON_THREAD_POOL_NAME, true);
- daemonThreadPool = Executors.newCachedThreadPool(daemonFactory);
- }
private static boolean blacklistDisable;
static {
try {
@@ -82,6 +76,9 @@ public class DiscoveryComponentProxyFactory {
} // always catch here, always let the class load, use a default if the sysprop is invalid
}
+ public DiscoveryComponentProxyFactory(PluginComponentFactory pluginComponentFactory) {
+ this.pluginComponentFactory = pluginComponentFactory;
+ }
/**
* Same as {@link #getDiscoveryComponentProxy(org.rhq.core.domain.resource.ResourceType, org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent, long, org.rhq.core.pc.inventory.ResourceContainer)} except
@@ -141,8 +138,16 @@ public class DiscoveryComponentProxyFactory {
parentResourceContainer);
}
+ public void initialize() {
+ LoggingThreadFactory daemonFactory = new LoggingThreadFactory(DAEMON_THREAD_POOL_NAME, true);
+ daemonThreadPool = Executors.newCachedThreadPool(daemonFactory);
+ }
+
public void shutdown() {
- PluginContainer.shutdownExecutorService(daemonThreadPool, true);
+ if (daemonThreadPool != null) {
+ PluginContainer.shutdownExecutorService(daemonThreadPool, true);
+ daemonThreadPool = null;
+ }
}
public HashSet<ResourceType> getResourceTypeBlacklist() {
10 years, 6 months
[rhq] modules/plugins
by Simeon Pinder
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit bad2a251c907b54b79f730e6841470db95adc257
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Nov 21 14:17:21 2013 -0500
Revert " [BZ 997669] addition to changes to i)better filter attribute list for templated components"
This reverts commit 99a8510f6a1fc0e373c00596b5fd3872433dab7c.
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 1d1b983..26bc08f 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -854,7 +854,7 @@
<!ENTITY sharedThreadPoolResourceConfig '
<c:simple-property name="allow-core-timeout" required="false" type="boolean" readOnly="false" defaultValue="false" displayName="Allow Core Timeout" description="Whether core threads may time out. The default value is false."/>
- <c:simple-property name="core-threads:expr" required="true" defaultValue="0" type="integer" readOnly="false" displayName="Core Threads" description="The core thread pool size which is smaller than the maximum pool size. If undefined, the core thread pool size is the same as the maximum thread pool size."/>
+ <c:simple-property name="core-threads:expr" required="false" type="integer" readOnly="false" displayName="Core Threads" description="The core thread pool size which is smaller than the maximum pool size. If undefined, the core thread pool size is the same as the maximum thread pool size."/>
<c:simple-property name="handoff-executor" displayName="Handoff Executor" required="false" type="string" readOnly="false" description="An executor to delegate tasks to in the event that a task cannot be accepted. If not specified, tasks that cannot be accepted will be silently discarded."/>
'>
10 years, 6 months