psdi.common.asyncjob

Class AsyncJobCron

  • All Implemented Interfaces:
    CronTask
    Direct Known Subclasses:
    AsyncJobImmediateCron, AsyncJobScheduledCron


    public abstract class AsyncJobCron
    extends SimpleCronTask
    Base class for the foreground and background asynchronous job processing crontasks. This is to handle pick up the job from the queue based on the criteria set up for this crontask instance and process it by invoking the asynchronous job handler.
    • Constructor Detail

      • AsyncJobCron

        public AsyncJobCron()
    • Method Detail

      • isImmediate

        public abstract boolean isImmediate()
        The actual foreground or background crontask definitation class needs to implement this method to return true or false.
        Returns:
        true if this crontask handles foreground jobs, false if it handles background jobs.
      • cronAction

        public void cronAction()
        This method picks up an entry in the asynchronous job queue and handles it to its specified asynchronous job handler to process it. The jobs are picked up in a FIFO order. It will check all the jobs that met the condition and are one of the job names specified by the crontask's job names parameter. The method will move on to the next cycle if there is no job in the queue. The action will complete with other crontask instances that looks to pick up the same kind of jobs. The first one who picks up the job wins. if there are any more left in the queue, the one lost will try to pick up the next in the queue.
        Specified by:
        cronAction in interface CronTask
        Specified by:
        cronAction in class SimpleCronTask
      • getJobUserInfo

        public UserInfo getJobUserInfo(java.lang.String userID,
                                       java.lang.String locale)
        Get the user info by the passed in userId and locale.
        Parameters:
        userID -
        locale -
        Returns:
      • pickupOneJob

        public java.lang.String pickupOneJob()
                                      throws MXException,
                                             java.rmi.RemoteException
        Returns the jobnum if successfully picks up a job. After this method is called, the status and the server host and name are updated to the record and other crontask will not pick it up again. It will pick up jobs in the submit status, and its scheduled time if specified is not later then the current time. It will also consider the re-triaable jobs that are in progress but the server who has picked up doesn't have a heartbeat for 15 minutes.
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getParameters

        public CrontaskParamInfo[] getParameters()
                                          throws MXException,
                                                 java.rmi.RemoteException
        Description copied from interface: CronTask
        This method provides an array of CrontaskParamInfo() object to describe all the parameters of the crontask. Parameter name, default values and the description of the parameter should be set to the CrontaskParamInfo object for each parameter. If default value and description is not set, null will be the values.
        Specified by:
        getParameters in interface CronTask
        Overrides:
        getParameters in class SimpleCronTask
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        CrontaskParamInfo