private boolean tryAcquire(long timeout, TimeUnit unit) {
    // First shot without waiting.
    try {
      if (underlying.tryLock(0, unit)) {
        LOG.debug(LOCK_ACQUIRED_MSG);
        return acquired();
      }
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      LOG.debug("Interrupted Exception ignored", e);
      return failedToAcquire();
    }

    // If the first shot fails, then we log the waiting messages.
    if (LOG.isDebugEnabled()) {
      LOG.debug(WAIT_LOCK_ACQUIRE_MSG + command);
    }

    if (timeout > 0) {
      try {
        if (!underlying.tryLock(timeout, unit)) {
          LOG.error(ErrorMsg.COMPILE_LOCK_TIMED_OUT.getErrorCodedMsg() + ": " + command);
          return failedToAcquire();
        }
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        LOG.debug("Interrupted Exception ignored", e);
        return failedToAcquire();
      }
    } else {
      underlying.lock();
    }

    LOG.debug(LOCK_ACQUIRED_MSG);
    return acquired();
  }
Acquires the compile lock. If the compile lock wait timeout is configured,
it will acquire the lock if it is not held by another thread within the given
waiting time.

@return {@code true} if the lock was successfully acquired,
or {@code false} if compile lock wait timeout is configured and
either the waiting time elapsed before the lock could be acquired
or the current thread was interrupted.
ql/src/java/org/apache/hadoop/hive/ql/lock/CompileLock.java