Class UpgradeTasksJob

java.lang.Object
edu.internet2.middleware.grouper.app.loader.OtherJobBase
edu.internet2.middleware.grouper.app.upgradeTasks.UpgradeTasksJob
All Implemented Interfaces:
org.quartz.Job

@DisallowConcurrentExecution public class UpgradeTasksJob extends OtherJobBase
  • Field Details

  • Constructor Details

    • UpgradeTasksJob

      public UpgradeTasksJob()
  • Method Details

    • main

      public static void main(String[] args)
      run the daemon
      Parameters:
      args -
    • runDaemonStandalone

      public static String runDaemonStandalone()
      run standalone
    • canRunDdl

      public static boolean canRunDdl()
    • run

      Description copied from class: OtherJobBase
      implement this method for the logic of the OtherJob
      Specified by:
      run in class OtherJobBase
      Returns:
      the output
      See Also:
    • isThereWorkToDo

      public static boolean isThereWorkToDo(Set<Integer> sortedOldDbVersions)
    • grouperUpgradeTasksStemName

      public static String grouperUpgradeTasksStemName()
      stem name for upgrade tasks
      Returns:
      stem name
    • grouperUpgradeTasksAttributeDef

      public static AttributeDef grouperUpgradeTasksAttributeDef()
    • getDBVersion

      public static int getDBVersion()
      DO NOT CALL THIS METHOD SINCE THE ATTRIBUTE CHANGED TO MULTIVALUED
    • getDBVersions

      public static Set<Integer> getDBVersions()
    • grouperUpgradeTasksMetadataGroup

      public static Group grouperUpgradeTasksMetadataGroup()
      The metadata group (etc:attribute:upgradeTasks:upgradeTasksMetadataGroup) whose multivalued upgradeTasksVersion attribute records which upgrade task versions have been completed.
      Returns:
      the metadata group
    • grouperUpgradeTasksVersionAttributeName

      public static String grouperUpgradeTasksVersionAttributeName()
      full name of the multivalued attribute def name that records completed upgrade task versions
      Returns:
      the attribute def name
    • retrieveUpgradeTask

      public static UpgradeTasks retrieveUpgradeTask(int version)
      Look up an upgrade task enum constant by its version number.
      Parameters:
      version - e.g. 43
      Returns:
      the UpgradeTasks enum constant, or null if there is no task for that version
    • markUpgradeTaskComplete

      public static void markUpgradeTaskComplete(int version)
      Mark an upgrade task version complete by adding its number to the multivalued upgradeTasksVersion attribute on the metadata group - the same write the daemon (run()) does inline. This tells Grouper the task is done so it will not be run again. Idempotent: a no-op if the version is already recorded.
      Parameters:
      version - the upgrade task version number
    • markUpgradeTaskNotComplete

      public static void markUpgradeTaskNotComplete(int version)
      Remove the completed marker for an upgrade task version so the daemon (or a manual run) will run it again. Idempotent: a no-op if the version is not currently recorded as complete.
      Parameters:
      version - the upgrade task version number
    • upgradeTaskHasDdlWorkToDo

      public static boolean upgradeTaskHasDdlWorkToDo(UpgradeTasksInterface upgradeTasksInterface)
      Whether a single upgrade task currently has DDL work left to do. Non-DDL tasks always return false. For DDL tasks this is the expensive check (doesUpgradeTaskHaveDdlWorkToDo reads the live schema), so it is wrapped in the DDL model cache - the same pattern run() uses - so the schema is read once and shared across the asserts in this single check.
      Parameters:
      upgradeTasksInterface - the task to check
      Returns:
      true if this is a DDL task that still has automatic DDL work to do
    • retrieveUpgradeTaskStatus

      public static UpgradeTasksJob.UpgradeTaskStatus retrieveUpgradeTaskStatus(int version, Set<Integer> completedVersions, boolean checkDdl)
      Compute the status of a single upgrade task for display.
      Parameters:
      version - the upgrade task version number
      completedVersions - the set of versions already recorded complete (pass getDBVersions() once and reuse across rows rather than re-querying per row)
      checkDdl - if true, a not-complete DDL task with no DDL work to do is reported NOT_APPLICABLE (this runs the expensive schema check via upgradeTaskHasDdlWorkToDo(edu.internet2.middleware.grouper.app.upgradeTasks.UpgradeTasksInterface)); if false, a not-complete task is simply NOT_COMPLETE (cheap - no schema read)
      Returns:
      the status
    • runUpgradeTask

      public static String runUpgradeTask(int version)
      Run a single upgrade task by version number and, on success, record it complete. This performs the same per-task work the daemon (run()) does for one version, in a standalone loader-log context so it can be triggered individually - e.g. from the Configure -> Upgrade tasks admin screen. Runs as the root grouper session. Note the tasks are individually idempotent (each re-checks its own preconditions), but they are designed to run in ascending version order.
      Parameters:
      version - the upgrade task version number to run
      Returns:
      the loader job message accumulated while running the task