Sling
  1. Sling
  2. SLING-2979

Add support for running scheduled task on specific instances

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Commons Scheduler 2.4.0
    • Component/s: Commons
    • Labels:
      None

      Description

      With the new topology api we have support for leader election. In many cases scheduled tasks should only run on a single instance in a cluster. So far this can only be done by manually adding the task through the Scheduler interface but not with the whiteboard support.
      We should add a new property scheduler.leaderonly which defaults to false but can be set to true. IN this case the task is only started on the leader.

        Issue Links

          Activity

          Hide
          Konrad Windszus added a comment -

          Would you mind extending the documentation at http://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html. What exactly does SINGLE mean? Which node will execute the jobs then?

          Show
          Konrad Windszus added a comment - Would you mind extending the documentation at http://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html . What exactly does SINGLE mean? Which node will execute the jobs then?
          Konrad Windszus made changes -
          Link This issue is related to SLING-3358 [ SLING-3358 ]
          Carsten Ziegeler made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Hide
          Carsten Ziegeler added a comment -

          I'Ve revised the implementation and changed the property to "scheduler.runOn" which can either have

          • a string (array) of Sling IDs where this job should run
          • the constant LEADER - to run on the leader only
          • the constant SINGLE - to run on a single instance only
          Show
          Carsten Ziegeler added a comment - I'Ve revised the implementation and changed the property to "scheduler.runOn" which can either have a string (array) of Sling IDs where this job should run the constant LEADER - to run on the leader only the constant SINGLE - to run on a single instance only
          Carsten Ziegeler made changes -
          Summary Add support for running scheduled task only on the leader Add support for running scheduled task on specific instances
          Carsten Ziegeler made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Carsten Ziegeler added a comment -

          Added in 1507250

          I've added support for the leader evaluation which is optional. So this scheduler still runs in systems without the discovery api - in that case the flag to restrict a job on running on the leader is ignored.
          If the discovery api is available, the leader information is evaluated. To avoid registering/unregistering jobs when the leader changes (and keeping track of them etc.), all jobs are scheduled, however if a job should only run on a leader and it is scheduled on a non leader, then the its scheduled but not executed.

          Show
          Carsten Ziegeler added a comment - Added in 1507250 I've added support for the leader evaluation which is optional. So this scheduler still runs in systems without the discovery api - in that case the flag to restrict a job on running on the leader is ignored. If the discovery api is available, the leader information is evaluated. To avoid registering/unregistering jobs when the leader changes (and keeping track of them etc.), all jobs are scheduled, however if a job should only run on a leader and it is scheduled on a non leader, then the its scheduled but not executed.
          Carsten Ziegeler made changes -
          Field Original Value New Value
          Summary Scheduled task should only run on leader Add support for running scheduled task only on the leader
          Carsten Ziegeler created issue -

            People

            • Assignee:
              Carsten Ziegeler
              Reporter:
              Carsten Ziegeler
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development