public class AdminImpl extends Object implements Admin
| Modifier and Type | Class and Description |
|---|---|
protected class |
AdminImpl.PubSubListener |
JobExecutor.State| Modifier and Type | Field and Description |
|---|---|
protected redis.clients.jedis.Jedis |
jedis |
protected AdminImpl.PubSubListener |
jedisPubSub |
protected String |
namespace |
protected AtomicReference<JobExecutor.State> |
state |
protected AtomicReference<Worker> |
workerRef |
| Constructor and Description |
|---|
AdminImpl(Config config) |
AdminImpl(Config config,
Set<String> channels,
Map<String,? extends Class<?>> jobTypes) |
| Modifier and Type | Method and Description |
|---|---|
void |
addJobType(String jobName,
Class<?> jobType)
Allow the given job type to be executed.
|
protected static void |
checkChannels(Iterable<String> channels)
Verify that the given channels are all valid.
|
protected void |
checkJobTypes(Map<String,? extends Class<?>> jobTypes)
Verify the given job types are all valid.
|
void |
end(boolean now)
Shutdown this JobExecutor.
|
protected Object |
execute(Job job,
String curQueue,
Object instance)
Executes the given job.
|
Set<String> |
getChannels() |
ExceptionHandler |
getExceptionHandler()
The current exception handler.
|
Map<String,Class<?>> |
getJobTypes()
The allowed job names and types that this JobExecutor will execute.
|
protected int |
getReconnectAttempts() |
Worker |
getWorker() |
boolean |
isProcessingJob()
Returns whether this JobExecutor is currently processing a job.
|
boolean |
isShutdown()
Returns whether this JobExecutor is either shutdown or in the process of shutting down.
|
void |
join(long millis)
Wait for this JobExecutor to complete.
|
protected void |
recoverFromException(String channel,
Exception e)
Handle an exception that was thrown from inside
AdminImpl.PubSubListener.onMessage(String,String) |
void |
removeJobName(String jobName)
Disallow the job name from being executed.
|
void |
removeJobType(Class<?> jobType)
Disallow the job type from being executed.
|
void |
run() |
void |
setChannels(Set<String> channels) |
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
Set this JobExecutor's exception handler to the given handler.
|
void |
setJobTypes(Map<String,? extends Class<?>> jobTypes)
Clear any current allowed job types and use the given set.
|
void |
setWorker(Worker worker) |
protected final redis.clients.jedis.Jedis jedis
protected final String namespace
protected final AdminImpl.PubSubListener jedisPubSub
protected final AtomicReference<Worker> workerRef
protected final AtomicReference<JobExecutor.State> state
public AdminImpl(Config config)
public Set<String> getChannels()
getChannels in interface Adminpublic void setChannels(Set<String> channels)
setChannels in interface Adminpublic void end(boolean now)
JobExecutorend in interface JobExecutornow - if true, an effort will be made to stop any job in progresspublic boolean isShutdown()
JobExecutorisShutdown in interface JobExecutorpublic boolean isProcessingJob()
JobExecutorisProcessingJob in interface JobExecutorpublic void join(long millis)
throws InterruptedException
JobExecutorJobExecutor.end(boolean).join in interface JobExecutormillis - the time to wait in millisecondsInterruptedException - if any thread has interrupted the current threadpublic Map<String,Class<?>> getJobTypes()
JobExecutorgetJobTypes in interface JobExecutorpublic void addJobType(String jobName, Class<?> jobType)
JobExecutoraddJobType in interface JobExecutorjobName - the job name as seenjobType - the job type to allowpublic void removeJobType(Class<?> jobType)
JobExecutorremoveJobType in interface JobExecutorjobType - the job type to disallowpublic void removeJobName(String jobName)
JobExecutorremoveJobName in interface JobExecutorjobName - the job name to disallowpublic void setJobTypes(Map<String,? extends Class<?>> jobTypes)
JobExecutorsetJobTypes in interface JobExecutorjobTypes - the job types to allowpublic ExceptionHandler getExceptionHandler()
JobExecutorgetExceptionHandler in interface JobExecutorpublic void setExceptionHandler(ExceptionHandler exceptionHandler)
JobExecutorsetExceptionHandler in interface JobExecutorexceptionHandler - the exception handler to useprotected Object execute(Job job, String curQueue, Object instance) throws Exception
protected int getReconnectAttempts()
protected void recoverFromException(String channel, Exception e)
AdminImpl.PubSubListener.onMessage(String,String)channel - the name of the channel that was being processed when the exception was throwne - the exception that was thrownprotected static void checkChannels(Iterable<String> channels)
channels - the given channelsCopyright © 2011-2013. All Rights Reserved.