Time for failed locks. Under normal circumstances the lock column will be
deleted. If not then this lock column will remain and the row will remain
locked. The lock will expire after this timeout.

@param timeout
@param unit
@return
494984
public OneStepDistributedRowLock<K, C> expireLockAfter(long timeout, TimeUnit unit) {
        this.timeout      = timeout;
        this.timeoutUnits = unit;
        return this;
    }
663257
public static boolean lock(CacheConfigBean cacheConfigBean, String key, Object valueObj, int expireTimeInSecond, long timeOutInSecond) {
        final LockData lockData = LOCK_THREAD_DATA.get();
        if (lockData != null) {
            lockData.getLockCount().incrementAndGet();
            return true;
        }

        long startNano = System.nanoTime();

        // 重试间隔等待时间
        final int retryAwait = (int) timeOutInSecond * 1000 / TRY_NUM;

        int autoIncrementTryNum = 0;
        do {
            autoIncrementTryNum++;

            String result = "nil";
            try (Jedis jedis = Redis.useDataSource(cacheConfigBean).getResource()) {
                if (jedis != null)
                    result = ObjectCacheOperate.set(jedis, key, valueObj, "EX", expireTimeInSecond, "NX");
            } catch (Exception e) {
                LOG.error(e);
            }

            if (!EnvUtil.getEnv().equals(EnvUtil.PRODUCTION))
                LOG.info(String.format("SET %s \"%s\" EX %s NX = result: %s, 第 %s 次尝试", key, valueObj, expireTimeInSecond, result, autoIncrementTryNum));

            if ("OK".equals(result)) {
                LOCK_THREAD_DATA.set(new LockData(key, FormatUtil.formatValue(valueObj)));

                if (!EnvUtil.getEnv().equals(EnvUtil.PRODUCTION)) {
                    long endNano = System.nanoTime();
                    long consumeTime = (endNano - startNano) / 1000000;
                    LOG.info(String.format("key: %s, 分布式加锁, 尝试次数： %s, 累计耗时: %s 纳秒", key, autoIncrementTryNum, consumeTime));
                }

                return true;
            }

            if (!EnvUtil.getEnv().equals(EnvUtil.PRODUCTION))
                LOG.info(String.format("key: %s, 分布式加锁, 目前尝试次数: %s, 暂停: %s 毫秒后继续尝试", key, autoIncrementTryNum, retryAwait));

            LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(retryAwait));

        } while (autoIncrementTryNum < TRY_NUM);

        return false;
    }
1210765
protected TimeoutId requestTimeout(final long delay, final TimeUnit unit, @Nullable final Object data) {
        return requestTimeout(delay, unit, null, data);
    }
919434
@Override
    public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
        V v = super.get(timeout, unit);
        this.mergeWorkerTracyTheadContext();
        return v;
    }
1288985
public static boolean sleep(Number timeout, TimeUnit timeUnit) {
		try {
			timeUnit.sleep(timeout.longValue());
		} catch (InterruptedException e) {
			return false;
		}
		return true;
	}
261161
public void setTimeout(long timeout, TimeUnit unit)
    {
        this.timeout = TimeUnit.MILLISECONDS.convert(timeout, unit);
    }
408731
public synchronized void timeoutTransaction(boolean initial) {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "timeoutTransaction", initial);

        if (tc.isEventEnabled())
            Tr.event(tc, "(SPI) Transaction TIMEOUT occurred for TX: " + getLocalTID());

        _timedOut = true; // mark
        _rollbackOnly = true; // for the case of server quiesce?

        // inactivity timeout may have happened ... check status
        if (_status.getState() == TransactionState.STATE_ACTIVE) {
            // If there is no txn timeout, or we are into completion phase the timeout setting may be zero
            if (_timeout == 0)
                _timeout = 10;
            TimeoutManager.setTimeout(this, TimeoutManager.REPEAT_TIMEOUT, _timeout);
        }

        // Story 132693: JDBC4.1 allows connections to be aborted. Only call abort on the initial
        // call, not on retries.
        if (initial)
            abortTransactionParticipants();

        if (tc.isEntryEnabled())
            Tr.exit(tc, "timeoutTransaction");
    }
879249
public Reason wait(T waiter, long timeout, TimeUnit unit)
    {
        if (list == null)
        {
            return Reason.Release;
        }
        try
        {
            Locks.locked(lock, waiter, (w)->{list.add(w);});
            if (semaphore.tryAcquire(timeout, unit))
            {
                return Reason.Release;
            }
            else
            {
                list.remove(waiter);
                return Reason.Timeout;
            }
        }
1220818
public TransportConfigurationBuilder initialClusterTimeout(long initialClusterTimeout, TimeUnit unit) {
      attributes.attribute(INITIAL_CLUSTER_TIMEOUT).set(unit.toMillis(initialClusterTimeout));
      return this;
   }
612247
public static Timeout max(Timeout... timeouts)
	{
		Timeout max = null;

		for (Timeout timeout : timeouts)
		{
			if (timeout != null)
				if (max == null || max.getMilliseconds() < timeout.getMilliseconds())
					max = timeout;
		}

		if (max != null)
			return max;
		else
			throw new IllegalArgumentException("Must specify at least one non-null timeout!");
	}
988013
public ConverterServerBuilder requestTimeout(long timeout, TimeUnit unit) {
        assertNumericArgument(timeout, true);
        this.requestTimeout = unit.toMillis(timeout);
        return this;
    }
840292
public ConverterServerBuilder processTimeout(long processTimeout, TimeUnit timeUnit) {
        assertNumericArgument(processTimeout, false);
        this.processTimeout = timeUnit.toMillis(processTimeout);
        return this;
    }
1345710
public void await(long weight, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
        try {
            lock.lockInterruptibly();
            while (isPermit(weight) == false) {
                condition.await(timeout, unit);
            }
        } finally {
            lock.unlock();
        }
    }
644600
public SleepBuilder<T> withTimeout(long timeout, TimeUnit timeUnit) {
        this.timeout = timeUnit.toMillis(timeout);
        return this;
    }
53067
public long waitForZkTxId(long zkTxId, Object timeout)
    throws TimeoutException, InterruptedException
  {
    long endTime = ClockUtils.toEndTime(clock, timeout);

    synchronized(_lock)
    {
      while(_lastZkTxId < zkTxId)
      {
        ConcurrentUtils.awaitUntil(clock, _lock, endTime);
      }

      return _lastZkTxId;
    }
  }
891914
public static void sleep(long time, TimeUnit unit) {
        try {
            if (time <= 0 || unit == null) {
                return;
            }

            Thread.sleep(unit.toMillis(time));
        } catch (InterruptedException e) {
            log.warn("时间参数不正确或者线程被中断，线程将不会睡眠");
            throw new RuntimeException(e);
        }
    }
1086084
public synchronized boolean lock(ActivityLog log, long maxWait, TimeUnit unit) throws Exception
    {
        if ( ownsTheLock )
        {
            throw new IllegalStateException("Already locked");
        }

        lockStartMs = System.currentTimeMillis();

        key = lockPrefix + lockKeySeparator + newRandomSequence();

        long        startMs = System.currentTimeMillis();
        boolean     hasMaxWait = (unit != null);
        long        maxWaitMs = hasMaxWait ? TimeUnit.MILLISECONDS.convert(maxWait, unit) : Long.MAX_VALUE;
        Preconditions.checkState(maxWaitMs >= settlingMs, String.format("The maxWait ms (%d) is less than the settling ms (%d)", maxWaitMs, settlingMs));

        createFile(key, content.getBytes());

        for(;;)
        {
            checkUpdate();
            if ( ownsTheLock )
            {
                break;
            }
            long        thisWaitMs;
            if ( hasMaxWait )
            {
                long        elapsedMs = System.currentTimeMillis() - startMs;
                thisWaitMs = maxWaitMs - elapsedMs;
                if ( thisWaitMs <= 0 )
                {
                    log.add(ActivityLog.Type.ERROR, String.format("Could not acquire lock within %d ms, polling: %d ms, key: %s", maxWaitMs, pollingMs, key));
                    break;
                }
            }
            else
            {
                thisWaitMs = pollingMs;
            }
            wait(Math.min(pollingMs, thisWaitMs));
        }
        return ownsTheLock;
    }