public class AdminPoolImpl extends Object implements Admin
| Modifier and Type | Class and Description |
|---|---|
protected class |
AdminPoolImpl.PubSubListener |
JobExecutor.State| Modifier and Type | Field and Description |
|---|---|
protected redis.clients.util.Pool<redis.clients.jedis.Jedis> |
jedisPool |
protected AdminPoolImpl.PubSubListener |
jedisPubSub |
protected String |
namespace |
protected AtomicReference<JobExecutor.State> |
state |
protected AtomicReference<Worker> |
workerRef |
| Constructor and Description |
|---|
AdminPoolImpl(Config config,
redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool)
Create a new AdminImpl which subscribes to
ResqueConstants.ADMIN_CHANNEL, registers the
PauseCommand and ShutdownCommand jobs. |
AdminPoolImpl(Config config,
Set<String> channels,
JobFactory jobFactory,
redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool)
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.
|
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
AdminPoolImpl.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.util.Pool<redis.clients.jedis.Jedis> jedisPool
protected final String namespace
protected final AdminPoolImpl.PubSubListener jedisPubSub
protected final AtomicReference<Worker> workerRef
protected final AtomicReference<JobExecutor.State> state
public AdminPoolImpl(Config config, redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool)
ResqueConstants.ADMIN_CHANNEL, registers the
PauseCommand and ShutdownCommand jobs.config - the Jesque configurationjedisPool - the Redis connection poolpublic AdminPoolImpl(Config config, Set<String> channels, JobFactory jobFactory, redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool)
config - the Jesque configurationchannels - the channels to subscribe tojobFactory - the job factory that materializes the jobsjedisPool - the Redis connection poolpublic 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 void recoverFromException(String channel, Exception e)
AdminPoolImpl.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–2019. All rights reserved.