Interface GearmanJob

    • Method Detail

      • getHandle

        byte[] getHandle()
        Retrieves the handle used by the Gearman Job Server to which this job was submitted to as a means to identify this job.
        Returns:
        The handle assigned to the job by the Gearman Job Server. If the job has not been submitted to a Gearman Job Server, then returns an empty array.
      • getID

        byte[] getID()
        Retrieves a unique ID used to identify this job. The ID is created when the Job is created, as opposed to the handle which is created by the Job Server once the job has been submitted.
        Returns:
        A unique used to identify this job.
      • getFunctionName

        String getFunctionName()
        Retrieve the name of the GearmanFunction registered with this job.
        Returns:
        function name
      • isBackgroundJob

        boolean isBackgroundJob()
        Determines if this job is a background job. A background job is a job which does not send status updates back to the GearmanClient that submitted the job. Unlike non-background jobs, executing Future.get() will not block until job completion. Nor will a background job return a GearmanJobResult when it has finished execution. To determine the status of background job, you must execute GearmanClient.getJobStatus(org.gearman.client.GearmanJob).
        Returns:
        true if the job is a background job, else returns false.
      • getPriority

        GearmanJob.JobPriority getPriority()
        Retrieve the priority associated with this job.
        Returns:
        Job Priority
      • getData

        byte[] getData()
        Retrieve the data against which the job is executed. This data is contained in GearmanFunction that has been registered with this job.
        Returns:
        The data against which the job is executed or if no data has been specified, returns an empty array.
      • registerFunction

        void registerFunction​(Callable<GearmanJobResult> function)
        Registers a particular GearmanFunction with this job. The GearmanFunction contains the definition for how the job will be executed and the data against which the execution will occurr.
        Parameters:
        function - The function defining job execution and data.
      • registerEventListener

        void registerEventListener​(GearmanIOEventListener listener)
        As a GearmanJob progress through its' lifecycle, it will receives a series of events notifications from the Gearman Job Server. For example when the job has been successfully submitted to the sever, it will receive a JOB_CREATED notification, or when some intermediate data has been sent back from the worker, than a WORK_DATA event is generated.

        This method lets user register listeners who will receive notifications when a particular event has been received from the Gearman Job Server. See GearmanIOEventListener for the list of events that can listened for and handled by the listener.

        Parameters:
        listener - the listener to which event notifications will be sent.
      • removeEventListener

        boolean removeEventListener​(GearmanIOEventListener listener)
        removes a GearmanIOEventListener from recieving event notifications.
        Parameters:
        listener - the listener to be removed.
        Returns:
        true if the listener has been removed, else false.