(OFBIZ-11200)
Before this commit, to purge old job we use the thread job manager to check
if some job need to be run and if the pool is empty, check the old job to purge.
I detected a problem when you have many job's server and more than one pool.
When you have a first pool that run regular job and a second that receive
huge asynchrone services (by persist call), the server who manage the second pool
have rarely the possibility to purge their jobs that, by the way, increase JobSandbox table.
The Server who manage the first pool, call often the purge process, but the table size
generate a long query time to purge few element. Long query time, run often,
this purge process load uselessly the database.
After analyze, I refactoring these following items :
* When you call JobSandbox table for a purge, use a limit on the query
with the max thread pool because when you have the database return,
you purge only with this limit so this help the database to not scan
the whole table. Other small improvement, do not sort the result
(no functional gain).
* Purge by the pool thread is nice, each server can only purge their
own job (filtered on run_by_instance_id), to help an overloaded server,
I was rehability purgeOldJobs service that it can run with specific
parameter to make assistance.
* Last, all job services are historical on class org.apache.ofbiz.service.ServiceUtil,
I moved them all in a new dedicate class org.apache.ofbiz.service.job.JobServices