Repository: syncope Updated Branches: refs/heads/1_2_X 188b937d6 -> 7c337d226
[SYNCOPE-1103] Option to put Quartz scheduler in standby, from persistence.properties Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/7c337d22 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/7c337d22 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/7c337d22 Branch: refs/heads/1_2_X Commit: 7c337d2269da8484f3bf081ca968bae261c654c2 Parents: 188b937 Author: Francesco Chicchiriccò <ilgro...@apache.org> Authored: Tue Jun 6 11:42:28 2017 +0200 Committer: Francesco Chicchiriccò <ilgro...@apache.org> Committed: Tue Jun 6 11:42:28 2017 +0200 ---------------------------------------------------------------------- .../syncope/core/init/JobInstanceLoader.java | 22 +++++++++++++++++--- core/src/main/resources/persistence.properties | 1 + core/src/main/resources/schedulingContext.xml | 3 +++ 3 files changed, 23 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/7c337d22/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java b/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java index 27f0579..7544e6c 100644 --- a/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java +++ b/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java @@ -56,10 +56,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Component public class JobInstanceLoader { private static final Logger LOG = LoggerFactory.getLogger(JobInstanceLoader.class); @@ -76,6 +74,12 @@ public class JobInstanceLoader { @Autowired private ConfDAO confDAO; + private boolean disableQuartzInstance; + + public void setDisableQuartzInstance(final boolean disableQuartzInstance) { + this.disableQuartzInstance = disableQuartzInstance; + } + private static Long getIdFromJobName(final String name, final String pattern, final int prefixLength) { Long result = null; @@ -180,7 +184,7 @@ public class JobInstanceLoader { final AbstractSyncActions<?> syncActions = (AbstractSyncActions<?>) ApplicationContextProvider.getBeanFactory(). - createBean(actionsClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, true); + createBean(actionsClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, true); actions.add(syncActions); } catch (Exception e) { @@ -247,6 +251,18 @@ public class JobInstanceLoader { @Transactional public void load() { + if (disableQuartzInstance) { + String instanceId = "AUTO"; + try { + instanceId = scheduler.getScheduler().getSchedulerInstanceId(); + scheduler.getScheduler().standby(); + + LOG.info("Successfully put Quartz instance {} in standby", instanceId); + } catch (SchedulerException e) { + LOG.error("Could not put Quartz instance {} in standby", instanceId, e); + } + } + // 1. jobs for SchedTasks Set<SchedTask> tasks = new HashSet<SchedTask>(taskDAO.findAll(SchedTask.class)); tasks.addAll(taskDAO.findAll(SyncTask.class)); http://git-wip-us.apache.org/repos/asf/syncope/blob/7c337d22/core/src/main/resources/persistence.properties ---------------------------------------------------------------------- diff --git a/core/src/main/resources/persistence.properties b/core/src/main/resources/persistence.properties index a737b93..216777d 100644 --- a/core/src/main/resources/persistence.properties +++ b/core/src/main/resources/persistence.properties @@ -23,5 +23,6 @@ jpa.pool.validationQuery=SELECT 1 #note: other connection pool settings can also be configured here, see persistenceContext.xml quartz.jobstore=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate quartz.sql=tables_postgres.sql +quartz.disableInstance=false audit.sql=audit.sql database.schema= \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/7c337d22/core/src/main/resources/schedulingContext.xml ---------------------------------------------------------------------- diff --git a/core/src/main/resources/schedulingContext.xml b/core/src/main/resources/schedulingContext.xml index 295f8f4..9f28f5e 100644 --- a/core/src/main/resources/schedulingContext.xml +++ b/core/src/main/resources/schedulingContext.xml @@ -49,6 +49,9 @@ under the License. </props> </property> </bean> + <bean class="org.apache.syncope.core.init.JobInstanceLoader"> + <property name="disableQuartzInstance" value="${quartz.disableInstance:false}"/> + </bean> <bean id="notificationJob" class="org.apache.syncope.core.notification.NotificationJob"/> </beans>