Work towards automated cleaning of JcrJobRepository#107
Conversation
|
@jazeren1 @jbornemann @jdigger just WIP. Need to still properly test this and implement unit tests |
8d2cb53 to
7d855e2
Compare
|
Opening this up for some initial "approach" review. Currently I have a servlet that's triggering the cleaning. I'll be updating this to have a Cron like we discussed. Wanted to get some feedback on the approach I have taken. After I almost finished the job repp cleanup functionality .. But then I realized that there are way too many private methods in the service I have for cleanup. (this commit : 1e51ff8) Because of that, I thought it'd be better "host" the functionality on the DAO objects themselves.. Felt like that looked and organized better. ( this commit: 7d855e2) Does the latter approach look better? In order to make that happen, I had to extend Spring Batch's DAO interfaces to add the additional APIs we need for clean-up. @jdigger @jazeren1 @jbornemann @masroormohammed can you please take a look? |
|
Ugh hold on. Tests are failing. Taking a look. |
|
I'll change the logging to debug, etc. when this is good to go. I figured the logging will help right now during testing. Also made the change in grabbit version right now for easier installation for testing. To test,
I've had to ignore uninstall. Seems to be having issues with other bundles in AEM :( Run some content syncs for any number of paths .. or if you already have some data under
Current testing is to do a POST to This number can be any "integer" .. I have tested that it works fine for > 24 hours as well. More-over, I am also logging everything that's going on .. along with the Date its using to compare and everything. So your logs will look something like this : You can play around with the "hours" param for the servlet and see how it performs .. deletions will be made based on Comparison between "Date.now() - hours" and "All COMPLETED and FAILED JobExecutions" ... it will also delete all the corresponding "StepExecutions", "JobInstances" and "ExecutionContexts" ... |
|
|
||
| JcrJobRepositoryFactoryBean jobRepositoryFactoryBean = configurableApplicationContext.getBean(JcrJobRepositoryFactoryBean) | ||
|
|
||
| List<String> jobExecutionPaths = jobRepositoryFactoryBean.jobExecutionDao.getJobExecutions([BatchStatus.FAILED, BatchStatus.COMPLETED]) |
There was a problem hiding this comment.
Other "BatchStatus" options are
STARTING, STARTED, STOPPING, STOPPED, ABANDONED, UNKNOWN;
So, should we query for everything except "STARTING" and "STARTED" and "STOPPING" ?
There was a problem hiding this comment.
@sagarsane whats the difference between STARTING and STARTED?
There was a problem hiding this comment.
From what I understand .. its similar to OSGi's STARTING and ACTIVE bundle states (not 1-1 comparison tho :) )
https://blog.codecentric.de/en/2014/04/spring-batch-batchstatus-state-transitions/ has a bit more info.
|
Done with some main CR comments. Still not done anything to suggestions like #107 (comment) .. I like that idea but wanted to discuss that first. @jazeren1 @jbornemann @jdigger @masroormohammed please take a look . |
|
👍 Testing |
| Resource jobExecutionResource = resolver.getResource(jobExecutionResourcePath) | ||
| ValueMap props = jobExecutionResource.adaptTo(ValueMap) | ||
| Long jobExecutionId = props[JcrGrabbitJobExecutionDao.EXECUTION_ID] as Long | ||
| String query = "select * from [nt:unstructured] as s " + |
cf69e36 to
cf354ce
Compare
| @Slf4j | ||
| @CompileStatic | ||
| @SlingServlet(methods = ['POST'], resourceTypes = ['twcable:grabbit/jobrepository/clean']) | ||
| class GrabbitCleanJobRepositoryServlet extends SlingAllMethodsServlet { |
There was a problem hiding this comment.
@jbornemann @jazeren1 @jdigger @masroormohammed added this.
POST /grabbit/jobrepository/clean with param 'hours'
I like using a POST API to clean the jobrepository .. that acts as a "resource" .. and that resource manifests with the help of given "hours" param. This servlet returns JobExecutionIds that were removed (if successful)
cf354ce to
90eabe8
Compare
|
Updated testing instructions to have the new API to clean the jobrepository |
|
+1 Testing |
|
CR changes have been made @jdigger @jbornemann |
|
@sagarsane : +1 Testing |
…y that is older than X hours from "now" * New API added : POST /grabbit/jobrepository/clean --data hours=X * All JobInstances, JobExecutions, StepExecutions and ExecutionContexts that either FAILED or COMPLETED X hours from "now", i.e., when the API was called -- will be deleted
3e5670c to
b39f3b7
Compare
No description provided.