public void run()

in src/main/java/org/apache/sling/event/impl/jobs/tasks/CleanUpTask.java [102:145]


    public void run() {
        this.schedulerRuns++;
        logger.debug("Job manager maintenance: Starting #{}", this.schedulerRuns);

        final TopologyCapabilities topologyCapabilities = configuration.getTopologyCapabilities();
        if ( topologyCapabilities != null ) {
            // Clean up
            final String cleanUpUnassignedPath;;
            if ( topologyCapabilities.isLeader() ) {
                cleanUpUnassignedPath = this.configuration.getUnassignedJobsPath();
            } else {
                cleanUpUnassignedPath = null;
            }

            // job scheduler is handled every third run
            if ( schedulerRuns % 3 == 1 ) {
                this.jobScheduler.maintenance();
            }
            if ( schedulerRuns % 60 == 0 ) { // full clean up is done every hour
                this.fullEmptyFolderCleanup(topologyCapabilities, this.configuration.getLocalJobsPath());
                if ( cleanUpUnassignedPath != null ) {
                    this.fullEmptyFolderCleanup(topologyCapabilities, cleanUpUnassignedPath);
                }
                if ( topologyCapabilities.isLeader() ) {
                    this.cleanUpInstanceIdFolders(topologyCapabilities, this.configuration.getAssginedJobsPath());
                }
            } else if ( schedulerRuns % 5 == 0 ) { // simple clean up every 5 minutes
                this.simpleEmptyFolderCleanup(topologyCapabilities, this.configuration.getLocalJobsPath());
                if ( cleanUpUnassignedPath != null ) {
                    this.simpleEmptyFolderCleanup(topologyCapabilities, cleanUpUnassignedPath);
                }
            }
        }


        if (this.configuration.getHistoryCleanUpRemovedJobs() > 0 &&
                schedulerRuns % 60 == 1) {
            Calendar removeDate = getCalendarInstance();
            removeDate.add(Calendar.MINUTE, - this.configuration.getHistoryCleanUpRemovedJobs());
            this.historyCleanUpRemovedJobs(removeDate);
        }

        logger.debug("Job manager maintenance: Finished #{}", this.schedulerRuns);
    }