Class ClusteredRedisDLock

    • Constructor Detail

      • ClusteredRedisDLock

        public ClusteredRedisDLock​(String name)
    • Method Detail

      • getRedisHostsAndPorts

        public String getRedisHostsAndPorts()
        Redis' hosts and ports scheme (format host1:port1,host2:port2,host3:port3).
        Returns:
      • setRedisHostsAndPorts

        public ClusteredRedisDLock setRedisHostsAndPorts​(String redisHostsAndPorts)
        Redis' hosts and ports scheme (format host1:port1,host2:port2,host3:port3).
        Parameters:
        redisHostsAndPorts -
        Returns:
      • buildJedisConnector

        protected com.github.ddth.commons.redis.JedisConnector buildJedisConnector()
        Specified by:
        buildJedisConnector in class BaseRedisDLock
        Returns:
        Since:
        0.1.1.2
      • getJedis

        protected redis.clients.jedis.JedisCluster getJedis()
        Returns:
      • lock

        public LockResult lock​(int waitWeight,
                               String clientId,
                               long lockDurationMs)
        Acquire the lock for clientId for a duration of lockDurationMs.

        Reentrant: lock can be acquired multiple times by the same clientId. Lock's expiry will be extended accordingly.

        Parameters:
        waitWeight - "fairness": clientId with higher waitWeight value might have higher chance to acquire the lock, negative value means "no fairness"
        clientId - within a namespace, only one client is allowed to hold the lock as a given time
        Returns:
        LockResult.SUCCESSFUL if successful, LockResult.HOLD_BY_ANOTHER_CLIENT if lock is currently hold by another client