public abstract class AbstractClient extends Object implements Client
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClient(Config config)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquireLock(String lockName,
String lockHolder,
int timeout)
Acquire a non-blocking distributed lock.
|
void |
delayedEnqueue(String queue,
Job job,
long future)
Queues a job in a given queue to be run in the future.
|
static boolean |
doAcquireLock(redis.clients.jedis.Jedis jedis,
String namespace,
String lockName,
String lockHolder,
int timeout)
Helper method that encapsulates the logic to acquire a lock.
|
protected abstract boolean |
doAcquireLock(String lockName,
String lockHolder,
int timeout)
Actually acquire the lock based upon the client acquisition model.
|
static void |
doDelayedEnqueue(redis.clients.jedis.Jedis jedis,
String namespace,
String queue,
String jobJson,
long future) |
protected abstract void |
doDelayedEnqueue(String queue,
String msg,
long future) |
static void |
doEnqueue(redis.clients.jedis.Jedis jedis,
String namespace,
String queue,
String jobJson)
Helper method that encapsulates the minimum logic for adding a job to a
queue.
|
protected abstract void |
doEnqueue(String queue,
String msg)
Actually enqueue the serialized job.
|
static void |
doPriorityEnqueue(redis.clients.jedis.Jedis jedis,
String namespace,
String queue,
String jobJson)
Helper method that encapsulates the minimum logic for adding a high
priority job to a queue.
|
protected abstract void |
doPriorityEnqueue(String queue,
String msg)
Actually enqueue the serialized job with high priority.
|
static void |
doRemoveDelayedEnqueue(redis.clients.jedis.Jedis jedis,
String namespace,
String queue,
String jobJson) |
protected abstract void |
doRemoveDelayedEnqueue(String queue,
String msg) |
void |
enqueue(String queue,
Job job)
Queues a job in a given queue to be run.
|
protected String |
getNamespace() |
protected String |
key(String... parts)
Builds a namespaced Redis key with the given arguments.
|
void |
priorityEnqueue(String queue,
Job job)
Queues a job with high priority in a given queue to be run.
|
void |
removeDelayedEnqueue(String queue,
Job job)
Removes a queued future job.
|
protected AbstractClient(Config config)
config - used to get the namespace for key creationprotected String getNamespace()
protected String key(String... parts)
parts - the key parts to be joinedpublic void priorityEnqueue(String queue, Job job)
priorityEnqueue in interface Clientqueue - the queue to add the Job tojob - the job to be enqueuedpublic boolean acquireLock(String lockName, String lockHolder, int timeout)
acquireLock in interface ClientlockName - the name of the lock to acquirelockHolder - a unique string identifying the callertimeout - number of seconds until the lock will expireprotected abstract void doEnqueue(String queue, String msg) throws Exception
queue - the queue to add the Job tomsg - the serialized JobException - in case something goes wrongprotected abstract void doPriorityEnqueue(String queue, String msg) throws Exception
queue - the queue to add the Job tomsg - the serialized JobException - in case something goes wrongprotected abstract boolean doAcquireLock(String lockName, String lockHolder, int timeout) throws Exception
lockName - the name of the lock to acquiretimeout - number of seconds until the lock will expirelockHolder - a unique string identifying the callerException - in case something goes wrongpublic static void doEnqueue(redis.clients.jedis.Jedis jedis,
String namespace,
String queue,
String jobJson)
jedis - the connection to Redisnamespace - the Resque namespacequeue - the Resque queue namejobJson - the job serialized as JSONpublic static void doPriorityEnqueue(redis.clients.jedis.Jedis jedis,
String namespace,
String queue,
String jobJson)
jedis - the connection to Redisnamespace - the Resque namespacequeue - the Resque queue namejobJson - the job serialized as JSONpublic static boolean doAcquireLock(redis.clients.jedis.Jedis jedis,
String namespace,
String lockName,
String lockHolder,
int timeout)
jedis - the connection to Redisnamespace - the Resque namespacelockName - all calls to this method will contend for a unique lock with
the name of lockNametimeout - seconds until the lock will expirelockHolder - a unique string used to tell if you are the current holder of
a lock for both acquisition, and extensionpublic static void doDelayedEnqueue(redis.clients.jedis.Jedis jedis,
String namespace,
String queue,
String jobJson,
long future)
protected abstract void doDelayedEnqueue(String queue, String msg, long future) throws Exception
Exceptionpublic void delayedEnqueue(String queue, Job job, long future)
delayedEnqueue in interface Clientqueue - the queue to add the Job tojob - the job to be enqueuedfuture - timestamp when the job will runpublic static void doRemoveDelayedEnqueue(redis.clients.jedis.Jedis jedis,
String namespace,
String queue,
String jobJson)
protected abstract void doRemoveDelayedEnqueue(String queue, String msg) throws Exception
Exceptionpublic void removeDelayedEnqueue(String queue, Job job)
removeDelayedEnqueue in interface Clientqueue - the queue to remove the Job fromjob - the job to be removedCopyright © 2011-2015. All Rights Reserved.