Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Cluster ability like in quartz-1.0.2 #2

Closed

Description

@dtamm

In Quartz 1.0.2 for Grails 2.x, the Jobs can be clustered over several tomcat instances. For this ability, the Quartz plugin loaded in the QuartzGrailsPlugin.groovy in the "doWithSpring"-method

def doWithSpring = { context ->
    def config = loadQuartzConfig(application.config)
    ///...
}

via the "loadQuartzConfig"-method (which now is completely missing!) the following things:

/*
 * Load the various configs.
 * Order of priority has been "fixed" in 1.0-RC2 to be:
 *
 * 1. DefaultQuartzConfig is loaded
 * 2. App's Config.groovy is loaded in and overwrites anything from DQC
 * 3. QuartzConfig is loaded and overwrites anything from DQC or AppConfig
 * 4. quartz.properties are loaded into config as quartz._props
 */
private ConfigObject loadQuartzConfig(ConfigObject config) {
    def classLoader = new GroovyClassLoader(getClass().classLoader)
    String environment = Environment.current.name
    // Note here the order of objects when calling merge - merge OVERWRITES values in the target object
    // Load default Quartz config as a basis
    def newConfig = new ConfigSlurper(environment).parse(classLoader.loadClass('DefaultQuartzConfig'))
    // Overwrite defaults with what Config.groovy has supplied, perhaps from external files
    newConfig.merge(config)
    // Overwrite with contents of QuartzConfig
    try {
        newConfig.merge(new ConfigSlurper(environment).parse(classLoader.loadClass('QuartzConfig')))  //Which was located in grails-app/conf/
    } catch (Exception ignored) {
        // ignore, just use the defaults
    }
    // Now merge our correctly merged DefaultQuartzConfig and QuartzConfig into the main config
    config.merge(newConfig)
    // And now load quartz properties into main config
    def properties = new Properties()
    def resource = classLoader.getResourceAsStream("quartz.properties") //Which was located in grails-app/conf/quartz/
    if(resource != null) properties.load(resource)
    if(config.quartz.containsKey('props')) properties << config.quartz.props.toProperties('org.quartz')
    config.quartz._properties = properties
    return config.quartz
}

The grails-app/conf/quartz/quartz.properties did contain all needed information for the clustering ability:

org.quartz.scheduler.instanceName=app_quartz
org.quartz.scheduler.instanceId=AUTO
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=5
org.quartz.threadPool.threadPriority=5
org.quartz.jobStore.misfireThreshold=60000
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties=false
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.isClustered=true
org.quartz.jobStore.clusterCheckinInterval=1000
org.quartz.plugin.shutdownhook.class=org.quartz.plugins.management.ShutdownHookPlugin
org.quartz.plugin.shutdownhook.cleanShutdown=true 

With this config information, the plugin persisted all jobs from grails-app/jobs/* into the databse-tables, which were located in the grails-quartz/src/templates/sql/ folder, for setting up the tables in the db for each dbms. I am not sure, which methods beside the above described are needed to be implemented for the clustering features... but all i can say till now is, that the jobs are not persisted in the database till now, even though i put the QuartzConfig.groovy (or the equivalent DefaultQuartzConfig.groovy from grails-quartz/grails-app/conf/ folder) into the application.yml from my grails3 project and set the quartz.jdbcStore = true.

I hope these information is enough (for the moment) to resotre the clustering ability for grails3.

Activity

  1. graemerocher commented on Mar 9, 2015

    @graemerocher
    Member

    @jeffbrown Should still be possible via application.yml no?

  2. jeffscottbrown commented on Mar 9, 2015

    @jeffscottbrown
    Member

    @graemerocher Yes, still possible. It may be that the plugin isn't loading up those config settings in M2 of the plugin. I will look at it and get it addressed.

  3. dtamm commented on Mar 9, 2015

    @dtamm
    Author

    @jeffbrown thanks! just ring me up when i shall test a new version!

  4. dtamm commented on Mar 31, 2015

    @dtamm
    Author

    any updates on this one yet?

  5. jeffscottbrown commented on Mar 31, 2015

    @jeffscottbrown
    Member

    Not yet. It is still in the queue and will get addressed. If anyone is interested in putting a pull request together, that input would be welcomed. Otherwise I will get to it hopefully before too long.

    Thanks for the feedback. I appreciate it.

  6. robbugh commented on May 26, 2015

    @robbugh

    I created a pull request to address this issue. See: #5

    Regards,
    Rob

  7. dtamm commented on May 26, 2015

    @dtamm
    Author

    If the pullrequest gets accepted, i will test it out!

  8. dtamm commented on May 29, 2015

    @dtamm
    Author

    nevermind, i just had some properties wrong, but now i get the error, that the DataSource name is not set:

    ERROR grails.boot.GrailsApp - Application startup failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean wit
    h name 'quartzScheduler': Invocation of init method failed; nested exception is
    org.quartz.SchedulerConfigException: DataSource name not set.
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
    an(AbstractBeanFactory.java:299) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) ~[spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
            at grails.boot.GrailsApp.run(GrailsApp.groovy:49) [grails-core-3.0.1.jar!/:3.0.1]
            at grails.boot.GrailsApp.run(GrailsApp.groovy:254) [grails-core-3.0.1.jar!/:3.0.1]
            at grails.boot.GrailsApp.run(GrailsApp.groovy:243) [grails-core-3.0.1.jar!/:3.0.1]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_25]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_25]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_25]
            at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) [groovy-2.4.3.jar!/:2.4.3]
            at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) [groovy-2.4.3.jar!/:2.4.3]
            at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43) [groovy-2.4.3.jar!/:2.4.3]
            at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88) [groovy-2.4.3.jar!/:2.4.3]
            at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) [groovy-2.4.3.jar!/:2.4.3]
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110) [groovy-2.4.3.jar!/:2.4.3]
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122) [groovy-2.4.3.jar!/:2.4.3]
            at quartztest.Application.main(Application.groovy:8) [quartztest-0.1.jar!/:na]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_25]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_25]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_25]
            at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) [quartztest-0.1.jar!/:na]
            at java.lang.Thread.run(Unknown Source) [na:1.8.0_25]
    Caused by: org.quartz.SchedulerConfigException: DataSource name not set.
            at org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize(JobStoreSupport.java:638) ~[quartz-2.2.1.jar!/:na]
            at org.quartz.impl.jdbcjobstore.JobStoreTX.initialize(JobStoreTX.java:57) ~[quartz-2.2.1.jar!/:na]
            at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1333) ~[quartz-2.2.1.jar!/:na]
            at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1519) ~[quartz-2.2.1.jar!/:na]
            at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler(SchedulerFactoryBean.java:597) ~[spring-context-support-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:480) ~[spring-context-support-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
            ... 33 common frames omitted
    java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
    .java:53)
            at java.lang.Thread.run(Unknown Source)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
    ng bean with name 'quartzScheduler': Invocation of init method failed; nested ex
    ception is org.quartz.SchedulerConfigException: DataSource name not set.
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
            at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
            at grails.boot.GrailsApp.run(GrailsApp.groovy:49)
            at grails.boot.GrailsApp.run(GrailsApp.groovy:254)
            at grails.boot.GrailsApp.run(GrailsApp.groovy:243)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
            at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
            at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)
            at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
            at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
            at quartztest.Application.main(Application.groovy:8)        ... 6 more
    Caused by: org.quartz.SchedulerConfigException: DataSource name not set.
            at org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize(JobStoreSupport.java:638)
            at org.quartz.impl.jdbcjobstore.JobStoreTX.initialize(JobStoreTX.java:57)
            at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1333)
            at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1519)
            at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler(SchedulerFactoryBean.java:597)
            at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:480)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
            ... 33 more
    
  9. added a commit that references this issue on May 29, 2015
  10. dtamm commented on May 29, 2015

    @dtamm
    Author

    Okay, i got it fixed and will do a pullrequest later!

  11. dtamm commented on May 29, 2015

    @dtamm
    Author

    Made a PR #6

  12. dtamm commented on Jun 2, 2015

    @dtamm
    Author

    For my understandings, this ticket can be closed as fixed... tried myself a grails3 app on 2 tomcats with this plugin, worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions