@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(); /* * this is informational debugging only - do NOT change the status bits here */ if (log.isDebugEnabled()) { Agent agent = entityManager.find(Agent.class, agentId); log.debug("Marking status, agent[id=" + agent.getId() + ", status=" + agent.getStatus() + "]"); } }
@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(); /* * this is informational debugging only - do NOT change the status bits here */ if (log.isDebugEnabled()) { List<Agent> agents = agentManager.getAllAgents(); for (Agent agent : agents) { log.debug("Marking status, agent[id=" + agent.getId() + ", status=" + agent.getStatus() + "] for AutoBaselineCalculationJob"); } } } }
@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); updateAgentQuery.executeUpdate(); /* * this is informational debugging only - do NOT change the status bits here */ if (log.isDebugEnabled()) { MeasurementBaseline baseline = entityManager.find(MeasurementBaseline.class, baselineId); Agent agent = baseline.getSchedule().getResource().getAgent(); log.debug("Marking status, agent[id=" + agent.getId() + ", status=" + agent.getStatus() + "] for measurementBaseline[id=" + baselineId + "]"); } }
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void updateByResource(Subject subject, 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(); // use local references to execute in the same transaction 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(LookupUtil.getSubjectManager().getOverlord(), 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(Subject subject, int 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; } /* * 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(); // use local references to execute in the same transaction Query updateAgentQuery = entityManager.createNamedQuery(Agent.QUERY_UPDATE_STATUS_BY_ALERT_DEFINITION); updateAgentQuery.setParameter("alertDefinitionId", alertDefinitionId); int agentsUpdated = updateAgentQuery.executeUpdate(); /* * this is informational debugging only - do NOT change the status bits here */ if (log.isDebugEnabled()) { AlertDefinition definition = entityManager.find(AlertDefinition.class, alertDefinitionId); Agent agent = agentManager.getAgentByResourceId(LookupUtil.getSubjectManager().getOverlord(), definition .getResource().getId()); log.debug("Marking status, agent[id=" + agent.getId() + ", status=" + agent.getStatus() + "] for alertDefinition[id=" + alertDefinitionId + "]"); log.debug("Agents updated: " + agentsUpdated); } }