private static ReentrantLock getLockFor(String key){
    LOG.info("Finding lock for : {}", key);
    if( null == locks.get(key)){
      LOG.info("Lock not found for {} ",key);
      synchronized (locks){
        if(null == locks.get(key)){
          LOG.info("Creating lock for {} ", key);
          locks.put(key,new ReentrantLock());
        }
      }
    }

    return locks.get(key);
  }
gives the lock object for the specified key. creates if not yet created.
@param key : the key for which the lock is required.
@return : ReentrantLock for that key
contrib/views/utils/src/main/java/org/apache/ambari/view/utils/UserLocal.java