/** @see ConfigChangeListener#configChanged() */ @Override public void configChanged() { logger.info("Received configuration change notification."); if (!headServer.getConfig().equals(flowServiceConfig.getHeadConfig())) { MeandreServerProxy newHead; try { newHead = meandreServerProxyFactory.getServerProxyInstance( flowServiceConfig.getHeadConfig(), true); } catch (MeandreServerException e) { throw new RuntimeException("Could not instantiate head server.", e); } meandreServerProxyFactory.release(headServer); headServer = newHead; logger.info( "Head server configuration has changed. New head " + "server is " + headServer.toString()); } else { logger.info("Head server has not changed."); } jobScheduler.setWorkerConfigs(flowServiceConfig.getWorkerConfigs()); }
@PostConstruct public void init() { logger.info("Initializing NEMA Flow Service..."); notificationCreator = new JobStatusNotificationCreator(daoFactory); try { headServer = meandreServerProxyFactory.getServerProxyInstance(flowServiceConfig.getHeadConfig(), true); } catch (MeandreServerException e) { throw new RuntimeException("Could not instantiate head server.", e); } flowServiceConfig.addChangeListener(this); // Any jobs marked as scheduled in the database will be put back in the // queue for execution. JobDao jobDao = daoFactory.getJobDao(); List<Job> scheduledJobs; try { Session session = jobDao.getSessionFactory().openSession(); jobDao.startManagedSession(session); scheduledJobs = jobDao.getJobsByStatus(Job.JobStatus.SCHEDULED); jobDao.endManagedSession(); session.close(); } catch (HibernateException e) { throw new RuntimeException("Problem searching for scheduled jobs" + " in the database.", e); } if (scheduledJobs != null && scheduledJobs.size() > 0) { logger.info( scheduledJobs.size() + " scheduled jobs found in the " + "database. Jobs will be rescheduled for execution."); } for (Job job : scheduledJobs) { jobScheduler.scheduleJob(job); jobStatusMonitor.start(job, notificationCreator); } }