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)
Create a new AdminImpl which subscribes to
ResqueConstants.ADMIN_CHANNEL, registers the
PauseCommand and ShutdownCommand jobs, and creates a new Jedis connection. |
AdminImpl(Config config,
Set<String> channels,
JobFactory jobFactory)
Create a new AdminImpl which creates a new Jedis connection.
|
AdminImpl(Config config,
Set<String> channels,
JobFactory jobFactory,
redis.clients.jedis.Jedis jedis)
Create a new AdminImpl.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
checkChannels(Iterable<String> channels)
Verify that the given channels 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.
|
JobFactory |
getJobFactory()
The job factory.
|
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 |
run() |
void |
setChannels(Set<String> channels) |
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
Set this JobExecutor's exception handler to the given handler.
|
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)
ResqueConstants.ADMIN_CHANNEL, registers the
PauseCommand and ShutdownCommand jobs, and creates a new Jedis connection.config - the Jesque configurationpublic AdminImpl(Config config, Set<String> channels, JobFactory jobFactory)
config - the Jesque configurationchannels - the channels to subscribe tojobFactory - the job factory that materializes the jobspublic AdminImpl(Config config, Set<String> channels, JobFactory jobFactory, redis.clients.jedis.Jedis jedis)
config - the Jesque configurationchannels - the channels to subscribe tojobFactory - the job factory that materializes the jobsjedis - the connection to Redispublic Set<String> getChannels()
getChannels in interface Adminpublic void setChannels(Set<String> channels)
setChannels in interface Adminchannels - the set of Redis Pub/Sub channels to subscribe topublic Worker getWorker()
public void setWorker(Worker worker)
public void end(boolean now)
end in interface JobExecutornow - if true, an effort will be made to stop any job in progresspublic boolean isShutdown()
isShutdown in interface JobExecutorpublic boolean isProcessingJob()
isProcessingJob in interface JobExecutorpublic void join(long millis)
throws InterruptedException
JobExecutor.end(boolean).join in interface JobExecutormillis - the time to wait in millisecondsInterruptedException - if any thread has interrupted the current threadpublic JobFactory getJobFactory()
getJobFactory in interface JobExecutorpublic ExceptionHandler getExceptionHandler()
getExceptionHandler in interface JobExecutorpublic void setExceptionHandler(ExceptionHandler exceptionHandler)
setExceptionHandler 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 thrownCopyright © 2011-2015. All Rights Reserved.