Tabnine Logo
RedissonClient.getFairLock
Code IndexAdd Tabnine to your IDE (free)

How to use
getFairLock
method
in
org.redisson.api.RedissonClient

Best Java code snippets using org.redisson.api.RedissonClient.getFairLock (Showing top 5 results out of 315)

origin: hs-web/hsweb-framework

@Override
protected Lock createLock(String lockName) {
  return redisson.getFairLock(lockName);
}
origin: redisson/redisson-examples

public static void main(String[] args) throws InterruptedException {
  // connects to 127.0.0.1:6379 by default
  RedissonClient redisson = Redisson.create();
  
  RLock lock = redisson.getFairLock("test");
  int size = 10;
  List<Thread> threads = new ArrayList<Thread>();
  for (int i = 0; i < size; i++) {
    final int j = i;
    Thread t = new Thread() {
      public void run() {
        lock.lock();
        lock.unlock();
      };
    };
    
    threads.add(t);
  }
  
  for (Thread thread : threads) {
    thread.start();
    thread.join(5);
  }
  
  for (Thread thread : threads) {
    thread.join();
  }
}

origin: kekingcn/spring-boot-klock-starter

@Override
public boolean acquire() {
  try {
    rLock=redissonClient.getFairLock(lockInfo.getName());
    return rLock.tryLock(lockInfo.getWaitTime(), lockInfo.getLeaseTime(), TimeUnit.SECONDS);
  } catch (InterruptedException e) {
    return false;
  }
}
origin: Nepxion/Aquarius

private RLock getNewLock(LockType lockType, String key, boolean fair) {
  RedissonClient redisson = redissonHandler.getRedisson();
  switch (lockType) {
    case LOCK:
      if (fair) {
        return redisson.getFairLock(key);
      } else {
        return redisson.getLock(key);
      }
    case READ_LOCK:
      return getCachedReadWriteLock(lockType, key, fair).readLock();
      // return redisson.getReadWriteLock(key).readLock();
    case WRITE_LOCK:
      return getCachedReadWriteLock(lockType, key, fair).writeLock();
      // return redisson.getReadWriteLock(key).writeLock();
  }
  throw new AquariusException("Invalid Redis lock type for " + lockType);
}
origin: dqeasycloud/easy-cloud

/** 根据完整的锁名获取锁 */
private RLock getLock(String lockNameFull, EcLockTypeEnum lockType) {
  if (EcLockTypeEnum.isFair(lockType)) {
    return redisson.getFairLock(lockNameFull);
  } else if (EcLockTypeEnum.isUnfair(lockType)){
    return redisson.getLock(lockNameFull);
  } else if (EcLockTypeEnum.isRead(lockType)) {
    return redisson.getReadWriteLock(lockNameFull).readLock();
  } else if (EcLockTypeEnum.isWrite(lockType)) {
    return redisson.getReadWriteLock(lockNameFull).writeLock();
  }
  throw new EcBaseBusinessException(EcLockErrorCodeEnum.LOCK_TYPE_NOT_SUPPORT);
}

org.redisson.apiRedissonClientgetFairLock

Javadoc

Returns lock instance by name.

Implements a fair locking so it guarantees an acquire order by threads.

Popular methods of RedissonClient

  • shutdown
    Shuts down Redisson instance but NOT Redis server Shutdown ensures that no tasks are submitted for '
  • getMap
    Returns map instance by name using provided codec for both map keys and values.
  • getLock
    Returns lock instance by name. Implements a non-fair locking so doesn't guarantees an acquire order
  • getTopic
    Returns topic instance by name using provided codec for messages.
  • getBucket
    Returns object holder instance by name using provided codec for object.
  • getConfig
    Allows to get configuration provided during Redisson instance creation. Further changes on this obje
  • getMapCache
    Returns map-based cache instance by name using provided codec for both cache keys and values. Suppor
  • getAtomicLong
    Returns atomicLong instance by name.
  • getKeys
    Returns interface with methods for Redis keys. Each of Redis/Redisson object associated with own key
  • getScript
    Returns script operations object using provided codec.
  • getSemaphore
    Returns semaphore instance by name
  • getSet
    Returns set instance by name using provided codec for set objects.
  • getSemaphore,
  • getSet,
  • getBlockingQueue,
  • getList,
  • getScoredSortedSet,
  • getExecutorService,
  • getQueue,
  • getReadWriteLock,
  • getListMultimap

Popular in Java

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • putExtra (Intent)
  • onRequestPermissionsResult (Fragment)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Menu (java.awt)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now