From: <isp...@rh...> - 2009-10-20 17:31:38
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [5258] when updating metric schedules, if pushing the updated schedules to the Agents fails, throw an Exception, rather than just touching the mtime on the corresponding Resources; ***NOTE*** THIS IS A SPECIAL FIX FOR THIS BRANCH ONLY AND SHOULD NOT BE MERGED INTO TRUNK (http://jira.rhq-project.org/browse/RHQ-1996)</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>5258</dd> <dt>Author</dt> <dd>ispringer</dd> <dt>Date</dt> <dd>2009-10-20 12:31:23 -0500 (Tue, 20 Oct 2009)</dd> </dl> <h3>Log Message</h3> <pre>when updating metric schedules, if pushing the updated schedules to the Agents fails, throw an Exception, rather than just touching the mtime on the corresponding Resources; ***NOTE*** THIS IS A SPECIAL FIX FOR THIS BRANCH ONLY AND SHOULD NOT BE MERGED INTO TRUNK (http://jira.rhq-project.org/browse/RHQ-1996)</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqbranchesRHQ_1_2_0_GA_PERFmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseservermeasurementMeasurementScheduleManagerBeanjava">rhq/branches/RHQ_1_2_0_GA_PERF/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqbranchesRHQ_1_2_0_GA_PERFmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseservermeasurementMeasurementScheduleManagerBeanjava"></a> <div class="modfile"><h4>Modified: rhq/branches/RHQ_1_2_0_GA_PERF/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java (5257 => 5258)</h4> <pre class="diff"> <span class="info">--- rhq/branches/RHQ_1_2_0_GA_PERF/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java 2009-10-20 14:24:59 UTC (rev 5257) +++ rhq/branches/RHQ_1_2_0_GA_PERF/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java 2009-10-20 17:31:23 UTC (rev 5258) </span><span class="lines">@@ -568,6 +568,15 @@ </span><span class="cx"> } public void disableMeasurementSchedules(Subject subject, int[] measurementDefinitionIds, int resourceId) { </span><span class="add">+ if (!disableMeasurementSchedulesInternal(subject, measurementDefinitionIds, resourceId)) { + Resource resource = resourceManager.getResourceById(subject, resourceId); + Set<Resource> failedSyncResources = new HashSet<Resource>(); + failedSyncResources.add(resource); + handleFailedSyncResources(failedSyncResources); + } + } + + private boolean disableMeasurementSchedulesInternal(Subject subject, int[] measurementDefinitionIds, int resourceId) { </span><span class="cx"> Resource resource = resourceManager.getResourceById(subject, resourceId); if (!authorizationManager.hasResourcePermission(subject, Permission.MANAGE_MEASUREMENTS, resourceId)) { throw new PermissionException("You do not have permission to change resource [" + resource </span><span class="lines">@@ -592,7 +601,7 @@ </span><span class="cx"> } entityManager.merge(resource); </span><span class="rem">- return; </span><span class="add">+ return synced; </span><span class="cx"> } @RequiredPermissions( { @RequiredPermission(Permission.MANAGE_INVENTORY), </span><span class="lines">@@ -704,18 +713,24 @@ </span><span class="cx"> // convert the int[] to Integer[], incase we need to set List<Integer> measurementDefinitionList = convertIntArrayToListOfIntegers(measurementDefinitionIds); // send schedule updates to agents </span><span class="add">+ Set<Agent> downAgents = new HashSet<Agent>(); </span><span class="cx"> for (Map.Entry<Agent, Set<ResourceMeasurementScheduleRequest>> agentEntry : agentUpdates.entrySet()) { </span><span class="rem">- boolean synced = sendUpdatedSchedulesToAgent(agentEntry.getKey(), agentEntry.getValue()); </span><span class="add">+ Agent agent = agentEntry.getKey(); + boolean synced = sendUpdatedSchedulesToAgent(agent, agentEntry.getValue()); </span><span class="cx"> if (!synced) { /* * only sync resources that are affected by this set of definitions that were updated, and only * for the agent that couldn't be contacted (under the assumption that 9 times out of 10 the agent * will be up; so, we don't want to unnecessarily mark more resources as needing syncing that don't </span><span class="rem">- */ - int agentId = agentEntry.getKey().getId(); - setAgentSynchronizationNeededByDefinitionsForAgent(agentId, measurementDefinitionList); </span><span class="add">+ */ + setAgentSynchronizationNeededByDefinitionsForAgent(agent.getId(), measurementDefinitionList); + downAgents.add(agent); </span><span class="cx"> } } </span><span class="add">+ if (!downAgents.isEmpty()) { + throw new RuntimeException("Failed to push updated schedules to Agents " + downAgents + + " - please make sure these Agents are started and reachable, then try again."); + } </span><span class="cx"> } } </span><span class="lines">@@ -737,6 +752,16 @@ </span><span class="cx"> public void updateMeasurementSchedules(Subject subject, int[] measurementDefinitionIds, int resourceId, long collectionInterval) { </span><span class="add">+ if (!updateMeasurementSchedulesInternal(subject, measurementDefinitionIds, resourceId, collectionInterval)) { + Resource resource = resourceManager.getResourceById(subject, resourceId); + Set<Resource> failedSyncResources = new HashSet<Resource>(); + failedSyncResources.add(resource); + handleFailedSyncResources(failedSyncResources); + } + } + + public boolean updateMeasurementSchedulesInternal(Subject subject, int[] measurementDefinitionIds, int resourceId, + long collectionInterval) { </span><span class="cx"> collectionInterval = verifyMinimumCollectionInterval(collectionInterval); Resource resource = resourceManager.getResourceById(subject, resourceId); if (!authorizationManager.hasResourcePermission(subject, Permission.MANAGE_MEASUREMENTS, resourceId)) { </span><span class="lines">@@ -763,7 +788,7 @@ </span><span class="cx"> } entityManager.merge(resource); </span><span class="rem">- return; </span><span class="add">+ return synced; </span><span class="cx"> } /** </span><span class="lines">@@ -785,9 +810,14 @@ </span><span class="cx"> // don't verify minimum collection interval here, it will be caught by updateMeasurementSchedules callee List<Resource> resources = resourceGroupManager.getResourcesForAutoGroup(subject, parentResourceId, childResourceType); </span><span class="add">+ + Set<Resource> failedSyncResources = new HashSet<Resource>(); </span><span class="cx"> for (Resource resource : resources) { </span><span class="rem">- updateMeasurementSchedules(subject, measurementDefinitionIds, resource.getId(), collectionInterval); </span><span class="add">+ if (!updateMeasurementSchedulesInternal(subject, measurementDefinitionIds, resource.getId(), collectionInterval)) { + failedSyncResources.add(resource); + } </span><span class="cx"> } </span><span class="add">+ handleFailedSyncResources(failedSyncResources); </span><span class="cx"> } /** </span><span class="lines">@@ -809,9 +839,13 @@ </span><span class="cx"> ResourceGroup group = resourceGroupManager.getResourceGroupById(subject, groupId, GroupCategory.COMPATIBLE); Set<Resource> resources = group.getExplicitResources(); </span><span class="add">+ Set<Resource> failedSyncResources = new HashSet<Resource>(); </span><span class="cx"> for (Resource resource : resources) { </span><span class="rem">- updateMeasurementSchedules(subject, measurementDefinitionIds, resource.getId(), collectionInterval); </span><span class="add">+ if (!updateMeasurementSchedulesInternal(subject, measurementDefinitionIds, resource.getId(), collectionInterval)) { + failedSyncResources.add(resource); + } </span><span class="cx"> } </span><span class="add">+ handleFailedSyncResources(failedSyncResources); </span><span class="cx"> } /** </span><span class="lines">@@ -821,9 +855,13 @@ </span><span class="cx"> ResourceGroup group = resourceGroupManager.getResourceGroupById(subject, groupId, GroupCategory.COMPATIBLE); Set<Resource> resources = group.getExplicitResources(); </span><span class="add">+ Set<Resource> failedSyncResources = new HashSet<Resource>(); </span><span class="cx"> for (Resource resource : resources) { </span><span class="rem">- disableMeasurementSchedules(subject, measurementDefinitionIds, resource.getId()); - } </span><span class="add">+ if (!disableMeasurementSchedulesInternal(subject, measurementDefinitionIds, resource.getId())) { + failedSyncResources.add(resource); + } + } + handleFailedSyncResources(failedSyncResources); </span><span class="cx"> } /** </span><span class="lines">@@ -838,9 +876,14 @@ </span><span class="cx"> int parentResourceId, int childResourceType) { List<Resource> resources = resourceGroupManager.getResourcesForAutoGroup(subject, parentResourceId, childResourceType); </span><span class="add">+ + Set<Resource> failedSyncResources = new HashSet<Resource>(); </span><span class="cx"> for (Resource resource : resources) { </span><span class="rem">- disableMeasurementSchedules(subject, measurementDefinitionIds, resource.getId()); </span><span class="add">+ if (!disableMeasurementSchedulesInternal(subject, measurementDefinitionIds, resource.getId())) { + failedSyncResources.add(resource); + } </span><span class="cx"> } </span><span class="add">+ handleFailedSyncResources(failedSyncResources); </span><span class="cx"> } /** </span><span class="lines">@@ -1226,4 +1269,15 @@ </span><span class="cx"> } } } </span><span class="add">+ + private void handleFailedSyncResources(Set<Resource> failedSyncResources) { + if (!failedSyncResources.isEmpty()) { + Set<Agent> downAgents = new HashSet<Agent>(); + for (Resource failedSyncResource : failedSyncResources) { + downAgents.add(failedSyncResource.getAgent()); + } + throw new RuntimeException("Failed to push updated schedules to Agents for Resources " + failedSyncResources + + " - no response from Agents " + downAgents + " - please make sure these Agents are started and reachable, then try again."); + } + } </span><span class="cx"> } \ No newline at end of file </span> </pre> </div> </div> </body> </html> |