modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java | 22 ++
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionCategory.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/alert/composite/AlertConditionDriftCategoryComposite.java | 40 ++++
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 87 ++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 31 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java | 41 ++--
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 7
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java | 37 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerBean.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerLocal.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AgentConditionCache.java | 59 +++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheCoordinator.java | 44 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheUtils.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java | 25 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitorMBean.java | 10 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/model/AbstractCacheElement.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/model/DriftCacheElement.java | 45 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java | 26 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 34 +--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java | 23 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftChangeSetSummary.java | 93 ++++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java | 11 +
modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java | 27 ++
modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/JPADriftServerPluginComponent.java | 9
modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml | 6
33 files changed, 628 insertions(+), 105 deletions(-)
New commits:
commit 3d607576bbaf20c0aa3e5a292cf895b7561e18e7
Merge: 6aa3c58 5d4fbbe
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Aug 31 13:22:29 2011 -0400
Merge commit 'origin/master' into drift-alert
commit 6aa3c583f37107dedf6d75a30dd4e62c1dd4b148
Merge: 89731c7 044113e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Aug 30 22:43:33 2011 -0400
Merge commit 'origin/master' into drift-alert
Conflicts:
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
diff --cc modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 738d69f,898a4c2..27ec698
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@@ -59,7 -54,9 +61,8 @@@ import org.rhq.core.domain.drift.DriftC
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftConfigurationComparator;
-import org.rhq.core.domain.drift.DriftConfigurationComparator.CompareMode;
import org.rhq.core.domain.drift.DriftConfigurationDefinition;
+ import org.rhq.core.domain.drift.DriftDetails;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftSnapshot;
import org.rhq.core.domain.drift.FileDiffReport;
commit 89731c7d830f3b9293b8307002e4ae015d17406b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Aug 30 22:40:51 2011 -0400
start of drift alerting support.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
index 355c854..00a409b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
@@ -242,6 +242,21 @@ import org.rhq.core.domain.operation.OperationRequestStatus;
+ " AND ad.deleted = FALSE " //
+ " AND ac.category = 'RESOURCE_CONFIG' " //
+ "ORDER BY ac.id"), //
+ @NamedQuery(name = AlertCondition.QUERY_BY_CATEGORY_DRIFT, query = "" //
+ + " SELECT new org.rhq.core.domain.alert.composite.AlertConditionDriftCategoryComposite " //
+ + " ( " //
+ + " ac, " //
+ + " res.id " //
+ + " ) " //
+ + " FROM AlertCondition AS ac " //
+ + " JOIN ac.alertDefinition ad " //
+ + " JOIN ad.resource res " //
+ + " WHERE " + AlertCondition.RECOVERY_CONDITIONAL_EXPRESSION //
+ + " AND ( res.agent.id = :agentId OR :agentId IS NULL ) " //
+ + " AND ad.enabled = TRUE " //
+ + " AND ad.deleted = FALSE " //
+ + " AND ac.category = 'DRIFT' " //
+ + "ORDER BY ac.id"), //
@NamedQuery(name = AlertCondition.QUERY_BY_CATEGORY_COUNT_PARAMETERIZED, query = "" //
+ " SELECT count(ac.id) " //
+ " FROM AlertCondition AS ac " //
@@ -273,6 +288,7 @@ public class AlertCondition implements Serializable {
public static final String QUERY_BY_CATEGORY_THRESHOLD = "AlertCondition.byCategoryThreshold";
public static final String QUERY_BY_CATEGORY_EVENT = "AlertCondition.byCategoryEvent";
public static final String QUERY_BY_CATEGORY_RESOURCE_CONFIG = "AlertCondition.byCategoryResourceConfig";
+ public static final String QUERY_BY_CATEGORY_DRIFT = "AlertCondition.byCategoryDrift";
public static final String QUERY_BY_CATEGORY_COUNT_BASELINE = "AlertCondition.byCategoryCountBaseline";
public static final String QUERY_BY_CATEGORY_COUNT_PARAMETERIZED = "AlertCondition.byCategoryCountParameterized";
@@ -395,6 +411,8 @@ public class AlertCondition implements Serializable {
* TRAIT: the name of the trait (TODO: today its the display name, very bad for i18n purposes)
* CONTROL: the name of the operation (not its display name)
* EVENT: the level of event to compare with (DEBUG, INFO, WARN, ERROR, FATAL)
+ * RESOURCE_CONFIG: n/a (null)
+ * DRIFT: n/a (null)
*
* @return additional information about the condition
*/
@@ -450,7 +468,9 @@ public class AlertCondition implements Serializable {
* TRAIT: n/a
* CONTROL: the {@link OperationRequestStatus} name (SUCCESS, FAILURE, etc).
* EVENT: the regular expression of the message to match (which may be empty string if not specified)
- *
+ * RESOURCE_CONFIG: n/a
+ * DRIFT: n/a (TODO driftalert - regular expression to match files whose content drifted (may be empty string if not specified)
+ *
* @return additional information about the condition
*/
public String getOption() {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionCategory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionCategory.java
index 531857b..e80c221 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionCategory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionCategory.java
@@ -31,7 +31,8 @@ public enum AlertConditionCategory {
CONTROL("Control Action"), //
ALERT("Alert Fired"), //
RESOURCE_CONFIG("Resource Configuration Property Value Change"), //
- EVENT("Log Event");
+ EVENT("Log Event"), //
+ DRIFT("Drift Detected");
/*
* legacyOrder exists to support code that still uses the old EventConstants.TYPE_* attributes, which was one-based
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/composite/AlertConditionDriftCategoryComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/composite/AlertConditionDriftCategoryComposite.java
new file mode 100644
index 0000000..7b56a4c
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/composite/AlertConditionDriftCategoryComposite.java
@@ -0,0 +1,40 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * 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 and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.alert.composite;
+
+import org.rhq.core.domain.alert.AlertCondition;
+
+public class AlertConditionDriftCategoryComposite extends AbstractAlertConditionCategoryComposite {
+
+ private final Integer resourceId;
+
+ public AlertConditionDriftCategoryComposite(AlertCondition condition, Integer resourceId) {
+ super(condition);
+ this.resourceId = resourceId;
+ }
+
+ public Integer getResourceId() {
+ return resourceId;
+ }
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
index 777d2fb..6fcdcc5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
@@ -834,6 +834,9 @@ public class ResourceType implements Serializable, Comparable<ResourceType> {
}
public void addDriftConfigurationTemplate(ConfigurationTemplate template) {
+ if (driftConfigurationTemplates == null) {
+ driftConfigurationTemplates = new HashSet<ConfigurationTemplate>(1);
+ }
driftConfigurationTemplates.add(template);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java
index 26a2477..c25855c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java
@@ -187,6 +187,10 @@ public class AlertFormatUtility {
}
break;
}
+ case DRIFT: {
+ str.append(MSG.view_alert_common_tab_conditions_type_drift());
+ break;
+ }
default: {
str.append(MSG.view_alert_common_tab_invalid_condition_category(category.name()));
break;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index c113008..4410315 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -22,6 +22,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -38,12 +39,15 @@ import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.alert.AlertFormatUtility;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
@@ -55,7 +59,7 @@ public class ConditionsEditor extends LocatableVLayout {
private ResourceType resourceType;
private HashSet<AlertCondition> conditions;
- private Table table;
+ private Table<ConditionDataSource> table;
public ConditionsEditor(String locatorId, ResourceType resourceType, HashSet<AlertCondition> conditions) {
super(locatorId);
@@ -110,36 +114,63 @@ public class ConditionsEditor extends LocatableVLayout {
protected void configureTable() {
addTableAction(this.extendLocatorId("add"), "Add", null, new AbstractTableAction() {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- final Window winModal = new LocatableWindow(ConditionsEditor.this
- .extendLocatorId("newConditionEditorWindow"));
- winModal.setTitle(MSG.view_alert_common_tab_conditions_modal_title());
- winModal.setOverflow(Overflow.VISIBLE);
- winModal.setShowMinimizeButton(false);
- winModal.setIsModal(true);
- winModal.setShowModalMask(true);
- winModal.setAutoSize(true);
- winModal.setAutoCenter(true);
- //winModal.setShowResizer(true);
- //winModal.setCanDragResize(true);
- winModal.centerInPage();
- winModal.addCloseClickHandler(new CloseClickHandler() {
- @Override
- public void onCloseClick(CloseClientEvent event) {
- winModal.markForDestroy();
- }
- });
-
- NewConditionEditor newConditionEditor = new NewConditionEditor(
- extendLocatorId("newConditionEditor"), conditions, ConditionsEditor.this.resourceType,
- new Runnable() {
+
+ // we need the drift config templates (if there are any) so we know if we should offer drift conditions as an option
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(resourceType.getId(),
+ EnumSet.of(MetadataType.driftConfigurationTemplates),
+ new ResourceTypeRepository.TypeLoadedCallback() {
@Override
- public void run() {
- winModal.markForDestroy();
- refresh();
+ public void onTypesLoaded(ResourceType type) {
+ // the resource type repo caches types - so if this resource type was already cached prior
+ // to the conditions editor component created (which it probably was) then we are getting the same
+ // exact instance that we had before (resourceType). When this happens, great! Our resourceType
+ // instance will have its drift config templates populated. But, I'm being paranoid. If somehow
+ // we have a resourceType that is different than the type being passed to us, we need to copy
+ // the drift config.
+ if (type != resourceType) {
+ // paranoia, unsure if this is needed but clear out any old drift config still hanging around
+ if (resourceType.getDriftConfigurationTemplates() != null) {
+ resourceType.getDriftConfigurationTemplates().clear();
+ }
+ // if the newly loaded resource type supports drift, put it in our type object
+ if (type.getDriftConfigurationTemplates() != null) {
+ for (ConfigurationTemplate ct : type.getDriftConfigurationTemplates()) {
+ resourceType.addDriftConfigurationTemplate(ct);
+ }
+ }
+ }
+ final Window winModal = new LocatableWindow(ConditionsEditor.this
+ .extendLocatorId("newConditionEditorWindow"));
+ winModal.setTitle(MSG.view_alert_common_tab_conditions_modal_title());
+ winModal.setOverflow(Overflow.VISIBLE);
+ winModal.setShowMinimizeButton(false);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ //winModal.setShowResizer(true);
+ //winModal.setCanDragResize(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.markForDestroy();
+ }
+ });
+
+ NewConditionEditor newConditionEditor = new NewConditionEditor(
+ extendLocatorId("newConditionEditor"), conditions,
+ ConditionsEditor.this.resourceType, new Runnable() {
+ @Override
+ public void run() {
+ winModal.markForDestroy();
+ refresh();
+ }
+ });
+ winModal.addItem(newConditionEditor);
+ winModal.show();
}
});
- winModal.addItem(newConditionEditor);
- winModal.show();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 44875d8..8b9986f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -99,6 +99,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
private boolean supportsOperations = false;
private boolean supportsEvents = false;
private boolean supportsResourceConfig = false;
+ private boolean supportsDrift = false;
private Runnable closeFunction; // this is called after a button is pressed and the editor should close
private ResourceType resourceType;
@@ -112,6 +113,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
this.supportsEvents = (rtype.getEventDefinitions() != null && rtype.getEventDefinitions().size() > 0);
this.supportsResourceConfig = (rtype.getResourceConfigurationDefinition() != null);
+ this.supportsDrift = (rtype.getDriftConfigurationTemplates() != null && rtype.getDriftConfigurationTemplates()
+ .size() > 0);
Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions();
if (metricDefinitions != null && metricDefinitions.size() > 0) {
@@ -183,6 +186,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
condTypes.put(AlertConditionCategory.EVENT.name(), MSG
.view_alert_definition_condition_editor_option_event());
}
+ if (supportsDrift) {
+ condTypes.put(AlertConditionCategory.DRIFT.name(), MSG
+ .view_alert_definition_condition_editor_option_drift());
+ }
conditionTypeSelectItem.setValueMap(condTypes);
conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.AVAILABILITY.name());
conditionTypeSelectItem.setWrapTitle(false);
@@ -245,6 +252,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
if (supportsResourceConfig) {
formItems.addAll(buildResourceConfigChangeFormItems());
}
+ if (supportsDrift) {
+ formItems.addAll(buildDriftFormItems());
+ }
formItems.add(spacer2);
formItems.add(ok);
formItems.add(cancel);
@@ -367,6 +377,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
break;
}
+ case DRIFT: {
+ newCondition.setName(null);
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(null); // TODO driftalert - be able to regex for only certain files that drifted
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
default: {
CoreGUI.getErrorHandler()
.handleError(MSG.view_alert_common_tab_invalid_condition_category(category.name())); // should never happen
@@ -702,6 +721,18 @@ public class NewConditionEditor extends LocatableDynamicForm {
return formItems;
}
+ private ArrayList<FormItem> buildDriftFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.DRIFT);
+
+ String helpStr = MSG.view_alert_definition_condition_editor_drift_tooltip();
+ StaticTextItem helpItem = buildHelpTextItem("driftHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ return formItems;
+ }
+
private SelectItem buildMetricDropDownMenu(String itemName, boolean dynamicOnly, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
index c4630dd..d9689aa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
@@ -30,6 +30,7 @@ import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
@@ -57,7 +58,7 @@ public class ResourceTypeRepository {
private static ResourceTypeGWTServiceAsync resourceTypeService = GWTServiceLookup.getResourceTypeGWTService();
public enum MetadataType {
- children, operations, measurements, content, events, pluginConfigurationDefinition, resourceConfigurationDefinition, subCategory, parentTypes, processScans, productVersions
+ children, operations, measurements, content, events, pluginConfigurationDefinition, resourceConfigurationDefinition, subCategory, parentTypes, processScans, productVersions, driftConfigurationTemplates
}
public static class Cache {
@@ -245,6 +246,9 @@ public class ResourceTypeRepository {
case subCategory:
criteria.fetchSubCategory(true);
break;
+ case driftConfigurationTemplates:
+ criteria.fetchDriftConfigurationTemplates(true);
+ break;
default:
Log.error("ERROR: metadataType " + metadataType.name()
+ " not incorporated into ResourceType criteria.");
@@ -254,11 +258,10 @@ public class ResourceTypeRepository {
criteria.setPageControl(PageControl.getUnlimitedInstance());
- Log.info("Loading " + typesNeeded.size()
- + ((metadataTypes != null) ? (" types: " + metadataTypes) : ""));
+ Log.info("Loading " + typesNeeded.size() + ((metadataTypes != null) ? (" types: " + metadataTypes) : ""));
- if ((topLevelServerAndServiceTypes == null) && (metadataTypes != null) &&
- metadataTypes.contains(MetadataType.children)) {
+ if ((topLevelServerAndServiceTypes == null) && (metadataTypes != null)
+ && metadataTypes.contains(MetadataType.children)) {
// Perform a one-time load of server and service types with no parent types. These types are implicitly
// children of all platform types, even though they are not included in the platform types'
// childResourceTypes field.
@@ -269,9 +272,8 @@ public class ResourceTypeRepository {
}
private void loadTopLevelServerAndServiceTypes(final TypesLoadedCallback callback,
- final EnumSet<MetadataType> metadataTypes,
- final ResourceTypeCriteria criteria, final Map<Integer,
- ResourceType> cachedTypes) {
+ final EnumSet<MetadataType> metadataTypes, final ResourceTypeCriteria criteria,
+ final Map<Integer, ResourceType> cachedTypes) {
ResourceTypeCriteria topLevelCriteria = new ResourceTypeCriteria();
topLevelCriteria.fetchParentResourceTypes(true);
resourceTypeService.findResourceTypesByCriteria(topLevelCriteria, new AsyncCallback<PageList<ResourceType>>() {
@@ -283,8 +285,8 @@ public class ResourceTypeRepository {
public void onSuccess(PageList<ResourceType> types) {
topLevelServerAndServiceTypes = new HashSet<ResourceType>();
for (ResourceType type : types) {
- if ((type.getCategory() != ResourceCategory.PLATFORM) &&
- (type.getParentResourceTypes() == null || type.getParentResourceTypes().isEmpty())) {
+ if ((type.getCategory() != ResourceCategory.PLATFORM)
+ && (type.getParentResourceTypes() == null || type.getParentResourceTypes().isEmpty())) {
topLevelServerAndServiceTypes.add(type);
}
}
@@ -293,7 +295,8 @@ public class ResourceTypeRepository {
});
}
- private void loadRequestedTypes(final TypesLoadedCallback callback, final EnumSet<MetadataType> metadataTypes, ResourceTypeCriteria criteria, final Map<Integer, ResourceType> cachedTypes) {
+ private void loadRequestedTypes(final TypesLoadedCallback callback, final EnumSet<MetadataType> metadataTypes,
+ ResourceTypeCriteria criteria, final Map<Integer, ResourceType> cachedTypes) {
resourceTypeService.findResourceTypesByCriteria(criteria, new AsyncCallback<PageList<ResourceType>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.widget_typeCache_loadFail(), caught);
@@ -308,8 +311,8 @@ public class ResourceTypeRepository {
switch (metadataType) {
case children:
Set<ResourceType> childTypes = type.getChildResourceTypes();
- if (type.getCategory() == ResourceCategory.PLATFORM &&
- topLevelServerAndServiceTypes != null) {
+ if (type.getCategory() == ResourceCategory.PLATFORM
+ && topLevelServerAndServiceTypes != null) {
// Add server and service types with no parent types to the list of child types.
// These types are implicitly children of all platform types, even though they
// are not included in the platform types' childResourceTypes field.
@@ -349,9 +352,19 @@ public class ResourceTypeRepository {
case subCategory:
cachedType.setSubCategory(type.getSubCategory());
break;
+ case driftConfigurationTemplates:
+ if (cachedType.getDriftConfigurationTemplates() != null) {
+ cachedType.getDriftConfigurationTemplates().clear(); // remove any old ones hanging around
+ }
+ if (type.getDriftConfigurationTemplates() != null) {
+ for (ConfigurationTemplate ct : type.getDriftConfigurationTemplates()) {
+ cachedType.addDriftConfigurationTemplate(ct);
+ }
+ }
+ break;
default:
Log.error("ERROR: metadataType " + metadataType.name()
- + " not merged into cached ResourceType.");
+ + " not merged into cached ResourceType.");
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index beb105b..2c62f90 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -612,6 +612,7 @@ view_alert_common_tab_conditions_text = Condition
view_alert_common_tab_conditions_type_availability = Availability Change
view_alert_common_tab_conditions_type_availability_down = Went down
view_alert_common_tab_conditions_type_availability_up = Came up
+view_alert_common_tab_conditions_type_drift = Drift Detection
view_alert_common_tab_conditions_type_event = Event Detection
view_alert_common_tab_conditions_type_event_matching = with event source matching
view_alert_common_tab_conditions_type_metric_baseline = Metric Value Baseline
@@ -666,6 +667,7 @@ view_alert_definition_condition_editor_common_avg = Average
view_alert_definition_condition_editor_common_max = Maximum
view_alert_definition_condition_editor_common_min = Minimum
view_alert_definition_condition_editor_delete_confirm = Delete the selected alert condition(s)?
+view_alert_definition_condition_editor_drift_tooltip = This condition is triggered when drift has been detected.
view_alert_definition_condition_editor_event_regex = Regular Expression
view_alert_definition_condition_editor_event_regex_tooltip = If specified, this is a regular expression that must match a collected event message in order to trigger the condition.
view_alert_definition_condition_editor_event_severity = Event Severity
@@ -716,6 +718,7 @@ view_alert_definition_condition_editor_operation_status_success = Success
view_alert_definition_condition_editor_operation_tooltip = Specify the result that must occur when the selected operation is executed in order to trigger the condition.
view_alert_definition_condition_editor_operation_value = Operation
view_alert_definition_condition_editor_option_availability = Availability Change
+view_alert_definition_condition_editor_option_drift = Drift Detection
view_alert_definition_condition_editor_option_event = Event Detection
view_alert_definition_condition_editor_option_label = Condition Type
view_alert_definition_condition_editor_option_metric_baseline = Measurement Baseline Threshold
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 5bb5a98..54c4599 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -489,7 +489,8 @@ view_alert_common_tab_conditions_text = Bedingung
view_alert_common_tab_conditions_type_availability = Ãnderung der VerfÃŒgbarkeit
view_alert_common_tab_conditions_type_availability_down = Wurde unverfÃŒgbar
view_alert_common_tab_conditions_type_availability_up = Wurde wieder verfÃŒgbar
-view_alert_common_tab_conditions_type_event = Event Detection~
+##view_alert_common_tab_conditions_type_drift = Drift Detection
+##view_alert_common_tab_conditions_type_event = Event Detection
view_alert_common_tab_conditions_type_event_matching = with event source matching~
view_alert_common_tab_conditions_type_metric_baseline = Metrik ÃŒberschreitet Referenzband
view_alert_common_tab_conditions_type_metric_baseline_verb = von
@@ -543,6 +544,7 @@ view_alert_definition_condition_editor_common_avg = Durchschnitt
view_alert_definition_condition_editor_common_max = Maximum
view_alert_definition_condition_editor_common_min = Minimum
view_alert_definition_condition_editor_delete_confirm = Die ausgewÀhlte(n) Alarm-Bedingung(en) löschen?
+##view_alert_definition_condition_editor_drift_tooltip = This condition is triggered when drift has been detected.
view_alert_definition_condition_editor_event_regex = RegulÀrer Ausdruck
view_alert_definition_condition_editor_event_regex_tooltip = If specified, this is a regular expression that must match a collected event message in order to trigger the condition.~
view_alert_definition_condition_editor_event_severity = Schwere des Ereignisses
@@ -593,7 +595,8 @@ view_alert_definition_condition_editor_operation_status_success = Erfolg
view_alert_definition_condition_editor_operation_tooltip = Specify the result that must occur when the selected operation is executed in order to trigger the condition.~
view_alert_definition_condition_editor_operation_value = Operation
view_alert_definition_condition_editor_option_availability = Ãnderung der VerfÃŒgbarkeit
-view_alert_definition_condition_editor_option_event = Event Detection~
+##view_alert_definition_condition_editor_option_drift = Drift Detection
+##view_alert_definition_condition_editor_option_event = Event Detection
view_alert_definition_condition_editor_option_label = Typ der Bedingung
view_alert_definition_condition_editor_option_metric_baseline = Schwelle des Referenzbands
view_alert_definition_condition_editor_option_metric_calltime_change = Ãnderung des Call-Time-Werts
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 98a20a4..bafd11f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -607,6 +607,7 @@ view_alert_common_tab_conditions_text = æ¡ä»¶
view_alert_common_tab_conditions_type_availability = ã¢ãã€ã©ããªãã£ã®å€å
view_alert_common_tab_conditions_type_availability_down = äžé
view_alert_common_tab_conditions_type_availability_up = äžæ
+##view_alert_common_tab_conditions_type_drift = Drift Detection
view_alert_common_tab_conditions_type_event = ã€ãã³ãã®æ€åº
view_alert_common_tab_conditions_type_event_matching = ã€ãã³ããœãŒã¹ãäžèŽ
view_alert_common_tab_conditions_type_metric_baseline = ã¡ããªãã¯å€ã®ããŒã¹ã©ã€ã³
@@ -661,6 +662,7 @@ view_alert_definition_condition_editor_common_avg = å¹³å
view_alert_definition_condition_editor_common_max = æ倧
view_alert_definition_condition_editor_common_min = æå°
view_alert_definition_condition_editor_delete_confirm = éžæãããã¢ã©ãŒãå®çŸ©ãåé€ããŸãã?
+##view_alert_definition_condition_editor_drift_tooltip = This condition is triggered when drift has been detected.
view_alert_definition_condition_editor_event_regex = æ£èŠè¡šçŸ
view_alert_definition_condition_editor_event_regex_tooltip = ããæå®ããããªããããã¯æ£èŠè¡šçŸã§ããããã®æ¡ä»¶ãåŒãèµ·ããããã«åéãããã€ãã³ãã¡ãã»ãŒãžã«äžèŽããªããã°ãªããŸããã
view_alert_definition_condition_editor_event_severity = ã€ãã³ãé倧床
@@ -711,6 +713,7 @@ view_alert_definition_condition_editor_operation_status_success = æå
view_alert_definition_condition_editor_operation_tooltip = æ¡ä»¶ãåŒãèµ·ããããã«éžæããããå®è¡ããããšãçºçããªããã°ãªããªãçµæãæå®ããŸã
view_alert_definition_condition_editor_operation_value = ãªãã¬ãŒã·ã§ã³
view_alert_definition_condition_editor_option_availability = ã¢ãã€ã©ããªãã£ã®å€å
+##view_alert_definition_condition_editor_option_drift = Drift Detection
view_alert_definition_condition_editor_option_event = ã€ãã³ãã®æ€åº
view_alert_definition_condition_editor_option_label = æ¡ä»¶ã¿ã€ã
view_alert_definition_condition_editor_option_metric_baseline = 枬å®ããŒã¹ã©ã€ã³ã®éŸå€
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 48cae04..2722b0d 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -623,6 +623,7 @@ view_alert_common_tab_conditions_text = Condi\u00E7\u00E3o
view_alert_common_tab_conditions_type_availability = Mudan\u00E7a na Disponibilidade
view_alert_common_tab_conditions_type_availability_down = Indispon\u00EDvel
view_alert_common_tab_conditions_type_availability_up = Dispon\u00EDvel
+##view_alert_common_tab_conditions_type_drift = Drift Detection
view_alert_common_tab_conditions_type_event = Detec\u00E7\u00E3o de Envento
view_alert_common_tab_conditions_type_event_matching = combinando com o evento de origem
view_alert_common_tab_conditions_type_metric_baseline = Valor da m\u00E9trica excede a linha de base (baseline)
@@ -679,6 +680,7 @@ view_alert_definition_condition_editor_common_avg = M\u00E9dio
view_alert_definition_condition_editor_common_max = M\u00E1ximo
view_alert_definition_condition_editor_common_min = M\u00EDnimo
view_alert_definition_condition_editor_delete_confirm = Delete the selected alert condition(s)?
+##view_alert_definition_condition_editor_drift_tooltip = This condition is triggered when drift has been detected.
view_alert_definition_condition_editor_event_regex = Express\u00E3o Regular
view_alert_definition_condition_editor_event_regex_tooltip = Se definida, a condi\u00E7\u00E3o somente ser\u00E1 disparada caso o evento satisfa\u00E7a a express\u00E3o.
view_alert_definition_condition_editor_event_severity = Severidade do Evento
@@ -729,6 +731,7 @@ view_alert_definition_condition_editor_operation_status_success = Sucesso
view_alert_definition_condition_editor_operation_tooltip = Define o resultado esperado quando a opera\u00E7\u00E3o selecionada for executada para dispararo da confi\u00E7\u00E3o.
view_alert_definition_condition_editor_operation_value = Opera\u00E7\u00E3o
view_alert_definition_condition_editor_option_availability = Mudan\u00E7a de Disponibilidade
+##view_alert_definition_condition_editor_option_drift = Drift Detection
view_alert_definition_condition_editor_option_event = Detec\u00E7\u00E3o de Evento
view_alert_definition_condition_editor_option_label = Tipo de Condi\u00E7\u00E3o
view_alert_definition_condition_editor_option_metric_baseline = Threshold base da M\u00E9trica
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 77d3749..f73be85 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -606,6 +606,7 @@ view_alert_common_tab_conditions_text = \u6761\u4ef6
view_alert_common_tab_conditions_type_availability = \u53ef\u7528\u6027\u6539\u53d8
view_alert_common_tab_conditions_type_availability_down = Went down
view_alert_common_tab_conditions_type_availability_up = Came up
+##view_alert_common_tab_conditions_type_drift = Drift Detection
view_alert_common_tab_conditions_type_event = \u4e8b\u4ef6\u68c0\u6d4b
view_alert_common_tab_conditions_type_event_matching = with event source matching
view_alert_common_tab_conditions_type_metric_baseline = \u6307\u6807\u57fa\u51c6
@@ -660,6 +661,7 @@ view_alert_definition_condition_editor_common_avg = \u5e73\u5747
view_alert_definition_condition_editor_common_max = \u6700\u5927
view_alert_definition_condition_editor_common_min = \u6700\u5c0f
view_alert_definition_condition_editor_delete_confirm = \u5220\u9664\u9009\u5b9a\u7684\u8b66\u62a5\u6761\u4ef6?
+##view_alert_definition_condition_editor_drift_tooltip = This condition is triggered when drift has been detected.
view_alert_definition_condition_editor_event_regex = \u6b63\u5219\u8868\u8fbe\u5f0f
view_alert_definition_condition_editor_event_regex_tooltip = If specified, this is a regular expression that must match a collected event message in order to trigger the condition.
view_alert_definition_condition_editor_event_severity = \u4e8b\u4ef6\u4e25\u91cd\u6027
@@ -710,6 +712,7 @@ view_alert_definition_condition_editor_operation_status_success = Success
view_alert_definition_condition_editor_operation_tooltip = Specify the result that must occur when the selected operation is executed in order to trigger the condition.
view_alert_definition_condition_editor_operation_value = \u64cd\u4f5c
view_alert_definition_condition_editor_option_availability = \u53ef\u7528\u6027\u6539\u53d8
+##view_alert_definition_condition_editor_option_drift = Drift Detection
view_alert_definition_condition_editor_option_event = \u4e8b\u4ef6\u68c0\u6d4b
view_alert_definition_condition_editor_option_label = \u6761\u4ef6\u7c7b\u578b
view_alert_definition_condition_editor_option_metric_baseline = \u6307\u6807\u57fa\u7ebf\u9600\u503c
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
index ef2ac95..05e2af6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
@@ -112,6 +112,9 @@ public class AlertConditionManagerBean implements AlertConditionManagerLocal {
} else if (category == AlertConditionCategory.RESOURCE_CONFIG) {
queryName = AlertCondition.QUERY_BY_CATEGORY_RESOURCE_CONFIG;
+ } else if (category == AlertConditionCategory.DRIFT) {
+ queryName = AlertCondition.QUERY_BY_CATEGORY_DRIFT;
+
} else {
throw new IllegalArgumentException("getAlertConditionComposites does not support category '" + category
+ "'");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
index 02ae7b1..728ceff 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java
@@ -620,7 +620,9 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
* flushing org.jboss.on.domain.event.alert.AlertConditionLog.alert -> org.jboss.on.domain.event.alert.Alert"
*/
this.createAlert(newAlert);
- log.debug("New alert identifier=" + newAlert.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("New alert identifier=" + newAlert.getId());
+ }
// AlertNotificationLog alertNotifLog = new AlertNotificationLog(newAlert); TODO - is that all?
// entityManager.persist(alertNotifLog);
@@ -628,7 +630,9 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
List<AlertConditionLog> unmatchedConditionLogs = alertConditionLogManager
.getUnmatchedLogsByAlertDefinitionId(alertDefinitionId);
for (AlertConditionLog unmatchedLog : unmatchedConditionLogs) {
- log.debug("Matched alert condition log for alertId=" + newAlert.getId() + ": " + unmatchedLog);
+ if (log.isDebugEnabled()) {
+ log.debug("Matched alert condition log for alertId=" + newAlert.getId() + ": " + unmatchedLog);
+ }
newAlert.addConditionLog(unmatchedLog); // adds both relationships
}
@@ -651,7 +655,9 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
* to give them some way to explicitly try to re-send the notification for some client-side auditing purposes
*/
try {
- log.debug("Sending alert notifications for " + alert.toSimpleString() + "...");
+ if (log.isDebugEnabled()) {
+ log.debug("Sending alert notifications for " + alert.toSimpleString() + "...");
+ }
List<AlertNotification> alertNotifications = alert.getAlertDefinition().getAlertNotifications();
//Set<String> emailAddresses = new LinkedHashSet<String>();
@@ -721,7 +727,9 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
}
public Collection<String> sendAlertNotificationEmails(Alert alert, Collection<String> emailAddresses) {
- log.debug("Sending alert notifications for " + alert.toSimpleString() + "...");
+ if (log.isDebugEnabled()) {
+ log.debug("Sending alert notifications for " + alert.toSimpleString() + "...");
+ }
if (emailAddresses.size() == 0) {
return new ArrayList<String>(0); // No email to send -> no bad addresses
@@ -885,6 +893,13 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
else
builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_AVAILABILITY,
condition.getOption()));
+ } else if (category == AlertConditionCategory.DRIFT) {
+ if (shortVersion)
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_DRIFT_SHORT,
+ condition.getOption()));
+ else
+ builder.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_CONFIG_PROPS_CB_DRIFT, condition
+ .getOption()));
} else {
// do nothing
}
@@ -915,17 +930,19 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
Integer recoveryDefinitionId = firedDefinition.getRecoveryId();
if (recoveryDefinitionId != 0) {
- log.debug("Processing recovery rules...");
- log.debug("Found recoveryDefinitionId " + recoveryDefinitionId);
+ if (log.isDebugEnabled()) {
+ log.debug("Processing recovery rules... Found recoveryDefinitionId " + recoveryDefinitionId);
+ }
AlertDefinition toBeRecoveredDefinition = alertDefinitionManager.getAlertDefinitionById(overlord,
recoveryDefinitionId);
boolean wasEnabled = toBeRecoveredDefinition.getEnabled();
- log
- .debug(firedDefinition + (wasEnabled ? "does not need to recover " : "needs to recover ")
+ if (log.isDebugEnabled()) {
+ log.debug(firedDefinition + (wasEnabled ? "does not need to recover " : "needs to recover ")
+ toBeRecoveredDefinition
+ (wasEnabled ? ", it was already enabled " : ", it was currently disabled "));
+ }
if (!wasEnabled) {
/*
@@ -941,7 +958,9 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote {
* update the cache indirectly via the status field on the owning agent and the periodic job that checks it.
*/
} else if (firedDefinition.getWillRecover()) {
- log.debug("Disabling " + firedDefinition + " until recovered manually or by recovery definition");
+ if (log.isDebugEnabled()) {
+ log.debug("Disabling " + firedDefinition + " until recovered manually or by recovery definition");
+ }
/*
* disable until recovered manually or by recovery definition
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerBean.java
index 525585e..57cf70d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerBean.java
@@ -38,6 +38,7 @@ import org.rhq.core.domain.operation.OperationHistory;
import org.rhq.core.domain.resource.Agent;
import org.rhq.enterprise.server.alert.engine.internal.AlertConditionCacheCoordinator;
import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
/**
* @author Joseph Marques
@@ -88,6 +89,12 @@ public class AlertConditionCacheManagerBean implements AlertConditionCacheManage
return stats;
}
+ public AlertConditionCacheStats checkConditions(DriftChangeSetSummary driftChangeSetSummary) {
+ AlertConditionCacheStats stats;
+ stats = AlertConditionCacheCoordinator.getInstance().checkConditions(driftChangeSetSummary);
+ return stats;
+ }
+
public void reloadCachesForAgent(int agentId) {
AlertConditionCacheCoordinator.getInstance().reloadCachesForAgent(agentId);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerLocal.java
index 0281d05..1eed43d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/AlertConditionCacheManagerLocal.java
@@ -31,6 +31,7 @@ import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.calltime.CallTimeData;
import org.rhq.core.domain.operation.OperationHistory;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
/**
* This is the SLSB interface for interacting with the clustered cache that stores and computes whether AlertDefinition
@@ -95,6 +96,14 @@ public interface AlertConditionCacheManagerLocal {
*/
AlertConditionCacheStats checkConditions(ResourceConfigurationUpdate update);
+ /**
+ * Drift changes that an agent reported.
+ *
+ * @param driftChangeSetSummary data on the change set that is to be checked
+ * @return the number of conditions that were true against this argument
+ */
+ AlertConditionCacheStats checkConditions(DriftChangeSetSummary driftChangeSetSummary);
+
void reloadCachesForAgent(int agentId);
void reloadGlobalCache();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AgentConditionCache.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AgentConditionCache.java
index 0100d3a..ac19d37 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AgentConditionCache.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AgentConditionCache.java
@@ -32,6 +32,7 @@ import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.alert.composite.AbstractAlertConditionCategoryComposite;
import org.rhq.core.domain.alert.composite.AlertConditionBaselineCategoryComposite;
import org.rhq.core.domain.alert.composite.AlertConditionChangesCategoryComposite;
+import org.rhq.core.domain.alert.composite.AlertConditionDriftCategoryComposite;
import org.rhq.core.domain.alert.composite.AlertConditionEventCategoryComposite;
import org.rhq.core.domain.alert.composite.AlertConditionScheduleCategoryComposite;
import org.rhq.core.domain.alert.composite.AlertConditionTraitCategoryComposite;
@@ -54,6 +55,7 @@ import org.rhq.enterprise.server.alert.engine.internal.AlertConditionCacheCoordi
import org.rhq.enterprise.server.alert.engine.mbean.AlertConditionCacheMonitor;
import org.rhq.enterprise.server.alert.engine.model.AlertConditionOperator;
import org.rhq.enterprise.server.alert.engine.model.CallTimeDataCacheElement;
+import org.rhq.enterprise.server.alert.engine.model.DriftCacheElement;
import org.rhq.enterprise.server.alert.engine.model.EventCacheElement;
import org.rhq.enterprise.server.alert.engine.model.InvalidCacheElementException;
import org.rhq.enterprise.server.alert.engine.model.MeasurementBaselineCacheElement;
@@ -63,6 +65,7 @@ import org.rhq.enterprise.server.alert.engine.model.NumericDoubleCacheElement;
import org.rhq.enterprise.server.alert.engine.model.CallTimeDataCacheElement.CallTimeElementValue;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -74,6 +77,7 @@ class AgentConditionCache extends AbstractConditionCache {
private Map<Integer, List<MeasurementTraitCacheElement>> measurementTraitCache;
private Map<Integer, List<CallTimeDataCacheElement>> callTimeCache;
private Map<Integer, List<EventCacheElement>> eventsCache;
+ private Map<Integer, List<DriftCacheElement>> driftCache;
private AlertConditionManagerLocal alertConditionManager;
private MeasurementDataManagerLocal measurementDataManager;
@@ -90,6 +94,7 @@ class AgentConditionCache extends AbstractConditionCache {
measurementTraitCache = new HashMap<Integer, List<MeasurementTraitCacheElement>>();
callTimeCache = new HashMap<Integer, List<CallTimeDataCacheElement>>();
eventsCache = new HashMap<Integer, List<EventCacheElement>>();
+ driftCache = new HashMap<Integer, List<DriftCacheElement>>();
alertConditionManager = LookupUtil.getAlertConditionManager();
measurementDataManager = LookupUtil.getMeasurementDataManager();
@@ -110,14 +115,15 @@ class AgentConditionCache extends AbstractConditionCache {
AlertConditionCacheStats stats = new AlertConditionCacheStats();
try {
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Loading Alert Condition Caches for agent[id=" + agentId + "]...");
+ }
Subject overlord = subjectManager.getOverlord();
EnumSet<AlertConditionCategory> supportedCategories = EnumSet.of(AlertConditionCategory.BASELINE,
AlertConditionCategory.CHANGE, AlertConditionCategory.TRAIT, AlertConditionCategory.THRESHOLD,
- AlertConditionCategory.EVENT);
+ AlertConditionCategory.EVENT, AlertConditionCategory.DRIFT);
for (AlertConditionCategory nextCategory : supportedCategories) {
// page thru all alert definitions
@@ -146,12 +152,14 @@ class AgentConditionCache extends AbstractConditionCache {
pc.setPageNumber(pc.getPageNumber() + 1);
}
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Loaded " + rowsProcessed + " Alert Condition Composites of type '" + nextCategory + "'");
+ }
}
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Loaded Alert Condition Caches for agent[id=" + agentId + "]");
+ }
} catch (Throwable t) {
// don't let any exceptions bubble up to the calling SLSB layer
log.error("Error loading cache for agent[id=" + agentId + "]", t);
@@ -304,6 +312,10 @@ class AgentConditionCache extends AbstractConditionCache {
}
addTo("eventsCache", eventsCache, eventComposite.getResourceId(), cacheElement, alertConditionId, stats);
+ } else if (alertConditionCategory == AlertConditionCategory.DRIFT) {
+ AlertConditionDriftCategoryComposite driftComposite = (AlertConditionDriftCategoryComposite) composite;
+ DriftCacheElement cacheElement = new DriftCacheElement(alertConditionOperator, alertConditionId);
+ addTo("driftCache", driftCache, driftComposite.getResourceId(), cacheElement, alertConditionId, stats);
}
}
@@ -340,7 +352,7 @@ class AgentConditionCache extends AbstractConditionCache {
log.debug("Check Measurements[size=" + measurementData.length + "] - " + stats);
} catch (Throwable t) {
// don't let any exceptions bubble up to the calling SLSB layer
- log.error("Error during cache processing for agent[id=" + agentId + "]", t);
+ log.error("Error during measurement data cache processing for agent[id=" + agentId + "]", t);
}
return stats;
}
@@ -372,8 +384,9 @@ class AgentConditionCache extends AbstractConditionCache {
private HashMap<Integer, HashMap<String, ArrayList<CallTimeDataValue>>> produceOrderedCallTimeDataStructure(
CallTimeData... callTime) {
long beginTime = 0;
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
beginTime = System.nanoTime();
+ }
//Insert all CallTimeDataValue in data structure
HashMap<Integer, HashMap<String, ArrayList<CallTimeDataValue>>> order = new HashMap<Integer, HashMap<String, ArrayList<CallTimeDataValue>>>();
@@ -396,9 +409,10 @@ class AgentConditionCache extends AbstractConditionCache {
for (ArrayList<CallTimeDataValue> bottomList : topList.values())
Collections.sort(bottomList, getCallTimeComparator());
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("sorting call-time data during alerting took: "
+ TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - beginTime) + "ms");
+ }
return order;
}
@@ -447,11 +461,32 @@ class AgentConditionCache extends AbstractConditionCache {
AlertConditionCacheMonitor.getMBean().incrementEventCacheElementMatches(stats.matched);
AlertConditionCacheMonitor.getMBean().incrementEventProcessingTime(stats.getAge());
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Check Events[size=" + events.length + "] - " + stats);
+ }
+ } catch (Throwable t) {
+ // don't let any exceptions bubble up to the calling SLSB layer
+ log.error("Error during event cache processing for agent[id=" + agentId + "]", t);
+ }
+ return stats;
+ }
+
+ public AlertConditionCacheStats checkConditions(DriftChangeSetSummary driftChangeSetSummary) {
+ AlertConditionCacheStats stats = new AlertConditionCacheStats();
+ try {
+ int resourceId = driftChangeSetSummary.getResourceId();
+ List<DriftCacheElement> cacheElements = lookupDriftCacheElements(resourceId);
+
+ processCacheElements(cacheElements, (Object) "", driftChangeSetSummary.getCreatedTime(), stats);
+
+ AlertConditionCacheMonitor.getMBean().incrementDriftCacheElementMatches(stats.matched);
+ AlertConditionCacheMonitor.getMBean().incrementDriftProcessingTime(stats.getAge());
+ if (log.isDebugEnabled()) {
+ log.debug("Check Drift[resourceId=" + resourceId + "] - " + stats);
+ }
} catch (Throwable t) {
// don't let any exceptions bubble up to the calling SLSB layer
- log.error("Error during cache processing for agent[id=" + agentId + "]", t);
+ log.error("Error during drift cache processing for agent[id=" + agentId + "]", t);
}
return stats;
}
@@ -472,6 +507,10 @@ class AgentConditionCache extends AbstractConditionCache {
return eventsCache.get(resourceId); // yup, might be null
}
+ private List<DriftCacheElement> lookupDriftCacheElements(int resourceId) {
+ return driftCache.get(resourceId); // yup, might be null
+ }
+
private Double getCalculatedBaselineValue(int conditionId, AlertConditionBaselineCategoryComposite composite,
String optionStatus, Double threshold) {
int baselineId = composite.getBaselineId();
@@ -517,6 +556,8 @@ class AgentConditionCache extends AbstractConditionCache {
return AlertConditionCacheUtils.getMapListCount(callTimeCache);
} else if (cache == AlertConditionCacheCoordinator.Cache.EventsCache) {
return AlertConditionCacheUtils.getMapListCount(eventsCache);
+ } else if (cache == AlertConditionCacheCoordinator.Cache.DriftCache) {
+ return AlertConditionCacheUtils.getMapListCount(driftCache);
} else {
throw new IllegalArgumentException("The " + AgentConditionCache.class.getSimpleName()
+ " either does not manage caches of type " + cache.type + ", or does not support obtaining their size");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheCoordinator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheCoordinator.java
index f24b7d9..db4b0b9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheCoordinator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheCoordinator.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats;
import org.rhq.enterprise.server.alert.engine.model.AbstractCacheElement;
import org.rhq.enterprise.server.cloud.StatusManagerLocal;
import org.rhq.enterprise.server.core.AgentManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -66,7 +67,8 @@ public final class AlertConditionCacheCoordinator {
ResourceOperationCache(Type.Global), //
AvailabilityCache(Type.Global), //
EventsCache(Type.Agent), //
- ResourceConfigurationCache(Type.Global);
+ ResourceConfigurationCache(Type.Global), //
+ DriftCache(Type.Agent);
public enum Type {
Global, //
@@ -298,6 +300,35 @@ public final class AlertConditionCacheCoordinator {
return stats;
}
+ public AlertConditionCacheStats checkConditions(DriftChangeSetSummary driftChangeSetSummary) {
+ if (driftChangeSetSummary == null) {
+ return new AlertConditionCacheStats();
+ }
+
+ Integer agentId = getAgentId(driftChangeSetSummary);
+ if (agentId == null) {
+ log.error("Could not find agent for resourceId = " + driftChangeSetSummary.getResourceId());
+ return new AlertConditionCacheStats();
+ }
+
+ AlertConditionCacheStats stats = null;
+ AgentConditionCache agentCache = null;
+ agentReadWriteLock.readLock().lock();
+ try {
+ agentCache = agentCaches.get(agentId);
+ } catch (Throwable t) {
+ log.error("Error during checkConditions", t); // don't let any exceptions bubble up to the calling SLSB layer
+ } finally {
+ agentReadWriteLock.readLock().unlock();
+ }
+ if (agentCache != null) {
+ stats = agentCache.checkConditions(driftChangeSetSummary);
+ } else {
+ stats = new AlertConditionCacheStats();
+ }
+ return stats;
+ }
+
public AlertConditionCacheStats checkConditions(Availability... availabilities) {
AlertConditionCacheStats stats = null;
try {
@@ -311,6 +342,17 @@ public final class AlertConditionCacheCoordinator {
return stats;
}
+ private Integer getAgentId(DriftChangeSetSummary driftChangeSetSummary) {
+ try {
+ int resourceId = driftChangeSetSummary.getResourceId();
+ Integer agentId = agentManager.getAgentIdByResourceId(resourceId);
+ return agentId;
+ } catch (Throwable t) {
+ log.error("Error looking up agent by DriftChangeSet", t);
+ }
+ return null;
+ }
+
private Integer getAgentId(EventSource source) {
try {
int resourceId = source.getResource().getId();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheUtils.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheUtils.java
index 6fc8407..2e3ace3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheUtils.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/internal/AlertConditionCacheUtils.java
@@ -49,6 +49,11 @@ class AlertConditionCacheUtils {
return AlertConditionOperator.GREATER_THAN_OR_EQUAL_TO;
}
+ if (category == AlertConditionCategory.DRIFT) {
+ // any drift that is detected infers a change to its previous state
+ return AlertConditionOperator.CHANGES;
+ }
+
if (category == AlertConditionCategory.RESOURCE_CONFIG || category == AlertConditionCategory.CHANGE
|| category == AlertConditionCategory.TRAIT) {
// the model currently supports CHANGE as a category type instead of a comparator
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java
index e997ac1..1442dce 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java
@@ -42,6 +42,7 @@ public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBe
public AtomicInteger measurementCacheElementMatches = new AtomicInteger();
public AtomicInteger resourceConfigurationCacheElementMatches = new AtomicInteger();
public AtomicInteger operationCacheElementMatches = new AtomicInteger();
+ public AtomicInteger driftCacheElementMatches = new AtomicInteger();
public AtomicInteger totalCacheElementMatches = new AtomicInteger();
public AtomicLong availabilityProcessingTime = new AtomicLong();
@@ -49,6 +50,7 @@ public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBe
public AtomicLong measurementProcessingTime = new AtomicLong();
public AtomicLong resourceConfigurationProcessingTime = new AtomicLong();
public AtomicLong operationProcessingTime = new AtomicLong();
+ public AtomicLong driftProcessingTime = new AtomicLong();
public AtomicLong totalProcessingTime = new AtomicLong();
private static MBeanServer mbeanServer;
@@ -97,6 +99,11 @@ public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBe
AlertConditionCacheCoordinator.Cache.ResourceOperationCache);
}
+ public int getDriftCacheElementCount() {
+ return AlertConditionCacheCoordinator.getInstance().getCacheSize(
+ AlertConditionCacheCoordinator.Cache.DriftCache);
+ }
+
public Map<String, Integer> getCacheCounts() {
return AlertConditionCacheCoordinator.getInstance().getCacheCounts();
}
@@ -121,6 +128,10 @@ public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBe
return operationCacheElementMatches.get();
}
+ public int getDriftCacheElementMatches() {
+ return driftCacheElementMatches.get();
+ }
+
public int getTotalCacheElementMatches() {
return totalCacheElementMatches.get();
}
@@ -150,6 +161,11 @@ public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBe
totalCacheElementMatches.addAndGet(matches);
}
+ public void incrementDriftCacheElementMatches(int matches) {
+ driftCacheElementMatches.addAndGet(matches);
+ totalCacheElementMatches.addAndGet(matches);
+ }
+
public long getAvailabilityProcessingTime() {
return availabilityProcessingTime.get();
}
@@ -166,6 +182,10 @@ public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBe
return operationProcessingTime.get();
}
+ public long getDriftProcessingTime() {
+ return driftProcessingTime.get();
+ }
+
public long getTotalProcessingTime() {
return totalProcessingTime.get();
}
@@ -195,6 +215,11 @@ public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBe
totalProcessingTime.addAndGet(moreMillis);
}
+ public void incrementDriftProcessingTime(long moreMillis) {
+ driftProcessingTime.addAndGet(moreMillis);
+ totalProcessingTime.addAndGet(moreMillis);
+ }
+
public void reloadCaches() {
LookupUtil.getAlertConditionCacheManager().reloadAllCaches();
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitorMBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitorMBean.java
index 6af167b..9e0a1f8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitorMBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitorMBean.java
@@ -40,6 +40,8 @@ public interface AlertConditionCacheMonitorMBean {
public long getOperationProcessingTime();
+ public long getDriftProcessingTime();
+
public void incrementAvailabilityProcessingTime(long moreMillis);
public void incrementMeasurementProcessingTime(long moreMillis);
@@ -50,6 +52,8 @@ public interface AlertConditionCacheMonitorMBean {
public void incrementOperationProcessingTime(long moreMillis);
+ public void incrementDriftProcessingTime(long moreMillis);
+
/*
* for current congestion
*/
@@ -63,6 +67,8 @@ public interface AlertConditionCacheMonitorMBean {
public int getOperationCacheElementCount();
+ public int getDriftCacheElementCount();
+
public Map<String, Integer> getCacheCounts();
/*
@@ -80,6 +86,8 @@ public interface AlertConditionCacheMonitorMBean {
public int getOperationCacheElementMatches();
+ public int getDriftCacheElementMatches();
+
public void incrementAvailabilityCacheElementMatches(int matches);
public void incrementMeasurementCacheElementMatches(int matches);
@@ -90,6 +98,8 @@ public interface AlertConditionCacheMonitorMBean {
public void incrementOperationCacheElementMatches(int matches);
+ public void incrementDriftCacheElementMatches(int matches);
+
/*
* cache contents
*/
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/model/AbstractCacheElement.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/model/AbstractCacheElement.java
index f91e167..e09ddae 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/model/AbstractCacheElement.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/model/AbstractCacheElement.java
@@ -68,8 +68,10 @@ public abstract class AbstractCacheElement<T> {
if (value == null) {
if ((operator == AlertConditionOperator.CHANGES) || (operator == AlertConditionOperator.CHANGES_TO)
|| (operator == AlertConditionOperator.CHANGES_FROM)) {
- log.debug("Possible invalid Cache Element: " + "condition with id=" + conditionId + " "
- + "and operator='" + operator.toString() + "' " + "passed a null value argument");
+ if (log.isDebugEnabled()) {
+ log.debug("Possible invalid Cache Element: " + "condition with id=" + conditionId + " "
+ + "and operator='" + operator.toString() + "' " + "passed a null value argument");
+ }
} else {
throw new InvalidCacheElementException("Invalid Cache Element: " + "condition with id=" + conditionId
+ " " + "and operator='" + operator.toString() + "' " + "requires a non-null value");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/model/DriftCacheElement.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/model/DriftCacheElement.java
new file mode 100644
index 0000000..d11ab51
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/model/DriftCacheElement.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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.server.alert.engine.model;
+
+public class DriftCacheElement extends AbstractCacheElement<Object> {
+
+ public DriftCacheElement(AlertConditionOperator operator, int conditionTriggerId) {
+ super(operator, "", conditionTriggerId);
+ }
+
+ @Override
+ public boolean matches(Object providedValue, Object... extraParams) {
+ if (alertConditionOperator == AlertConditionOperator.CHANGES) {
+ return true; // any drift report we get implies the content has changed
+ } else {
+ throw new UnsupportedAlertConditionOperatorException(getClass().getSimpleName() + " does not support "
+ + alertConditionOperator);
+ }
+ }
+
+ @Override
+ public AlertConditionOperator.Type getOperatorSupportsType(AlertConditionOperator operator) {
+ if (operator == AlertConditionOperator.CHANGES) {
+ return operator.getDefaultType();
+ }
+
+ return AlertConditionOperator.Type.NONE;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
index 1de3d85..fb5f392 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/i18n/AlertI18NResourceKeys.java
@@ -28,34 +28,38 @@ import mazz.i18n.annotation.I18NResourceBundle;
@I18NResourceBundle(baseName = "alert-messages", defaultLocale = "en")
public interface AlertI18NResourceKeys {
+ @I18NMessages( { @I18NMessage("Drift detected"), @I18NMessage(locale = "de", value = "Ãnderung erkannt") })
+ String ALERT_CONFIG_PROPS_CB_DRIFT = "alert.config.props.CB.Drift";
+
+ @I18NMessages( { @I18NMessage("Drift detected"), @I18NMessage(locale = "de", value = "Ãnderung erkannt") })
+ String ALERT_CONFIG_PROPS_CB_DRIFT_SHORT = "alert.config.props.CB.Drift.short";
+
@I18NMessages( { @I18NMessage("Availability goes {0}"),
- @I18NMessage(locale = "de", value = "Verfgbarkeit wird {0}") })
+ @I18NMessage(locale = "de", value = "Verfï¿œgbarkeit wird {0}") })
String ALERT_CONFIG_PROPS_CB_AVAILABILITY = "alert.config.props.CB.Availability";
- @I18NMessages( { @I18NMessage("Avail goes {0}"),
- @I18NMessage(locale = "de", value = "Verf. wird {0}") })
+ @I18NMessages( { @I18NMessage("Avail goes {0}"), @I18NMessage(locale = "de", value = "Verf. wird {0}") })
String ALERT_CONFIG_PROPS_CB_AVAILABILITY_SHORT = "alert.config.props.CB.Availability.short";
@I18NMessages( { @I18NMessage("Event Severity: {0}"),
@I18NMessage(locale = "de", value = "Schwere des Ereignesses: {0}") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY = "alert.config.props.CB.EventSeverity";
- @I18NMessages( { @I18NMessage("Sev: {0}"),
- @I18NMessage(locale = "de", value = "Schwere: {0}") })
+ @I18NMessages( { @I18NMessage("Sev: {0}"), @I18NMessage(locale = "de", value = "Schwere: {0}") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_SHORT = "alert.config.props.CB.EventSeverity.short";
@I18NMessages( { @I18NMessage("Event Severity: {0} and matching expression \"{1}\""),
- @I18NMessage(locale = "de", value = "Schwere des Ereignesses: {0} und zugehriger Ausdruck \"{1}\"") })
+ @I18NMessage(locale = "de", value = "Schwere des Ereignesses: {0} und zugehï¿œriger Ausdruck \"{1}\"") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH = "alert.config.props.CB.EventSeverity.RegexMatch";
@I18NMessages( { @I18NMessage("Sev: {0} & exp \"{1}\""),
@I18NMessage(locale = "de", value = "Schwere: {0} & Ausdruck \"{1}\"") })
String ALERT_CONFIG_PROPS_CB_EVENT_SEVERITY_REGEX_MATCH_SHORT = "alert.config.props.CB.EventSeverity.RegexMatch.short";
- @I18NMessages( { @I18NMessage("value changed"), @I18NMessage(locale = "de", value = "Der Wert hat sich gendert") })
+ @I18NMessages( { @I18NMessage("value changed"), @I18NMessage(locale = "de", value = "Der Wert hat sich geï¿œndert") })
String ALERT_CURRENT_LIST_VALUE_CHANGED = "alert.current.list.ValueChanged";
- @I18NMessages( { @I18NMessage("val chg"), @I18NMessage(locale = "de", value = "Wertnd.") })
+ @I18NMessages( { @I18NMessage("val chg"), @I18NMessage(locale = "de", value = "Wertï¿œnd.") })
String ALERT_CURRENT_LIST_VALUE_CHANGED_SHORT = "alert.current.list.ValueChanged.short";
@I18NMessages( {
@@ -64,9 +68,7 @@ public interface AlertI18NResourceKeys {
+ "\\ - Details: {3}\\n\\\n") })
String ALERT_EMAIL_CONDITION_LOG_FORMAT = "alert.email.condition.log.format";
- @I18NMessages( {
- @I18NMessage("\\ - Cond {0}: {1}\\n\\\n" + "\\ - Time: {2}\\n\\\n" + "\\ - Det: {3}\\n\\\n"),
- @I18NMessage(locale = "de", value = " - Bed {0}: {1}\\n\\\n - Zeit: {2}\\n\\\n"
- + "\\ - Det: {3}\\n\\\n") })
+ @I18NMessages( { @I18NMessage("\\ - Cond {0}: {1}\\n\\\n" + "\\ - Time: {2}\\n\\\n" + "\\ - Det: {3}\\n\\\n"),
+ @I18NMessage(locale = "de", value = " - Bed {0}: {1}\\n\\\n - Zeit: {2}\\n\\\n" + "\\ - Det: {3}\\n\\\n") })
String ALERT_EMAIL_CONDITION_LOG_FORMAT_SHORT = "alert.email.condition.log.format.short";
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index b1a7415..738d69f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -18,6 +18,10 @@
*/
package org.rhq.enterprise.server.drift;
+import static java.util.Arrays.asList;
+import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
import java.io.File;
import java.io.InputStream;
import java.util.HashSet;
@@ -36,6 +40,9 @@ import javax.jms.Session;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import difflib.DiffUtils;
+import difflib.Patch;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -52,11 +59,11 @@ import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftConfigurationComparator;
-import org.rhq.core.domain.drift.DriftConfigurationComparator.CompareMode;
import org.rhq.core.domain.drift.DriftConfigurationDefinition;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftSnapshot;
import org.rhq.core.domain.drift.FileDiffReport;
+import org.rhq.core.domain.drift.DriftConfigurationComparator.CompareMode;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
@@ -64,6 +71,7 @@ import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginManager;
@@ -71,13 +79,6 @@ import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
import org.rhq.enterprise.server.util.LookupUtil;
-import difflib.DiffUtils;
-import difflib.Patch;
-
-import static java.util.Arrays.asList;
-import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
-import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
-
/**
* The SLSB supporting Drift management to clients.
*
@@ -100,10 +101,10 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
binaryFileTypes.add("jar");
binaryFileTypes.add("war");
binaryFileTypes.add("ear");
- binaryFileTypes.add("sar"); // jboss service
- binaryFileTypes.add("har"); // hibernate archive
- binaryFileTypes.add("rar"); // resource adapter
- binaryFileTypes.add("wsr"); // jboss web service archive
+ binaryFileTypes.add("sar"); // jboss service
+ binaryFileTypes.add("har"); // hibernate archive
+ binaryFileTypes.add("rar"); // resource adapter
+ binaryFileTypes.add("wsr"); // jboss web service archive
binaryFileTypes.add("zip");
binaryFileTypes.add("tar");
binaryFileTypes.add("bz2");
@@ -351,9 +352,10 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
@Override
@TransactionAttribute(NOT_SUPPORTED)
- public void saveChangeSet(Subject subject, int resourceId, File changeSetZip) throws Exception {
+ public DriftChangeSetSummary saveChangeSet(Subject subject, int resourceId, File changeSetZip) throws Exception {
DriftServerPluginFacet driftServerPlugin = getServerPlugin();
- driftServerPlugin.saveChangeSet(subject, resourceId, changeSetZip);
+ DriftChangeSetSummary summary = driftServerPlugin.saveChangeSet(subject, resourceId, changeSetZip);
+ return summary;
}
@Override
@@ -415,8 +417,8 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
List<String> content2List = asList(content2.split("\\n"));
Patch patch = DiffUtils.diff(content1List, content2List);
- List<String> deltas = DiffUtils.generateUnifiedDiff(drift1.getPath(), drift2.getPath(), content1List, patch,
- 10);
+ List<String> deltas = DiffUtils
+ .generateUnifiedDiff(drift1.getPath(), drift2.getPath(), content1List, patch, 10);
return new FileDiffReport(patch.getDeltas().size(), deltas);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
index c3a34bf..105164f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
@@ -19,6 +19,8 @@
*/
package org.rhq.enterprise.server.drift;
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
@@ -73,11 +75,10 @@ import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.core.AgentManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
-import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
-
/**
* The SLSB method implementation needed to support the JPA (RHQ Default) Drift Server Plugin.
*
@@ -222,12 +223,15 @@ public class JPADriftServerBean implements JPADriftServerLocal {
@Override
@TransactionAttribute(REQUIRES_NEW)
- public void storeChangeSet(Subject subject, final int resourceId, File changeSetZip) throws Exception {
+ public DriftChangeSetSummary storeChangeSet(Subject subject, final int resourceId, File changeSetZip)
+ throws Exception {
final Resource resource = entityManager.find(Resource.class, resourceId);
if (null == resource) {
throw new IllegalArgumentException("Resource not found [" + resourceId + "]");
}
+ final DriftChangeSetSummary summary = new DriftChangeSetSummary();
+
try {
ZipUtil.walkZipFile(changeSetZip, new ChangeSetFileVisitor() {
@@ -254,6 +258,11 @@ public class JPADriftServerBean implements JPADriftServerLocal {
driftChangeSet = new JPADriftChangeSet(resource, version, category, config);
entityManager.persist(driftChangeSet);
+ summary.setCategory(category);
+ summary.setResourceId(resourceId);
+ summary.setDriftConfigurationName(reader.getHeaders().getDriftConfigurationName());
+ summary.setCreatedTime(driftChangeSet.getCtime());
+
for (FileEntry entry : reader) {
JPADriftFile oldDriftFile = getDriftFile(entry.getOldSHA(), emptyDriftFiles);
JPADriftFile newDriftFile = getDriftFile(entry.getNewSHA(), emptyDriftFiles);
@@ -269,6 +278,14 @@ public class JPADriftServerBean implements JPADriftServerLocal {
JPADrift drift = new JPADrift(driftChangeSet, path, entry.getType(), oldDriftFile,
newDriftFile);
entityManager.persist(drift);
+
+ // we are taking advantage of the fact that we know the summary is only used by the server
+ // if the change set is a DRIFT report. If its a coverage report, it is not used (we do
+ // not alert on coverage reports) - so don't waste memory by collecting all the paths
+ // when we know they aren't going to be used anyway.
+ if (category == DriftChangeSetCategory.DRIFT) {
+ summary.addDriftPathname(path);
+ }
}
// send a message to the agent requesting the empty JPADriftFile content
if (!emptyDriftFiles.isEmpty()) {
@@ -295,6 +312,9 @@ public class JPADriftServerBean implements JPADriftServerLocal {
return true;
}
});
+
+ return summary;
+
} catch (Exception e) {
String msg = "Failed to store drift changeset for ";
if (null != resource) {
@@ -304,6 +324,7 @@ public class JPADriftServerBean implements JPADriftServerLocal {
}
log.error(msg, e);
+ return null;
} finally {
// delete the changeSetFile?
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java
index 7142ead..e4c57df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.drift.JPADrift;
import org.rhq.core.domain.drift.JPADriftChangeSet;
import org.rhq.core.domain.drift.JPADriftFile;
import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
/**
* The SLSB methods needed to support the JPA (RHQ Default) Drift Server Plugin.
@@ -94,9 +95,10 @@ public interface JPADriftServerLocal {
*
* @param resourceId The resource for which the change-set is being reported.
* @param changeSetZip The change-set zip file
+ * @return a summary of the change set that was persisted
* @throws Exception
*/
- void storeChangeSet(Subject subject, int resourceId, File changeSetZip) throws Exception;
+ DriftChangeSetSummary storeChangeSet(Subject subject, int resourceId, File changeSetZip) throws Exception;
/**
* This method stores the provided drift files. The files should correspond to requested drift files.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftChangeSetSummary.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftChangeSetSummary.java
new file mode 100644
index 0000000..8148690
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftChangeSetSummary.java
@@ -0,0 +1,93 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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.server.plugin.pc.drift;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+
+/**
+ * Provides a summary of a change set.
+ *
+ * This object is mainly used to pass to the alert subsystem in order to determine which alerts should be triggered.
+ * It doesn't have all the information that a DriftChangeSet has - it's a summary that only has the data necessary
+ * for the alert subsystem to be able to determine what alerts need to be triggered.
+ *
+ * @author John Mazzitelli
+ */
+public class DriftChangeSetSummary {
+ private long createdTime;
+ private DriftChangeSetCategory category;
+ private int resourceId;
+ private String driftConfigurationName;
+ private List<String> driftPathnames;
+
+ public long getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(long createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public DriftChangeSetCategory getCategory() {
+ return category;
+ }
+
+ public void setCategory(DriftChangeSetCategory category) {
+ this.category = category;
+ }
+
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(int resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public String getDriftConfigurationName() {
+ return driftConfigurationName;
+ }
+
+ public void setDriftConfigurationName(String driftConfigurationName) {
+ this.driftConfigurationName = driftConfigurationName;
+ }
+
+ public List<String> getDriftPathnames() {
+ return obtainDriftPathnamesList();
+ }
+
+ public void setDriftPathnames(List<String> driftPathnames) {
+ this.driftPathnames = driftPathnames;
+ }
+
+ public void addDriftPathname(String driftPathname) {
+ obtainDriftPathnamesList().add(driftPathname);
+ }
+
+ private List<String> obtainDriftPathnamesList() {
+ if (driftPathnames == null) {
+ driftPathnames = new ArrayList<String>();
+ }
+ return driftPathnames;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
index 7a960dd..cedf437 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
@@ -72,7 +72,16 @@ public interface DriftServerPluginFacet {
*/
DriftFile getDriftFile(Subject subject, String hashId) throws Exception;
- void saveChangeSet(Subject subject, int resourceId, File changeSetZip) throws Exception;
+ /**
+ * Parses the given change set file and persists its data.
+ *
+ * @param subject
+ * @param resourceId
+ * @param changeSetZip
+ * @return a summary of what was in the change set file
+ * @throws Exception
+ */
+ DriftChangeSetSummary saveChangeSet(Subject subject, int resourceId, File changeSetZip) throws Exception;
void saveChangeSetFiles(Subject subject, File changeSetFilesZip) throws Exception;
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index 561d434..644ee60 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -19,6 +19,8 @@
package org.rhq.enterprise.server.plugins.drift.mongodb;
+import static org.rhq.enterprise.server.util.LookupUtil.getResourceManager;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
@@ -46,6 +48,7 @@ import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftSnapshot;
@@ -58,14 +61,13 @@ import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.file.FileUtil;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSetEntry;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBFile;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
-import static org.rhq.enterprise.server.util.LookupUtil.getResourceManager;
-
public class MongoDBDriftServer implements DriftServerPluginFacet, ServerPluginComponent {
//private final Log log = LogFactory.getLog(MongoDBDriftServer.class);
@@ -101,7 +103,11 @@ public class MongoDBDriftServer implements DriftServerPluginFacet, ServerPluginC
}
@Override
- public void saveChangeSet(final Subject subject, final int resourceId, final File changeSetZip) throws Exception {
+ public DriftChangeSetSummary saveChangeSet(final Subject subject, final int resourceId, final File changeSetZip)
+ throws Exception {
+
+ final DriftChangeSetSummary summary = new DriftChangeSetSummary();
+
ZipUtil.walkZipFile(changeSetZip, new ZipUtil.ZipEntryVisitor() {
@Override
public boolean visit(ZipEntry zipEntry, ZipInputStream stream) throws Exception {
@@ -115,18 +121,33 @@ public class MongoDBDriftServer implements DriftServerPluginFacet, ServerPluginC
changeSet.setDriftConfigurationId(1);
changeSet.setVersion(changeSetVersions++);
+ summary.setCategory(headers.getType());
+ summary.setResourceId(resourceId);
+ summary.setDriftConfigurationName(headers.getDriftConfigurationName());
+ summary.setCreatedTime(changeSet.getCtime());
+
for (FileEntry fileEntry : reader) {
String path = FileUtil.useForwardSlash(fileEntry.getFile());
MongoDBChangeSetEntry entry = new MongoDBChangeSetEntry();
entry.setCategory(fileEntry.getType());
entry.setPath(path);
changeSet.add(entry);
+
+ // we are taking advantage of the fact that we know the summary is only used by the server
+ // if the change set is a DRIFT report. If its a coverage report, it is not used (we do
+ // not alert on coverage reports) - so don't waste memory by collecting all the paths
+ // when we know they aren't going to be used anyway.
+ if (headers.getType() == DriftChangeSetCategory.DRIFT) {
+ summary.addDriftPathname(path);
+ }
}
ds.save(changeSet);
return true;
}
});
+
+ return summary;
}
@Override
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/JPADriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/JPADriftServerPluginComponent.java
index 1dadcb9..ee542d0 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/JPADriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/JPADriftServerPluginComponent.java
@@ -19,6 +19,8 @@
*/
package org.rhq.enterprise.server.plugins.drift;
+import static org.rhq.enterprise.server.util.LookupUtil.getJPADriftServer;
+
import java.io.File;
import org.apache.commons.logging.Log;
@@ -37,10 +39,9 @@ import org.rhq.core.domain.drift.JPADriftChangeSet;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
-import static org.rhq.enterprise.server.util.LookupUtil.getJPADriftServer;
-
/**
* A drift server-side plugin component that the server uses to process drift files.
*
@@ -104,8 +105,8 @@ public class JPADriftServerPluginComponent implements DriftServerPluginFacet, Se
}
@Override
- public void saveChangeSet(Subject subject, int resourceId, File changeSetZip) throws Exception {
- getJPADriftServer().storeChangeSet(subject, resourceId, changeSetZip);
+ public DriftChangeSetSummary saveChangeSet(Subject subject, int resourceId, File changeSetZip) throws Exception {
+ return getJPADriftServer().storeChangeSet(subject, resourceId, changeSetZip);
}
@Override
diff --git a/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml
index cbcbf44..9f0f6a3 100644
--- a/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml
@@ -48,6 +48,8 @@
description="The number of elements in the alerts cache that check conditions against operation history data"/>
<metric property="ResourceConfigurationCacheElementCount" category="throughput" displayType="summary"
description="The number of elements in the alerts cache that check conditions against resource configuration data"/>
+ <metric property="DriftCacheElementCount" category="throughput" displayType="summary"
+ description="The number of elements in the alerts cache that check conditions against drift data"/>
<metric property="TotalCacheElementMatches" category="throughput" displayType="summary" measurementType="trendsup"
description="The total number of times ANY cache element has triggered against incoming data since this RHQ Server instance was started"/>
@@ -61,6 +63,8 @@
description="The total number of times resource configuration-based conditions have triggered against incoming data since this RHQ Server instance was started"/>
<metric property="OperationCacheElementMatches" category="throughput" displayType="summary" measurementType="trendsup"
description="The total number of times operation-based conditions have triggered against incoming data since this RHQ Server instance was started"/>
+ <metric property="DriftCacheElementMatches" category="throughput" displayType="summary" measurementType="trendsup"
+ description="The total number of times drift conditions have triggered against incoming data since this RHQ Server instance was started"/>
<metric property="TotalProcessingTime" units="milliseconds" displayType="summary" measurementType="trendsup"
description="The total amount of time spent by the alerts cache processing ALL types of data"/>
@@ -74,6 +78,8 @@
description="The total amount of time spent by the alerts cache processing resource configuration data"/>
<metric property="OperationProcessingTime" units="milliseconds" displayType="summary" measurementType="trendsup"
description="The total amount of time spent by the alerts cache processing operation history data"/>
+ <metric property="DriftProcessingTime" units="milliseconds" displayType="summary" measurementType="trendsup"
+ description="The total amount of time spent by the alerts cache processing drift data"/>
</service>