modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
| 6
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
| 45 +++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
| 52 +++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
| 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java
| 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitorMBean.java
| 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java
| 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerBean.java
| 65 ++++++++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerLocal.java
| 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/CacheConsistencyManagerBean.java
| 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java
| 12 +
modules/plugins/rhq-server/src/main/java/org/rhq/plugins/server/AlertsCacheResourceComponent.java
| 12 -
12 files changed, 164 insertions(+), 43 deletions(-)
New commits:
commit 546f7dbcc30ecb0666f49958f275baac3c640151
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 30 10:56:10 2010 -0400
BZ-535788: BZ-545062: fix for newly created event/measurement-based alerts not firing
* was previously trying to set agent status bit by alert definition id via pure JPQL
* however, at the time the JPQL is executed, the alert definition hasn't been
persisted yet
* fix was to correlate the cache reload to resourceId instead, which is only required
in the CREATE case
* added new method to StatusManagerBean called updateByResource to handle this new
path
* updated logic in notifyAlertConditionCacheManager to switch on the
AlertDefinitionEvent appropriately
* added more debug-level logging
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index 5a3aeba..5bd260d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -196,6 +196,11 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
+ " FROM AlertDefinition ad " //
+ " WHERE ad.id = :alertDefinitionId " //
+ " AND ad.resourceGroup IS NOT NULL "), //
+ @NamedQuery(name = AlertDefinition.QUERY_IS_RESOURCE_ALERT_DEFINITION, query =
"" //
+ + "SELECT ad.id " //
+ + " FROM AlertDefinition ad " //
+ + " WHERE ad.id = :alertDefinitionId " //
+ + " AND ad.resource IS NOT NULL "), //
@NamedQuery(name = AlertDefinition.QUERY_UPDATE_SET_DELETED, query = "" //
+ "UPDATE AlertDefinition ad " //
+ " SET ad.deleted = TRUE " //
@@ -249,6 +254,7 @@ public class AlertDefinition implements Serializable {
public static final String QUERY_IS_ENABLED = "AlertDefinition.isEnabled";
public static final String QUERY_IS_TEMPLATE =
"AlertDefinition.isTemplate";
public static final String QUERY_IS_GROUP_ALERT_DEFINITION =
"AlertDefinition.isGroupAlertDefinition";
+ public static final String QUERY_IS_RESOURCE_ALERT_DEFINITION =
"AlertDefinition.isResourceAlertDefinition";
// group alert definitions
public static final String QUERY_UPDATE_SET_DELETED =
"AlertDefinition.updateSetDeleted";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
index b452add..0274eec 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
@@ -22,10 +22,9 @@
*/
package org.rhq.core.domain.resource;
-import org.rhq.core.domain.cloud.AffinityGroup;
-import org.rhq.core.domain.cloud.Server;
-
-import org.jetbrains.annotations.NotNull;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -41,9 +40,12 @@ import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.commons.logging.LogFactory;
+import org.jetbrains.annotations.NotNull;
+
+import org.rhq.core.domain.cloud.AffinityGroup;
+import org.rhq.core.domain.cloud.Server;
+import org.rhq.core.util.exception.ThrowableUtil;
/**
* A JON agent.
@@ -98,9 +100,17 @@ import java.util.List;
+ " FROM Agent a " //
+ " WHERE a.id = :agentId " //
+ " AND a.backFilled = true "), //
+ @NamedQuery(name = Agent.QUERY_UPDATE_STATUS_BY_RESOURCE, query = "" //
+ + " UPDATE Agent a " //
+ + " SET a.status = -1 " // negative numbers so that bitmask strategy
does not conflict with this one
+ + " WHERE a.status = 0 " // we only need the first guy to set it
+ + " AND a.id = ( SELECT resA.id " // only update ourselves;
+ + " FROM Resource res " //
+ + " JOIN res.agent resA " //
+ + " WHERE res.id = :resourceId ) "), //
@NamedQuery(name = Agent.QUERY_UPDATE_STATUS_BY_ALERT_DEFINITION, query =
"" //
+ " UPDATE Agent a " //
- + " SET a.status = -1 " // negative numbers so that bitmask strat
does not conflict with this one
+ + " SET a.status = -1 " // negative numbers so that bitmask strategy
does not conflict with this one
+ " WHERE a.status = 0 " // we only need the first guy to set it
+ " AND a.id = ( SELECT resA.id " // only update ourselves;
+ " FROM AlertDefinition ad " //
@@ -109,7 +119,7 @@ import java.util.List;
+ " WHERE ad.id = :alertDefinitionId ) "), //
@NamedQuery(name = Agent.QUERY_UPDATE_STATUS_BY_MEASUREMENT_BASELINE, query =
"" //
+ " UPDATE Agent a " //
- + " SET a.status = -1 " // negative numbers so that bitmask strat
does not conflict with this one
+ + " SET a.status = -1 " // negative numbers so that bitmask strategy
does not conflict with this one
+ " WHERE a.status = 0 " // we only need the first guy to set it
+ " AND a.id = ( SELECT resA.id " // only update ourselves;
+ " FROM MeasurementBaseline mb " //
@@ -119,12 +129,12 @@ import java.util.List;
+ " WHERE mb.id = :baselineId ) "), //
@NamedQuery(name = Agent.QUERY_UPDATE_STATUS_BY_AGENT, query = "" //
+ " UPDATE Agent a " //
- + " SET a.status = -1 " // negative numbers so that bitmask strat
does not conflict with this one
+ + " SET a.status = -1 " // negative numbers so that bitmask strategy
does not conflict with this one
+ " WHERE a.status = 0 " // we only need the first guy to set it
+ " AND a.id = :agentId "), //
@NamedQuery(name = Agent.QUERY_UPDATE_STATUS_FOR_ALL, query = "" //
+ " UPDATE Agent a " //
- + " SET a.status = -1 " // negative numbers so that bitmask strat
does not conflict with this one
+ + " SET a.status = -1 " // negative numbers so that bitmask strategy
does not conflict with this one
+ " WHERE a.status = 0 ") //
})
@SequenceGenerator(name = "id", sequenceName = "RHQ_AGENT_ID_SEQ")
@@ -154,6 +164,7 @@ public class Agent implements Serializable {
public static final String QUERY_UPDATE_CLEAR_STATUS_BY_IDS =
"Agent.updateClearStatusByIds";
public static final String QUERY_REMOVE_SERVER_REFERENCE =
"Agent.removeServerReference";
+ public static final String QUERY_UPDATE_STATUS_BY_RESOURCE =
"Agent.updateStatusByResource";
public static final String QUERY_UPDATE_STATUS_BY_ALERT_DEFINITION =
"Agent.updateStatusByAlertDefinition";
public static final String QUERY_UPDATE_STATUS_BY_MEASUREMENT_BASELINE =
"Agent.updateStatusByMeasurementBasleine";
public static final String QUERY_UPDATE_STATUS_BY_AGENT =
"Agent.updateStatusByAgent";
@@ -463,9 +474,21 @@ public class Agent implements Serializable {
@PreUpdate
void onUpdate() {
+ if (this.server == null) {
+ printWithTrace("Agent getting it's server reference set to
null");
+ }
this.mtime = System.currentTimeMillis();
}
+ private void printWithTrace(String message) {
+ try {
+ new IllegalArgumentException(message);
+ } catch (IllegalArgumentException iae) {
+ String stackTrace = ThrowableUtil.getStackAsString(iae);
+ LogFactory.getLog("HighAvailabilityLogic").fatal(stackTrace);
+ }
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index 4a6bf8b..9a2e3e4 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -126,7 +126,7 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
AlertDefinition alertDefinition = entityManager.find(AlertDefinition.class,
alertDefinitionId);
// avoid NPEs l8er if the caller passed an invalid id
- if (alertDefinition==null)
+ if (alertDefinition == null)
return null;
if (checkViewPermission(subject, alertDefinition) == false) {
@@ -240,8 +240,7 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
}
if (addToCache) {
- notifyAlertConditionCacheManager("createAlertDefinition",
alertDefinition.getId(),
- AlertDefinitionEvent.CREATED);
+ notifyAlertConditionCacheManager("createAlertDefinition",
alertDefinition, AlertDefinitionEvent.CREATED);
}
return alertDefinition.getId();
@@ -296,7 +295,7 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
// alertTemplates and groupAlertDefinitions do not need to update the
cache
isResourceLevel = (null != alertDefinition.getResource());
if (isResourceLevel) {
- notifyAlertConditionCacheManager("removeAlertDefinitions",
alertDefinition.getId(),
+ notifyAlertConditionCacheManager("removeAlertDefinitions",
alertDefinition,
AlertDefinitionEvent.DELETED);
}
if (alertDefinition.getResourceGroup() != null) {
@@ -324,7 +323,7 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
// alertTemplates and groupAlertDefinitions do not need to update the
cache
isResourceLevel = (null != alertDefinition.getResource());
if (isResourceLevel) {
-
notifyAlertConditionCacheManager("enableAlertDefinitions",
alertDefinition.getId(),
+
notifyAlertConditionCacheManager("enableAlertDefinitions", alertDefinition,
AlertDefinitionEvent.ENABLED);
}
}
@@ -358,6 +357,14 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
return (resultIds.size() == 1);
}
+ @SuppressWarnings("unchecked")
+ public boolean isResourceAlertDefinition(Integer definitionId) {
+ Query query =
entityManager.createNamedQuery(AlertDefinition.QUERY_IS_RESOURCE_ALERT_DEFINITION);
+ query.setParameter("alertDefinitionId", definitionId);
+ List<Integer> resultIds = query.getResultList();
+ return (resultIds.size() == 1);
+ }
+
public int disableAlertDefinitions(Subject subject, Integer[] alertDefinitionIds) {
int modifiedCount = 0;
boolean isResourceLevel;
@@ -374,7 +381,7 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
// alertTemplates and groupAlertDefinitions do not need to update the
cache
isResourceLevel = (null != alertDefinition.getResource());
if (isResourceLevel) {
-
notifyAlertConditionCacheManager("disableAlertDefinitions",
alertDefinition.getId(),
+
notifyAlertConditionCacheManager("disableAlertDefinitions", alertDefinition,
AlertDefinitionEvent.DISABLED);
}
}
@@ -402,8 +409,7 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
entityManager.persist(newAlertDefinition);
- notifyAlertConditionCacheManager("copyAlertDefinitions",
alertDefinition.getId(),
- AlertDefinitionEvent.CREATED);
+ notifyAlertConditionCacheManager("copyAlertDefinitions",
alertDefinition, AlertDefinitionEvent.CREATED);
}
}
}
@@ -479,8 +485,7 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
for (AlertCondition nextCondition : oldAlertDefinition.getConditions()) {
LOG.debug("OldAlertCondition[ id=" + nextCondition.getId() +
" ]");
}
- notifyAlertConditionCacheManager("updateAlertDefinition",
oldAlertDefinition.getId(),
- AlertDefinitionEvent.DELETED);
+ notifyAlertConditionCacheManager("updateAlertDefinition",
oldAlertDefinition, AlertDefinitionEvent.DELETED);
}
/*
@@ -521,7 +526,7 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
for (AlertCondition nextCondition : newAlertDefinition.getConditions())
{
LOG.debug("NewAlertCondition[ id=" + nextCondition.getId()
+ " ]");
}
- notifyAlertConditionCacheManager("updateAlertDefinition",
newAlertDefinition.getId(),
+ notifyAlertConditionCacheManager("updateAlertDefinition",
newAlertDefinition,
AlertDefinitionEvent.CREATED);
}
}
@@ -574,10 +579,29 @@ public class AlertDefinitionManagerBean implements
AlertDefinitionManagerLocal,
return;
}
- private void notifyAlertConditionCacheManager(String methodName, int
alertDefinitionId,
+ private void notifyAlertConditionCacheManager(String methodName, AlertDefinition
alertDefinition,
AlertDefinitionEvent alertDefinitionEvent) {
- LOG.debug("Invoking... " + methodName);
- agentStatusManager.updateByAlertDefinition(alertDefinitionId);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Invoking... " + methodName + " with
AlertDefinitionEvent[" + alertDefinitionEvent + "]");
+ }
+ if (alertDefinitionEvent == AlertDefinitionEvent.CREATED) {
+ if (alertDefinition.getResource() != null) {
+ int resourceId = alertDefinition.getResource().getId();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Invoking...
agentStatusManager.updateByResource(" + resourceId + ")");
+ }
+ agentStatusManager.updateByResource(resourceId);
+ } else {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("notifyAlertConditionCacheManager skipping alert
template or group alert definition");
+ }
+ }
+ } else {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Invoking...
agentStatusManager.updateByAlertDefinition(" + alertDefinition.getId() +
")");
+ }
+ agentStatusManager.updateByAlertDefinition(alertDefinition.getId());
+ }
}
private void purgeInternals(int alertDefinitionId) {
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
index 2c97a95..4ea8b60 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
@@ -57,6 +57,8 @@ public interface AlertDefinitionManagerLocal {
boolean isGroupAlertDefinition(Integer definitionId);
+ boolean isResourceAlertDefinition(Integer definitionId);
+
int disableAlertDefinitions(Subject subject, Integer[] alertDefinitionIds);
List<AlertDefinition> findAllRecoveryDefinitionsById(Subject subject, Integer
alertDefinitionId);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerBean.java
index e33adf4..4c4dbd2 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerBean.java
@@ -106,9 +106,39 @@ public class StatusManagerBean implements StatusManagerLocal {
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public void updateByResource(int resourceId) {
+ log.debug("About to mark status by resource");
+
+ /*
+ * the old alert definition is needed to know which caches to remove stale
entries from; the updated / new
+ * alert definition is needed to know which caches need to be reloaded to get the
new conditions; by the time
+ * this method is called, we only have the updated alert definition, thus
it's not possible to intelligently
+ * know which of the two caches to reload; so, we need to reload them both to be
sure the system is consistent
+ */
+ markGlobalCache();
+
+ Query updateAgentQuery =
entityManager.createNamedQuery(Agent.QUERY_UPDATE_STATUS_BY_RESOURCE);
+ updateAgentQuery.setParameter("resourceId", resourceId);
+ int agentsUpdated = updateAgentQuery.executeUpdate();
+
+ /*
+ * this is informational debugging only - do NOT change the status bits here
+ */
+ if (log.isDebugEnabled()) {
+ Agent agent = agentManager.getAgentByResourceId(resourceId);
+ log.debug("Marking status, agent[id=" + agent.getId() + ",
status=" + agent.getStatus()
+ + "] for resource[id=" + resourceId + "]");
+
+ log.debug("Agents updated: " + agentsUpdated);
+ }
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void updateByAlertDefinition(int alertDefinitionId) {
- // protect against template update, it has no resource and/or agent
- if (alertDefinitionManager.isTemplate(alertDefinitionId)) {
+ log.debug("About to mark status by alert definition");
+
+ // alert templates and group alert definitions do not represent cache-ready
entries
+ if (alertDefinitionManager.isResourceAlertDefinition(alertDefinitionId) == false)
{
return;
}
@@ -118,31 +148,44 @@ public class StatusManagerBean implements StatusManagerLocal {
* this method is called, we only have the updated alert definition, thus
it's not possible to intelligently
* know which of the two caches to reload; so, we need to reload them both to be
sure the system is consistent
*/
- Query updateServerQuery =
entityManager.createNamedQuery(Server.QUERY_UPDATE_STATUS_BY_NAME);
- updateServerQuery.setParameter("identity",
serverManager.getIdentity());
- updateServerQuery.executeUpdate();
+ markGlobalCache();
Query updateAgentQuery =
entityManager.createNamedQuery(Agent.QUERY_UPDATE_STATUS_BY_ALERT_DEFINITION);
updateAgentQuery.setParameter("alertDefinitionId", alertDefinitionId);
- updateAgentQuery.executeUpdate();
+ int agentsUpdated = updateAgentQuery.executeUpdate();
/*
* this is informational debugging only - do NOT change the status bits here
*/
if (log.isDebugEnabled()) {
- Server server = serverManager.getServer();
- log.debug("Marking status, server[id=" + server.getId() + ",
status=" + server.getStatus()
- + "] for alertDefinition[id=" + alertDefinitionId +
"]");
-
AlertDefinition definition = entityManager.find(AlertDefinition.class,
alertDefinitionId);
Agent agent =
agentManager.getAgentByResourceId(definition.getResource().getId());
log.debug("Marking status, agent[id=" + agent.getId() + ",
status=" + agent.getStatus()
+ "] for alertDefinition[id=" + alertDefinitionId +
"]");
+
+ log.debug("Agents updated: " + agentsUpdated);
+ }
+ }
+
+ private void markGlobalCache() {
+ Query updateServerQuery =
entityManager.createNamedQuery(Server.QUERY_UPDATE_STATUS_BY_NAME);
+ updateServerQuery.setParameter("identity",
serverManager.getIdentity());
+ int serversUpdated = updateServerQuery.executeUpdate();
+
+ /*
+ * this is informational debugging only - do NOT change the status bits here
+ */
+ if (log.isDebugEnabled()) {
+ Server server = serverManager.getServer();
+ log.debug("Marking status, server[id=" + server.getId() + ",
status=" + server.getStatus() + "]");
+
+ log.debug("Servers updated: " + serversUpdated);
}
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void updateByMeasurementBaseline(int baselineId) {
+ log.debug("About to mark status by measurement baseline");
// baselines refer to measurement-based alert conditions, thus only agent
statuses need to be set
Query updateAgentQuery =
entityManager.createNamedQuery(Agent.QUERY_UPDATE_STATUS_BY_MEASUREMENT_BASELINE);
updateAgentQuery.setParameter("baselineId", baselineId);
@@ -172,6 +215,7 @@ public class StatusManagerBean implements StatusManagerLocal {
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void updateByAgent(int agentId) {
+ log.debug("About to mark status by agent");
Query updateAgentQuery =
entityManager.createNamedQuery(Agent.QUERY_UPDATE_STATUS_BY_AGENT);
updateAgentQuery.setParameter("agentId", agentId);
updateAgentQuery.executeUpdate();
@@ -187,6 +231,7 @@ public class StatusManagerBean implements StatusManagerLocal {
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void updateByAutoBaselineCalculationJob() {
+ log.debug("About to mark status by autoBaselineCalculationJob");
// baselines refer to measurement-based alert conditions, thus only agent
statuses need to be set
Query updateAgentQuery =
entityManager.createNamedQuery(Agent.QUERY_UPDATE_STATUS_FOR_ALL);
updateAgentQuery.executeUpdate();
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerLocal.java
index 403f381..52ba90a 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StatusManagerLocal.java
@@ -30,6 +30,8 @@ public interface StatusManagerLocal {
List<Integer> getAndClearAgentsWithStatusForServer(String serverName);
+ void updateByResource(int resourceId);
+
void updateByAlertDefinition(int alertDefinitionId);
void updateByMeasurementBaseline(int baselineId);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/CacheConsistencyManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/CacheConsistencyManagerBean.java
index 166c504..4d2adee 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/CacheConsistencyManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/CacheConsistencyManagerBean.java
@@ -104,6 +104,9 @@ public class CacheConsistencyManagerBean implements
CacheConsistencyManagerLocal
try {
boolean hadServerStatus = serverManager.getAndClearServerStatus();
if (hadServerStatus == false) {
+ if (log.isDebugEnabled()) {
+ log.debug("Global cache does not need reloading");
+ }
return;
}
@@ -133,6 +136,9 @@ public class CacheConsistencyManagerBean implements
CacheConsistencyManagerLocal
// do nothing if nothing to do
if (agentIds.size() == 0) {
+ if (log.isDebugEnabled()) {
+ log.debug("No agent caches need reloading");
+ }
return;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java
index 8311ec2..cc2c565 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java
@@ -39,6 +39,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.cloud.PartitionEventType;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.communications.GlobalSuspendCommandListener;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
@@ -167,6 +168,15 @@ public class ServerManagerBean implements ServerManagerLocal {
return result;
}
+ public void printWithTrace(String message) {
+ try {
+ new IllegalArgumentException(message);
+ } catch (IllegalArgumentException iae) {
+ String stackTrace = ThrowableUtil.getStackAsString(iae);
+ LogFactory.getLog("HighAvailabilityLogic").fatal(stackTrace);
+ }
+ }
+
public void establishCurrentServerMode() {
Server server = getServer();
Server.OperationMode serverMode = server.getOperationMode();
@@ -179,6 +189,7 @@ public class ServerManagerBean implements ServerManagerLocal {
// for previously connected agents that did not fail-over while this server was
unavailable. This
// is done to avoid unnecessary cache re/load and moreover provides a logically
initialized environment.
if (null == lastEstablishedServerMode) {
+ printWithTrace("establishCurrentServerMode: NULL->" + serverMode
+ ", clearing agent references");
clearAgentReferences(server);
}
@@ -191,6 +202,7 @@ public class ServerManagerBean implements ServerManagerLocal {
// - out of MM without ever taking down the server
// 2) Re-establish server communication by taking away the MM listener
if (Server.OperationMode.MAINTENANCE == lastEstablishedServerMode) {
+ printWithTrace("establishCurrentServerMode:
MAINTENANCE->NORMAL, clearing agent references");
clearAgentReferences(server);
ServerCommunicationsServiceUtil.getService().safeGetServiceContainer().removeCommandListener(
commit 70fae154c410319e31fba8cf1753942a6b685ddb
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Apr 30 10:43:42 2010 -0400
fix the "Reload Caches" method on the "Alert Subsystem" MBean
component under the RHQ Server
* all emsBeans require calling refresh(), otherwise the remote method is not actually
invoked
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 e36e37f..e997ac1 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
@@ -195,7 +195,7 @@ public class AlertConditionCacheMonitor implements
AlertConditionCacheMonitorMBe
totalProcessingTime.addAndGet(moreMillis);
}
- public void getReloadCaches() {
+ 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 996a40f..6af167b 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
@@ -93,5 +93,5 @@ public interface AlertConditionCacheMonitorMBean {
/*
* cache contents
*/
- public void getReloadCaches();
+ public void reloadCaches();
}
\ No newline at end of file
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java
index 046c843..4b98c67 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java
@@ -85,6 +85,7 @@ public class CloudManagerBean implements CloudManagerLocal {
public List<Agent> getAgentsByServerName(String serverName) {
Server server = cloudManager.getServerByName(serverName);
List<Agent> agents = server.getAgents();
+ agents.size(); // iterating over this collection out of a transactional
boundaries will throw LazyInitExceptions
return agents;
}
diff --git
a/modules/plugins/rhq-server/src/main/java/org/rhq/plugins/server/AlertsCacheResourceComponent.java
b/modules/plugins/rhq-server/src/main/java/org/rhq/plugins/server/AlertsCacheResourceComponent.java
index 84c6b1a..f4c7aef 100644
---
a/modules/plugins/rhq-server/src/main/java/org/rhq/plugins/server/AlertsCacheResourceComponent.java
+++
b/modules/plugins/rhq-server/src/main/java/org/rhq/plugins/server/AlertsCacheResourceComponent.java
@@ -46,18 +46,18 @@ public class AlertsCacheResourceComponent extends
MBeanResourceComponent {
if ("reloadCaches".equals(name)) {
EmsBean emsBean = getEmsBean();
Map<String, Integer> before = (Map<String, Integer>)
emsBean.getAttribute("CacheCounts").refresh();
- emsBean.getAttribute("ReloadCaches"); // void return
+ emsBean.getOperation("reloadCaches").invoke(); // void return
Map<String, Integer> after = (Map<String, Integer>)
emsBean.getAttribute("CacheCounts").refresh();
OperationResult result = new OperationResult();
PropertyList statistics = new PropertyList("reloadStatistics");
result.getComplexResults().put(statistics);
for (String cacheName : before.keySet()) {
- PropertyMap stat = new PropertyMap("stat");
- stat.put(new PropertySimple("cacheName", cacheName));
- stat.put(new PropertySimple("beforeReloading",
before.get(cacheName)));
- stat.put(new PropertySimple("afterReloading",
after.get(cacheName)));
- statistics.add(stat);
+ PropertyMap stat = new PropertyMap("stat");
+ stat.put(new PropertySimple("cacheName", cacheName));
+ stat.put(new PropertySimple("beforeReloading",
before.get(cacheName)));
+ stat.put(new PropertySimple("afterReloading",
after.get(cacheName)));
+ statistics.add(stat);
}
return result;