Source:
<code>public void handleConfigurationChanged() { final Map<String, List<RemotePolledService>> servicesByPackage = new HashMap<>(); try { this.pollerConfig.update(); } catch (IOException e) { LOG.warn("Error reloading poller-configuration.xml"); } LOG.info("Re-scheduling all services..."); sessionUtils.withReadOnlyTransaction(() -> { for (final OnmsMonitoringLocation loc : monitoringLocationDao.findAll()) { final List<String> pollingPackageNames = loc.getPollingPackageNames(); LOG.debug("Location '{}' has polling packages: {}", loc.getLocationName(), pollingPackageNames); final Set<RemotePolledService> servicesToBeScheduled = new HashSet<>(); <START> for (final String pollingPackageName : pollingPackageNames) { <END> final List<RemotePolledService> servicesForPackage = servicesByPackage.computeIfAbsent(pollingPackageName, (pkgName) -> { final Package pkg = pollerConfig.getPackage(pollingPackageName); if (pkg == null) { LOG.warn("Polling package '{}' is associated with location '{}', but the package was not found." + " Using an empty set of services.", pollingPackageName, loc.getLocationName()); return Collections.emptyList(); } return getServicesForPackage(pkg); }); servicesToBeScheduled.addAll(servicesForPackage); } final Map<JobKey, RemotePolledService> mapOfScheduledServices = getMapOfScheduledServices(loc.getLocationName()); final Set<RemotePolledService> scheduledServices = mapOfScheduledServices.entrySet().stream().map(e -> e.getValue()).collect(Collectors.toSet()); for (final Map.Entry<JobKey, RemotePolledService> entry : mapOfScheduledServices.entrySet()) { if (!servicesToBeScheduled.contains(entry.getValue())) { try { scheduler.deleteJob(entry.getKey()); } catch (SchedulerException e) { LOG.warn("Failed to delete job for service {}.", entry.getKey(), entry.getValue(), e); } } } for (final RemotePolledService polledService : servicesToBeScheduled) { if (!scheduledServices.contains(polledService)) { try { scheduleService(loc.getLocationName(), polledService); } catch (SchedulerException e) { LOG.warn("Failed to schedule {}.", polledService, e); } } } } return null; }); }</code><technical_language>This is basically a duplicate of code in {{scheduleAllServices}}. deduplicate this</technical_language>

Target:
public void handleConfigurationChanged() { final Map<String, List<RemotePolledService>> servicesByPackage = new HashMap<>(); try { this.pollerConfig.update(); } catch (IOException e) { LOG.warn("Error reloading poller-configuration.xml"); } LOG.info("Re-scheduling all services..."); sessionUtils.withReadOnlyTransaction(() -> { for (final OnmsMonitoringLocation location : monitoringLocationDao.findAll()) { final List<String> pollingPackageNames = location.getPollingPackageNames(); LOG.debug("Location '{}' has polling packages: {}", location.getLocationName(), pollingPackageNames); final Set<RemotePolledService> servicesToBeScheduled = new HashSet<>(); for (final String pollingPackageName : pollingPackageNames) { servicesToBeScheduled.addAll(servicesByPackage.computeIfAbsent(pollingPackageName, (pkgName) -> getServicesForPackage(location, pkgName))); } final Map<JobKey, RemotePolledService> mapOfScheduledServices = getMapOfScheduledServices(location.getLocationName()); final Set<RemotePolledService> scheduledServices = mapOfScheduledServices.entrySet().stream().map(e -> e.getValue()).collect(Collectors.toSet()); for (final Map.Entry<JobKey, RemotePolledService> entry : mapOfScheduledServices.entrySet()) { if (!servicesToBeScheduled.contains(entry.getValue())) { try { scheduler.deleteJob(entry.getKey()); } catch (SchedulerException e) { LOG.warn("Failed to delete job for service {}.", entry.getKey(), entry.getValue(), e); } } } for (final RemotePolledService polledService : servicesToBeScheduled) { if (!scheduledServices.contains(polledService)) { try { scheduleService(location.getLocationName(), polledService); } catch (SchedulerException e) { LOG.warn("Failed to schedule {}.", polledService, e); } } } } return null; }); }