Hello World,

I am currently working on the Automatic Git Cache Maintenance Project under GSoC 2022. The aim of the project is to integrate git maintenance command to Jenkins to optimize the caches present on the Jenkins Controller.

Administrators can schedule various maintenance tasks by entering CronSytax in the UI. The data entered is stored internally in an XML file. I am confused between PeriodicWork/AsyncPeriodicWork to schedule the maintenance tasks.

The way I am thinking to implement is to extend this class and check every minute whether any of the maintenance task satisfy the cronSyntax entered by the administrator. If the current time satisfies the cronSyntax of a particulat task, then that task is added to a queue.

I am planning to create another thread which consumes the maintenance tasks present in the queue. The reason for creating another thread is to not block the thread which validates and pushes the maintenance task into the queue. The javadoc of PeriodicWork suggests to use it if the work done is short. I am more inclined towards using PeriodicWork. However, I am not sure about the performance.

I am not sure if this is the best approach and looking for help from the community. Open to suggestions and discussion.

Thank You

Hrushikesh Rao


||

--
You received this message because you are subscribed to the Google Groups "Jenkins 
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/5ed04dcb-898b-d48e-69ca-6b91db44b1ab%40gmail.com.
Title: PeriodicWork (Jenkins core 2.354 API)
Package hudson.model

Class PeriodicWork

    • Constructor Detail

      • PeriodicWork

        public PeriodicWork()
    • Method Detail

      • getRecurrencePeriod

        public abstract long getRecurrencePeriod()
        Gets the number of milliseconds between successive executions.

        Hudson calls this method once to set up a recurring timer, instead of calling this each time after the previous execution completed. So this class cannot be used to implement a non-regular recurring timer.

        IOW, the method should always return the same value.

      • getInitialDelay

        public long getInitialDelay()
        Gets the number of milliseconds til the first execution.

        By default it chooses the value randomly between 0 and getRecurrencePeriod()

Title: AsyncPeriodicWork (Jenkins core 2.354 API)
Package hudson.model

Class AsyncPeriodicWork

    • Field Detail

      • name

        public final String name
        Human readable name of the work.
    • Constructor Detail

      • AsyncPeriodicWork

        protected AsyncPeriodicWork​(String name)
    • Method Detail

      • doRun

        public final void doRun()
        Schedules this periodic work now in a new thread, if one isn't already running.
        Specified by:
        doRun in class SafeTimerTask
      • getLogFile

        protected File getLogFile()
        Determines the log file that records the result of this task.
      • getNormalLoggingLevel

        protected Level getNormalLoggingLevel()
        Returns the logging level at which normal messages are displayed.
        Returns:
        The logging level as @Level.
        Since:
        1.551
      • getSlowLoggingLevel

        protected Level getSlowLoggingLevel()
        Returns the logging level at which previous task still executing messages is displayed.
        Returns:
        The logging level as @Level.
        Since:
        1.565
      • getErrorLoggingLevel

        protected Level getErrorLoggingLevel()
        Returns the logging level at which error messages are displayed.
        Returns:
        The logging level as @Level.
        Since:
        1.551

Reply via email to