Interface GearmanFunction

    • Method Detail

      • getName

        String getName()
        Retrieves the name of the funcion to be executed by the job. This is used by a GearmanWorker to determine if the function has been regisitered with the worker and therefor can be executed by the Worker.
        Returns:
        the name of the function.
      • setData

        void setData​(Object data)
        Some functions require a dataset upon which to operate. This method is used to load that data so that it is available when the function is called.
        Parameters:
        data - The data used by the function at execution time.
      • setJobHandle

        void setJobHandle​(byte[] handle)
                   throws IllegalArgumentException
        Set the handle of the job for which this function is executing.
        Parameters:
        handle - the job handle.
        Throws:
        IllegalArgumentException - if the handle is null or empty.
      • getJobHandle

        byte[] getJobHandle()
        Retrieves the handle for the job that is executing this function.
        Returns:
        The jobhandle or an empty array if the handle is not set.
      • registerEventListener

        void registerEventListener​(GearmanIOEventListener listener)
                            throws IllegalArgumentException
        As a function executes, it can generate a series of I/O Events -- in the form of a GearmanPacket -- that can be handled by a series of listeners. This method registers an instance of a listener with this function. When the function calls the fireEvent(org.gearman.common.GearmanPacket) all registered listeners should be given a chance to handle the event. An exampe of this would be a function that generates intermediate data. As the data is generated, the function can call this method to allow any listeners to act upon that data.
        Parameters:
        listener -
        Throws:
        IllegalArgumentException - if the listener is null or deemed to be invalid by the function.
      • fireEvent

        void fireEvent​(GearmanPacket event)
        Allows all GearmanIOEventListener registered with this function to handle the specified event.
        Parameters:
        event - The event to be handled by the listeners.
      • setUniqueId

        void setUniqueId​(byte[] uuid)
        Set the Unique ID given to this job by the client
      • getUniqueId

        byte[] getUniqueId()
        Returns the Unique ID given to this job by the client