Giter Site home page Giter Site logo

knowm / sundial Goto Github PK

View Code? Open in Web Editor NEW
266.0 14.0 53.0 3.2 MB

A Light-weight Job Scheduling Framework

Home Page: http://knowm.org/open-source/sundial/

License: Apache License 2.0

Java 100.00%
java cron scheduler trigger scheduled-jobs quartz

sundial's People

Contributors

catull avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar franknozly avatar ikr avatar jkandasa avatar jlleitschuh avatar jonas-lindholm avatar ligasgr avatar micke-a avatar msmerc avatar reftel avatar ricardojlrufino avatar timmolter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sundial's Issues

Scheduler cannot load all annotated job classes from multiple locations

Hi,
This issue is related or a duplicate of #36
When the package to scan for annotated classes exists in multiple locations (e.g. two source roots: main and test going to separate output directories but both ending up on the classpath or a main and additional jar) then only one of those locations will be picked up and scanned.

The solution would seem to be to either modify existing method
https://github.com/knowm/Sundial/blob/develop/src/main/java/org/quartz/classloading/ClassLoadHelper.java -> URL getResource(String name); or add a new one that would allow multiple resource locations URL[] getResource(String name); and use it for finding package locations to iterate over in: https://github.com/knowm/Sundial/blob/develop/src/main/java/org/knowm/sundial/plugins/AnnotationJobTriggerPlugin.java -> public Set<Class<? extends Job>> getJobClasses(String pkgname)

Please let me know if you would have some time to look into that in near future and if not then I can try to submit a PR.

Ineffective JobInterruptException

Form a simple discovery test, I've created a Job managed programmatically because I aim at having a console to drive execution batchs by users.

Then in main:

        // Manage my job programmatically
        SundialJobScheduler.addJob( HelloJob.jobName(), HelloJob.class.getName());
        // Run my job every 2 seconds and unlimitedly
        SundialJobScheduler.addSimpleTrigger( 
                HelloJob.jobName() + "-Trigger", HelloJob.jobName(), -1, TimeUnit.SECONDS.toMillis(2));

In HelloJob.java:

  @Override
   public void doRun() throws JobInterruptException {
       
       System.out.println( String.format( "Hello Job %d at [%s]", ++count, DF.format( new Date())));
       if ( count >= 3 ) {
           System.out.println( "interrupted by itself");
           //SundialJobScheduler.removeTrigger( jobName() + "-Trigger");
           //SundialJobScheduler.stopJob( jobName()); // ineffective call
           throw new JobInterruptException(); // ineffective
       }
   }

Throwing JobInterruptException was hoping to trigger some behavior at monitor level, but nothing happened. Just wonder the utility of this exception then...

Configure DB backed JobStore?

Hello

Curious if Sundial permits us to configure a DB backed JobStore to maintain job state. I can't seem to find docs on whether this is possible or not.

Create an object and then give it to Sundial to run.

We would like to be able to create an object and then give it to Sundial to run. Currently we can only give it the class name and such but we are using Guice and need to use the Guice object. It would be great to have

MyObject mo = new MyObject("yes");//I can set the object up here...
SundialJobScheduler.addJob(name, mo, m, false);

And of course MyObject would extend Job...

Injecting an object to a Sundial Job

I am scheduling a job using Sundial to invoke an external API using HTTP client. I would like to use the underlying dropwizard to manage the httpclient module. Kindly help me out with how to inject the http object to the job.

Nice to have option to add triggers with priority

Sundial has only methods to add trigger to a job. however it assumes default priority for every trigger. Adding a trigger with priority to job would be useful. It is very essential for my project.

My use case follows.
An object has 4 states active, running, waiting, expired.
Active and running state events may be fired at same time.
running state must follow after active state.
but with out trigger priority, it is possible that running state event gets fired before active state event.

Run a single job explicitly / stay alive until finished

Hello,

I've successfully used Sundial to run my cron jobs.
Now I'm trying to add a CLI switch to my application to run a single job and then exit. I struggle with this.

How can I get the scheduler up and running and just submit a single job without it executing my jobs.xml? I tried to

SundialJobScheduler.createScheduler(1);
SundialJobScheduler.addJob("whatever", MyJob.class);
SundialJobScheduler.startJob("whatever");

but that doesn't seem to do anything. So I came up with this:

SundialJobScheduler.startScheduler(1, "my.jobs.package");
SundialJobScheduler.addJob("whatever", MyJob.class);
SundialJobScheduler.startJob("whatever");

which hopefully just runs the job I told it to run. But I then have issues to keep the application alive until the job is finished.

I deadlock the app for my cron jobs with:

        try {
            Object lock = new Object();
            synchronized (lock) {
                while (true) {
                    lock.wait();
                }
            }
        }
        catch (InterruptedException ex) {
            LOGGER.info("Caught ^c, shutting down.");
        }

but that's not a solution for the new use case. I thus tried to wait for the job to finish via

            try {
                while (SundialJobScheduler.isJobRunning("whatever")) {
                    LOGGER.debug("job still running");
                    Thread.sleep(2000);
                }
                LOGGER.debug("job finished");
            }
            catch (InterruptedException | SundialSchedulerException e) {
                LOGGER.error("Error in job?", e);
            }

but this, too, exits before the job is actually finished.

Is there a simple solution that I missed?

It appears that we cannot a delete a job from the scheduler

Hi,
First of all this is a great project very helpful. Thanks for putting this together.

I have a bug to report. It appears that once we add a job to the scheduler we cannot delete the same. I see that there are API's in quartz to delete a job from the scheduler.

Thanks,
Mahesh

Support for custom implementation of JobFactory

It would be nice to be able to implement a custom JobFactory to be used instead of SimpleJobFactory. The SimpleJobFactory is insansiated in QuartzScheduler and quite hard to override.
What about:

  1. adding a new constructor in QuartzScheduler with a JobFactory
  2. adding JobFactory as a parameter to SchedulerFactory.instantiate()
  3. and to SchedulerFactory.getScheduler()
  4. and finally to SundialJobScheduler.createScheduler()
    Or is there an easier way?

ExecutorService as thread pool

Please add a method createScheduler(ExecutorService executorService); because I want to reuse my threadpoolexecutor instead of creating a new one.

SundialJobScheduler.stopJob does not actually interrupt threads

The documentation for SundialJobScheduler.stopJob states:

Triggers a Job interrupt on all Jobs matching the given Job Name

However, is a job is running and is blocked in e.g. a call to Object.wait, then the job just sits there. It does not appear that Thread.interrupt is called on the thread hosting the job.

If this is intentional, then the documentation should be updated to reflect this, though I would very much prefer to have a way of interrupting jobs.

Start job by name

Whenever I try to start a job based on the jobName (http://localhost:9083/tasks/startjob?JOB_NAME=MyCronJob&id=123456), it throws an error:

ERROR [2017-06-15 12:22:43,440] org.knowm.sundial.SundialJobScheduler: ERROR STARTING JOB!!!
! org.quartz.exceptions.JobPersistenceException: The job (MyCronJob) referenced by the trigger does not exist.
! at org.quartz.core.RAMJobStore.storeTrigger(RAMJobStore.java:249)
...

I've tried to register my jobs using annotations, via jobs.xml or via API but the result is always the same: Quartz doesn't know about any jobs. The variable jobsByKey is always empty in org.quartz.core.RAMJobStore.

I'm on dropwizard-sundial 1.1.0.0 (Sundial 2.1.2).

OutOfMemoryError

Hi,

I want to use Sundial for production scheduling where we have existing logic of mail forwarding.
In Sundial Job I am opening 19 threads to work with different inboxes, scheduling if of 10 minutes,
after ten minutes when Sundial Scheduler triggers the job i check in job if last job is not finished (by checking threads in ps command) then just return.
this makes memory accumulation as job instance does not get removed,
what i am doing wrong?

Thanks to Tim for such a good open source,

Raz

Jobs.xml not parsing

I got a sundial scheduler job which should run with the help of jobs.xml. When I start dropwizard application the jobs.xml file get detected but getting some error while parsing the file.

I am trying to use simple trigger and only one job is there in Class: com.listener.Listener. Kindly help me to solve this issue.

I am attaching job.xml and error which was thrown.

jobs.txt
error.txt

package annotated jobs does not work with tomcat war versioning

If you use tomcat war versioning (e.g. war name: eDHTReporter##20180201-01.war / for more details please see https://objectpartners.com/2012/04/17/tomcat-v7-parallel-deployment/), package annotated jobs does not work because the directory encoding is wrong:

2018-02-01T09:02:34,452 [] [] INFO  org.quartz.core.SchedulerSignalerImpl <init>:49 - Initialized Scheduler Signaler of type: class org.quartz.core.SchedulerSignalerImpl
2018-02-01T09:02:34,463 [] [] INFO  org.quartz.core.RAMJobStore initialize:112 - RAMJobStore initialized.
2018-02-01T09:02:34,463 [] [] INFO  org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin initialize:124 - Initializing XMLSchedulingDataProcessorPlugin Plug-in.
2018-02-01T09:02:34,463 [] [] INFO  org.quartz.plugins.management.ShutdownHookPlugin initialize:99 - Registering Quartz shutdown hook.
2018-02-01T09:02:34,464 [] [] INFO  org.knowm.sundial.plugins.AnnotationJobTriggerPlugin initialize:76 - Initializing AnnotationJobTriggerPlugin Plug-in.
2018-02-01T09:02:34,468 [] [] WARN  org.quartz.plugins.xml.XMLSchedulingDataProcessor processFile:233 - File named 'jobs.xml' does not exist. This is OK if you don't want to use an XML job config file.
2018-02-01T09:02:34,469 [] [] INFO  org.quartz.plugins.xml.XMLSchedulingDataProcessor scheduleJobs:490 - Adding 0 jobs, 0 triggers.
2018-02-01T09:02:34,471 [] [] INFO  org.knowm.sundial.plugins.AnnotationJobTriggerPlugin start:86 - Loading annotated jobs from de.guhsoft.edhtreporter.server.tools.jobs.
2018-02-01T09:02:34,471 [] [] INFO  org.quartz.classloading.CascadingClassLoadHelper getJobClasses:229 - Package: 'de.guhsoft.edhtreporter.server.tools.jobs' becomes Resource: 'jar:file:/usr/local/tomcat/eDHTReporter/webapps/eDHTReporter%23%2320180201-01/WEB-INF/lib/eDHRServerScheduling.jar!/de/guhsoft/edhtreporter/server/tools/jobs/'
2018-02-01T09:02:34,472 [] [] ERROR de.guhsoft.edhtreporter.server.tools.SchedulerInitializer contextInitialized:21 - Exception while scheduling jobs.
java.lang.RuntimeException: Unexpected IOException reading JAR File '/usr/local/tomcat/eDHTReporter/webapps/eDHTReporter%23%2320180201-01/WEB-INF/lib/eDHRServerScheduling.jar'
        at org.quartz.classloading.CascadingClassLoadHelper.processJarfile(CascadingClassLoadHelper.java:276) ~[sundial-2.1.3.jar:?]
        at org.quartz.classloading.CascadingClassLoadHelper.getJobClasses(CascadingClassLoadHelper.java:232) ~[sundial-2.1.3.jar:?]
        at org.knowm.sundial.plugins.AnnotationJobTriggerPlugin.start(AnnotationJobTriggerPlugin.java:88) ~[sundial-2.1.3.jar:?]
        at org.quartz.QuartzScheduler.startPlugins(QuartzScheduler.java:1113) ~[sundial-2.1.3.jar:?]
        at org.quartz.QuartzScheduler.start(QuartzScheduler.java:211) ~[sundial-2.1.3.jar:?]
        at org.knowm.sundial.SundialJobScheduler.startScheduler(SundialJobScheduler.java:106) ~[sundial-2.1.3.jar:?]
        at org.knowm.sundial.SundialJobScheduler.startScheduler(SundialJobScheduler.java:93) ~[sundial-2.1.3.jar:?]
        at de.guhsoft.edhtreporter.server.tools.SchedulerInitializer.contextInitialized(SchedulerInitializer.java:19) [eDHRServerScheduling.jar:?]
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745) [catalina.jar:8.5.27]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207) [catalina.jar:8.5.27]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.27]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) [catalina.jar:8.5.27]
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) [catalina.jar:8.5.27]
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:8.5.27]
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986) [catalina.jar:8.5.27]
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) [catalina.jar:8.5.27]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_162]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_162]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_162]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_162]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_162]
Caused by: java.io.FileNotFoundException: /usr/local/tomcat/eDHTReporter/webapps/eDHTReporter%23%2320180201-01/WEB-INF/lib/eDHRServerScheduling.jar (No such file or directory)
        at java.util.zip.ZipFile.open(Native Method) ~[?:1.8.0_162]
        at java.util.zip.ZipFile.<init>(ZipFile.java:225) ~[?:1.8.0_162]
        at java.util.zip.ZipFile.<init>(ZipFile.java:155) ~[?:1.8.0_162]
        at java.util.jar.JarFile.<init>(JarFile.java:166) ~[?:1.8.0_162]
        at java.util.jar.JarFile.<init>(JarFile.java:103) ~[?:1.8.0_162]
        at org.quartz.classloading.CascadingClassLoadHelper.processJarfile(CascadingClassLoadHelper.java:274) ~[sundial-2.1.3.jar:?]
        ... 20 more

The file is there, but under

/usr/local/tomcat/eDHTReporter/webapps/eDHTReporter##20180201-01/WEB-INF/lib/eDHRServerScheduling.jar

not under

/usr/local/tomcat/eDHTReporter/webapps/eDHTReporter%23%2320180201-01/WEB-INF/lib/eDHRServerScheduling.jar

JobListener Support in Sundial

Sundial version of quartz is not having support to add globalJobListeners.

Is there any workaround or way to add global listeners.

We are trying implement some sort of job chaining using this job listener capability.

Please advise on the same. Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.