Package org.gearman.client
Interface GearmanJob
-
- All Superinterfaces:
Callable<GearmanJobResult>
,Future<GearmanJobResult>
- All Known Implementing Classes:
GearmanJobImpl
public interface GearmanJob extends Callable<GearmanJobResult>, Future<GearmanJobResult>
The Gearman Job is a basic undivisible unit of work to be executed by a Gearman system. The job is created by the user and submitted to the Gearman Client for execution.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
GearmanJob.JobPriority
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]
getData()
Retrieve the data against which the job is executed.String
getFunctionName()
Retrieve the name of theGearmanFunction
registered with this job.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.byte[]
getID()
Retrieves a unique ID used to identify this job.GearmanJob.JobPriority
getPriority()
Retrieve the priority associated with this job.boolean
isBackgroundJob()
Determines if this job is a background job.void
registerEventListener(GearmanIOEventListener listener)
As a GearmanJob progress through its' lifecycle, it will receives a series of events notifications from the Gearman Job Server.void
registerFunction(Callable<GearmanJobResult> function)
Registers a particularGearmanFunction
with this job.boolean
removeEventListener(GearmanIOEventListener listener)
removes aGearmanIOEventListener
from recieving event notifications.
-
-
-
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 theGearmanFunction
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 theGearmanClient
that submitted the job. Unlike non-background jobs, executingFuture.get()
will not block until job completion. Nor will a background job return aGearmanJobResult
when it has finished execution. To determine the status of background job, you must executeGearmanClient.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 inGearmanFunction
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 particularGearmanFunction
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 aGearmanIOEventListener
from recieving event notifications.- Parameters:
listener
- the listener to be removed.- Returns:
- true if the listener has been removed, else false.
-
-