public abstract class AbstractClient extends Object implements Client
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClient(Config config) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquireLock(String lockName,
String lockHolder,
Integer timeout)
A non blocking lock utilizing Redis to create a lock that can be utilized by distributed servers.
|
static boolean |
doAcquireLock(redis.clients.jedis.Jedis jedis,
String namespace,
String lockName,
String lockHolder,
Integer timeout)
Helper method that encapsulates the logic to acquire a lock.
|
protected abstract boolean |
doAcquireLock(String lockName,
String lockHolder,
Integer timeout)
Actually acquire the lock based upon the client acquisition model
|
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.
|
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.
|
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 enqueue(String queue, Job job)
Clientpublic void priorityEnqueue(String queue, Job job)
ClientpriorityEnqueue in interface Clientqueue - the queue to add the Job tojob - the job to be enqueuedpublic boolean acquireLock(String lockName, String lockHolder, Integer timeout)
ClientacquireLock in interface ClientlockName - all calls to this method will contend for a unique lock with the name of lockNamelockHolder - a unique string used to tell if you are the current holder of a lock for both acquisition, and extensiontimeout - 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, Integer timeout) throws Exception
lockName - 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 extensionExceptionpublic 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,
Integer 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 extensionCopyright © 2011-2013. All Rights Reserved.