Class JedisKeyedBlockingQueue

java.lang.Object
org.deltafi.common.queue.jedis.JedisKeyedBlockingQueue

public class JedisKeyedBlockingQueue extends Object
A keyed blocking queue based on the Jedis client library for Redis.
  • Constructor Details

    • JedisKeyedBlockingQueue

      public JedisKeyedBlockingQueue(String url, String password, int maxIdle, int maxTotal) throws URISyntaxException
      Constructs a JedisKeyedBlockingQueue.
      Parameters:
      url - the url of the redis server
      password - the password for the redis server
      maxIdle - the maximum number of idle pooled connections to the redis server
      maxTotal - the maximum number of pooled connections to the redis server. This should be set higher than the expected number of keys in the queue.
      Throws:
      URISyntaxException - if the provided url is not valid
  • Method Details

    • put

      public void put(SortedSetEntry entry)
      Puts an object into the queue.
      Parameters:
      entry - the SortedSetEntry to add to the queue
    • exists

      public boolean exists(String key, String search)
      Check if an object exists in the queue based on the search pattern
      Parameters:
      key - the key for the object
      search - the search pattern
      Returns:
      true if the pattern exists
    • drop

      public void drop(List<String> keys)
      Drop all queues in key list.
      Parameters:
      keys - list of keys
    • put

      public void put(List<SortedSetEntry> items)
      Puts multiple objects into the queue.
      Parameters:
      items - a list of SortedSetEntry to put into the queue
    • setHeartbeat

      public void setHeartbeat(String key)
      Publish a heartbeat in the form of a timestamp
      Parameters:
      key - the name of the component publishing the heartbeat
    • take

      public String take(String key)
      Takes an object out of the queue.

      This method will block until an object for the provided key is available. When multiple objects are available for the provided key, the earliest one put into the queue is retrieved.

      Parameters:
      key - the key for the object
      Returns:
      the object value type
    • keys

      public Set<String> keys()
      Get a list of unique keys from redis
      Returns:
      the set of keys
    • sortedSetSize

      public long sortedSetSize(String key)
      Get the size of the sorted set
      Parameters:
      key - the name of the sorted set
      Returns:
      the number of elements in the sorted set
    • getLongRunningTasks

      public Map<String,String> getLongRunningTasks()
      Retrieves a map of long-running tasks
      Returns:
      a map containing the long running tasks
    • getLongRunningTask

      public String getLongRunningTask(String key)
      Retrieves the value associated with the given key from the long-running tasks
      Parameters:
      key - the key used to retrieve the value
      Returns:
      the value associated with the given key, or null if the key is not found
    • recordLongRunningTask

      public void recordLongRunningTask(String key, String value)
      Records a long running task in the long-running tasks
      Parameters:
      key - the key used to retrieve the value
      value - the value associated with the given key
    • removeLongRunningTask

      public void removeLongRunningTask(String key)
      Remove a long-running task with the specified key
      Parameters:
      key - the key of the task to be removed