if (resourceConfigUpdate.getStatus() == ConfigurationUpdateStatus.INPROGRESS) {
// If this update isn't done, then, by definition, the group update isn't done either.
return;
}
GroupResourceConfigurationUpdate groupConfigUpdate = resourceConfigUpdate.getGroupConfigurationUpdate();
if (groupConfigUpdate == null) {
// The update isn't part of a group update - nothing we need to do.
return;
}
Query inProgressResourcesCountQuery = PersistenceUtility.createCountQuery(this.entityManager,
ResourceConfigurationUpdate.QUERY_FIND_BY_PARENT_UPDATE_ID_AND_STATUS);
inProgressResourcesCountQuery.setParameter("parentUpdateId", groupConfigUpdate.getId());
inProgressResourcesCountQuery.setParameter("status", ConfigurationUpdateStatus.INPROGRESS);
long inProgressResourcesCount = (Long) inProgressResourcesCountQuery.getSingleResult();
if (inProgressResourcesCount == 0) {
// No more member updates in progress - the group update is complete.
Query failedResourcesQuery = this.entityManager
.createNamedQuery(ResourceConfigurationUpdate.QUERY_FIND_BY_PARENT_UPDATE_ID_AND_STATUS);
failedResourcesQuery.setParameter("parentUpdateId", groupConfigUpdate.getId());
failedResourcesQuery.setParameter("status", ConfigurationUpdateStatus.FAILURE);
List<Resource> failedResources = failedResourcesQuery.getResultList();
ConfigurationUpdateStatus groupStatus;
if (failedResources.isEmpty()) {
groupStatus = ConfigurationUpdateStatus.SUCCESS;
} else {
groupStatus = ConfigurationUpdateStatus.FAILURE;
groupConfigUpdate.setErrorMessage("The following Resources failed to update their Configurations: "
+ failedResources);
}
groupConfigUpdate.setStatus(groupStatus);
LOG.info("Group Resource configuration update [" + groupConfigUpdate.getId() + "] for "
+ groupConfigUpdate.getGroup() + " has completed with status [" + groupStatus + "].");
// TODO: Add support for alerting on completion of group resource config updates.
//notifyAlertConditionCacheManager("checkForCompletedGroupResourceConfigurationUpdate", groupUpdate);
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Group Resource configuration update [" + groupConfigUpdate.getId() + "] for "
+ groupConfigUpdate.getGroup() + " has " + inProgressResourcesCount
+ " member updates still in progress.");
}
}
return;
}