edu.ucsb.nceas.metacat.scheduler

## Class SchedulerService

- java.lang.Object
- - edu.ucsb.nceas.metacat.shared.BaseService
  - - edu.ucsb.nceas.metacat.scheduler.SchedulerService

-     public class SchedulerService
      extends BaseService

- - ### Field Summary

    - ### Fields inherited from class edu.ucsb.nceas.metacat.shared.BaseService

      `_serviceName`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `deleteJob(ScheduledJobDAO jobDAO)` Remove the job from the scheduler and set the job status to deleted in the database
    `java.lang.String` | `deleteJob(java.lang.String jobName)` Remove the job from the scheduler and set the job status to deleted in the database
    `void` | `doRefresh()`
    `static SchedulerService` | `getInstance()` Get the single instance of SchedulerService.
    `java.lang.String` | `getJobInfoXML(java.lang.Long jobId)` Get information about the job in XML format
    `java.lang.String` | `getJobsInfoXML(java.lang.String groupName, java.lang.String paramName, java.lang.String paramValue)` Get the information for jobs in a group in an xml format.
    `void` | `getJobsInfoXML(java.lang.String groupName, java.lang.String paramName, java.lang.String paramValue, java.io.PrintWriter pw)` Get the information for jobs in a group in an xml format.
    `java.util.Calendar` | `getStartDateFromDelay(java.lang.String delay)` Extract the start date from the delay value
    `protected java.util.Vector<java.lang.String>` | `getStatus()`
    `java.lang.String` | `jobToXML(ScheduledJobDAO scheduledJobDAO)` Convert a single job to XML
    `boolean` | `refreshable()`
    `java.lang.String` | `rescheduleJob(ScheduledJobDAO jobDAO, java.lang.String username, java.lang.String[] groups)` Reschedule a job.
    `java.lang.String` | `rescheduleJob(ScheduledJobDAO jobDAO, java.lang.String username, java.lang.String[] groups, boolean checkStatus)` Reschedule a job.
    `java.lang.String` | `scheduleDelayedJob(java.lang.String jobName, java.lang.String delay, java.lang.String jobClassName, java.lang.String jobGroup, java.util.HashMap<java.lang.String,java.lang.String> jobParams, java.lang.String username, java.lang.String[] groups)` schedule a job one time with a given delay.
    `java.lang.String` | `scheduleJob(ScheduledJobDAO jobDAO, java.lang.String username, java.lang.String[] groups)` Schedule a job
    `java.lang.String` | `scheduleJob(java.lang.String jobName, java.util.Calendar startCal, java.util.Calendar endCal, int intervalValue, java.lang.String intervalUnit, java.lang.String jobClassName, java.lang.String jobGroup, java.util.HashMap<java.lang.String,java.lang.String> jobParams)` schedule a job
    `void` | `start()`
    `void` | `stop()`
    `java.lang.String` | `unscheduleJob(java.lang.String jobName, java.lang.String username, java.lang.String[] groups)` Unschedule a job.

    - ### Methods inherited from class edu.ucsb.nceas.metacat.shared.BaseService

      `refresh`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getInstance

          public static SchedulerService getInstance()
                                              throws ServiceException

      Get the single instance of SchedulerService.
      Returns:
        the single instance of SchedulerService
      Throws:
        `ServiceException`

    - #### refreshable

          public boolean refreshable()

      Specified by:
        `refreshable` in class `BaseService`

    - #### doRefresh

          public void doRefresh()
                         throws ServiceException

      Specified by:
        `doRefresh` in class `BaseService`
      Throws:
        `ServiceException`

    - #### start

          public void start()
                     throws ServiceException

      Throws:
        `ServiceException`

    - #### stop

          public void stop()
                    throws ServiceException

      Specified by:
        `stop` in class `BaseService`
      Throws:
        `ServiceException`

    - #### getStatus

          protected java.util.Vector<java.lang.String> getStatus()
                                                          throws ServiceException

      Throws:
        `ServiceException`

    - #### scheduleJob

          public java.lang.String scheduleJob(ScheduledJobDAO jobDAO,
                                              java.lang.String username,
                                              java.lang.String[] groups)
                                       throws ServiceException

      Schedule a job
      Parameters:
        `jobDAO` - the job data object to schedule
        `username` - the user that we will use to schedule
        `groups` - the user group that we will use to schedule
      Returns:
        a message saying that the job was scheduled
      Throws:
        `ServiceException`

    - #### scheduleJob

          public java.lang.String scheduleJob(java.lang.String jobName,
                                              java.util.Calendar startCal,
                                              java.util.Calendar endCal,
                                              int intervalValue,
                                              java.lang.String intervalUnit,
                                              java.lang.String jobClassName,
                                              java.lang.String jobGroup,
                                              java.util.HashMap<java.lang.String,java.lang.String> jobParams)
                                       throws ServiceException

      schedule a job
      Parameters:
        `jobName` - the name of the job
        `startCal` - a calendar holding the start date of the job
        `endCal` - a calendar holding the end date of the job
        `intervalValue` - the run interval for the job
        `intervalUnit` - the unit of the run interval for the job
        `jobClassName` - the job class name
        `jobGroup` - the job group name
        `jobParams` - a map of additional job parameters
        `username` - the user name
        `groups` - the user's group name
      Returns:
        a message saying that the job was scheduled
      Throws:
        `ServiceException`

    - #### scheduleDelayedJob

          public java.lang.String scheduleDelayedJob(java.lang.String jobName,
                                                     java.lang.String delay,
                                                     java.lang.String jobClassName,
                                                     java.lang.String jobGroup,
                                                     java.util.HashMap<java.lang.String,java.lang.String> jobParams,
                                                     java.lang.String username,
                                                     java.lang.String[] groups)
                                              throws ServiceException

      schedule a job one time with a given delay. The job is registered in the scheduler, but not persisted to the database. The delay is calculated from the time that this method is called.
      Parameters:
        `jobName` - the name of the job
        `delay` - the delay in seconds, minutes, hours or days from the time this method is called (i.e. 30s, 5m, 2h, 1d)
        `jobClassName` - the job class name
        `jobGroup` - the job group name
        `jobParams` - a map of additional job parameters
        `username` - the user name
        `groups` - the user's group name
      Returns:
        a message saying that the job was scheduled
      Throws:
        `ServiceException`

    - #### unscheduleJob

          public java.lang.String unscheduleJob(java.lang.String jobName,
                                                java.lang.String username,
                                                java.lang.String[] groups)
                                         throws ServiceException

      Unschedule a job. This removed it from the scheduler in memory and changed it's status to unscheduled in the database.
      Parameters:
        `jobName` - the name of the job to unschedule
        `username` - the user name
        `groups` - the user's group name
      Returns:
        a message saying the job was unscheduled
      Throws:
        `ServiceException`

    - #### rescheduleJob

          public java.lang.String rescheduleJob(ScheduledJobDAO jobDAO,
                                                java.lang.String username,
                                                java.lang.String[] groups)
                                         throws ServiceException

      Reschedule a job. This call will always check to make sure the status is not SCHEDULED
      Parameters:
        `jobDAO` - the job data object holding the information about the job to reschedule
        `username` - the user name
        `groups` - the user's group name
      Returns:
        a message saying that the job was rescheduled
      Throws:
        `ServiceException`

    - #### rescheduleJob

          public java.lang.String rescheduleJob(ScheduledJobDAO jobDAO,
                                                java.lang.String username,
                                                java.lang.String[] groups,
                                                boolean checkStatus)
                                         throws ServiceException

      Reschedule a job.
      Parameters:
        `jobDAO` - the job data object holding the information about the job to reschedule
        `username` - the user name
        `groups` - the user's group name
        `checkStatus` - if set to true, the method will check to make sure the status is UNSCHEDULED before restarting. Otherwise, the method will not check. This is so that we can restart a service at startup that was running when metacat was shut down.
      Returns:
        a message saying that the job was rescheduled
      Throws:
        `ServiceException`

    - #### deleteJob

          public java.lang.String deleteJob(java.lang.String jobName)
                                     throws ServiceException

      Remove the job from the scheduler and set the job status to deleted in the database
      Parameters:
        `jobName` - the string holding the name of the job to delete
        `username` - the user name
        `groups` - the user's group name
      Returns:
        a message saying that the job was deleted
      Throws:
        `ServiceException`

    - #### deleteJob

          public java.lang.String deleteJob(ScheduledJobDAO jobDAO)
                                     throws ServiceException

      Remove the job from the scheduler and set the job status to deleted in the database
      Parameters:
        `jobDAO` - the job data object holding the information about the job to delete
        `username` - the user name
        `groups` - the user's group name
      Returns:
        a message saying that the job was deleted
      Throws:
        `ServiceException`

    - #### getJobInfoXML

          public java.lang.String getJobInfoXML(java.lang.Long jobId)
                                         throws ServiceException

      Get information about the job in XML format
      Parameters:
        `jobId` - the job for which we want the information
      Returns:
        an XML representation of the job
      Throws:
        `ServiceException`

    - #### getJobsInfoXML

          public java.lang.String getJobsInfoXML(java.lang.String groupName,
                                                 java.lang.String paramName,
                                                 java.lang.String paramValue)
                                          throws ServiceException

      Get the information for jobs in a group in an xml format. A parameter key/value pair can be provided as well to limit the jobs returned.
      Parameters:
        `groupName` - the job group that we are searching for
        `paramName` - the parameter name that we are looking for. this is ignored if null
        `paramValue` - the parameter value that we are looking for. this is ignored if null
      Returns:
        an XML representation of the jobs.
      Throws:
        `ServiceException`

    - #### getJobsInfoXML

          public void getJobsInfoXML(java.lang.String groupName,
                                     java.lang.String paramName,
                                     java.lang.String paramValue,
                                     java.io.PrintWriter pw)
                              throws ServiceException

      Get the information for jobs in a group in an xml format. A parameter key/value pair can be provided as well to limit the jobs returned.
      Parameters:
        `groupName` - the job group that we are searching for
        `paramName` - the parameter name that we are looking for. this is ignored if null
        `paramValue` - the parameter value that we are looking for. this is ignored if null
      Throws:
        `ServiceException`

    - #### jobToXML

          public java.lang.String jobToXML(ScheduledJobDAO scheduledJobDAO)
                                    throws ServiceException

      Convert a single job to XML
      Parameters:
        `scheduledJobDAO` - the job we want to convert
      Returns:
        an XML representation of the job
      Throws:
        `ServiceException`

    - #### getStartDateFromDelay

          public java.util.Calendar getStartDateFromDelay(java.lang.String delay)
                                                   throws ServiceException

      Extract the start date from the delay value
      Parameters:
        `delay` - a string representing the start delay in notation where value is an integer and unit is one of s,m,h or d
      Returns:
        the calendar object holding the start date
      Throws:
        `ServiceException`

Copyright © 2020 Regents of the University of California. All Rights Reserved.