Open Distro for Elasticsearch has a new extensible plugin, Job Scheduler, which is a library that enables you to build a plugins that can run periodic jobs on your cluster. You can use Job Scheduler for a variety of reasons - from taking snapshots once per hour, deleting indexes that are more than 90 days old, to providing scheduled reports.
Great news for plug-in developers
The Job Scheduler plug-in provides a framework with a service provider interface (SPI), which developers can use to enhance their existing plugins or build new ones. Job Scheduler has a sweeper that listens for update events on the Elasticsearch cluster, a scheduler that manages when jobs should run, and a monitoring component that can query for metrics.
Elasticsearch plug-in developers can extend the Job Scheduler SPI to run their periodic jobs. Your extension plug-in can:
Define your JobParameter type by creating a JobParameter class which implements the
Implement a job runner which implements the
Your plug-in will need to extend
JobSchedulerExtension, to register following information with the JobScheduler plug-in.
- Job index name - the name of the index
- Job type - should be an unique string across all extended job scheduler plug-ins
- Job parser - used to de-serialize the job document to JobParameter instance
- JobRunner instance - contains your code for running the job
Don’t forget to create the service provider configuration file in your resources folder and bundle it into your plug-in artifact.
sample-extension-plugin example code in the Job Schedule source repo, which provides a complete example of using Job Scheduler to run your jobs with.
Build, Install, Code, Run!
The Job Scheduler plug-in source code can be built and installed by following the instructions here.
Please take a look at the source code - play with it, build with it! Let us know if it doesn’t support your use case or if you have ideas for how to improve it.
Check out the code, build a plugin, and open a pull request - we’re happy to review and figure out steps to integrate.
We welcome your participation on the project. If you have any questions, don’t hesitate to ask on the community discussion forums.
Go schedule your Elasticsearch plug-in jobs!