try {
updateId = configurationManager.createGroupConfigurationUpdate(groupUpdate);
} catch (SchedulerException sche) {
String message = "Error scheduling resource configuration update for group[id=" + group.getId() + "]";
LOG.error(message, sche);
throw new ResourceGroupUpdateException(message + ": " + sche);
}
// Create and persist updates for each of the members.
for (Integer resourceId : newResourceConfigurationMap.keySet()) {
Configuration memberResourceConfiguration = newResourceConfigurationMap.get(resourceId);
// Make sure to unmask the configuration before persisting the update.
Resource resource = resourceManager.getResource(subjectManager.getOverlord(), resourceId);
Configuration existingResourceConfiguration = resource.getResourceConfiguration();
ConfigurationMaskingUtility.unmaskConfiguration(memberResourceConfiguration, existingResourceConfiguration);
Resource flyWeight = new Resource(resourceId);
ResourceConfigurationUpdate memberUpdate = new ResourceConfigurationUpdate(flyWeight,
memberResourceConfiguration, subject.getName());
memberUpdate.setGroupConfigurationUpdate(groupUpdate);
entityManager.persist(memberUpdate);
}
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.putAsString(AbstractGroupConfigurationUpdateJob.DATAMAP_INT_CONFIG_GROUP_UPDATE_ID, updateId);
jobDataMap.putAsString(AbstractGroupConfigurationUpdateJob.DATAMAP_INT_SUBJECT_ID, subject.getId());
/*
* Acquire Quartz objects and schedule the group update, but defer the execution for 10 seconds,
* because we need this transaction to complete so that the data is available when the Quartz job triggers.
*/
JobDetail jobDetail = GroupResourceConfigurationUpdateJob.getJobDetail(group, subject, jobDataMap);
Trigger trigger = QuartzUtil.getFireOnceOffsetTrigger(jobDetail, 10000);
try {
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
String message = "Error scheduling job named '" + jobDetail.getName() + "':";
LOG.error(message, e);
throw new ResourceGroupUpdateException(message + e.getMessage());
}
if (LOG.isDebugEnabled()) {
LOG.debug("Scheduled Resource configuration update against compatible ResourceGroup[id="
+ compatibleGroupId + "].");