}
}
private void unscheduleJobs(Subject overlord, Integer resourceId) throws ResourceNotFoundException {
log.debug("Unscheduling jobs for resource[id=" + resourceId + "]");
OperationManagerLocal operationManager = LookupUtil.getOperationManager();
try {
List<ResourceOperationSchedule> schedules = operationManager.findScheduledResourceOperations(overlord,
resourceId);
for (ResourceOperationSchedule schedule : schedules) {
try {
/*
* unscheduleResourceOperation already takes care of ignoring requests to delete unknown schedules,
* which would happen if the following sequence occurs:
*
* - a user tries to delete a resource, gets the list of resource operation schedules - just then,
* one or more of the schedules completes it's last scheduled firing, and is removed - then we try
* to unschedule it here, except that the jobid will no longer be known
*/
operationManager.unscheduleResourceOperation(overlord, schedule.getJobId().toString(), resourceId);
} catch (UnscheduleException ise) {
log.warn("Failed to unschedule job [" + schedule + "] for a resource being deleted [" + resourceId
+ "]", ise);
}
}