Verifies that the given timeout is valid

@param timeout
430987
public static void validateTimeout(Duration timeout) {
		if(timeout.equals(Duration.ZERO)) {
			String message = "The timeout must be nonzero";
			throw new IllegalArgumentException(message);
		}
	}
1092748
private void timeoutHasExpired(final Timeout timeout, final TimeoutExpirationContext context) {
        try {
            addMessage(timeout, context.getOriginalHeaders());
        } catch (Exception ex) {
            LOG.error("Error handling timeout {}", timeout, ex);
        }
    }
840936
@Override
    protected void checkForTimeouts() {
        final boolean bTrace = TraceComponent.isAnyTracingEnabled();

        // See if anything may have timed out
        final long now = super.currentTime;
        if (now < nextTimeoutTime) {
            if (bTrace && tc.isDebugEnabled()) {
                Tr.debug(this, tc, "checkForTimeouts bypassing timeout processing");
            }
            return;
        }

        Set<SelectionKey> selectorKeys = selector.keys();
        if (bTrace && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "checkForTimeouts - checking " + selectorKeys.size() + " keys for timeouts");
        }
        if (selectorKeys.isEmpty()) {
            // if this isn't the primary (first) selector, see if it should be closed
            if (countIndex > 0) {
                // if we have already been waiting, and still no keys, and this
                // isn't the primary selector, we should close this
                if (waitingToQuit) {
                    quit = true;
                } else {
                    wqm.updateCount(countIndex, WorkQueueManager.CS_DELETE_IN_PROGRESS, channelType);
                    waitingToQuit = true;
                    nextTimeoutTime = now + TCPFactoryConfiguration.getChannelSelectorWaitToTerminate();
                }
            } else {
                nextTimeoutTime = now + TCPFactoryConfiguration.getChannelSelectorIdleTimeout();
            }
        } else {
            waitingToQuit = false;
            // go through requests, timing out those that need it, and calculating new
            // timeout
            // set nexttimeouttime to whatever the selectoridletimeout is, and work
            // back from there
            nextTimeoutTime = now + TCPFactoryConfiguration.getChannelSelectorIdleTimeout();
            for (SelectionKey key : selectorKeys) {
                try {
                    if (key.interestOps() <= 0) {
                        // skip if not waiting on read/writes
                        continue;
                    }
                    TCPBaseRequestContext req = (TCPBaseRequestContext) key.attachment();
                    if (!req.hasTimeout()) {
                        // skip if read/write does not have a timeout
                        continue;
                    }
                    if (req.getTimeoutTime() <= now) {
                        if (bTrace && tc.isEventEnabled()) {
                            Tr.event(this, tc, "Inactivity timeout on channel " + req.getTCPConnLink().getSocketIOChannel().getChannel());
                        }

                        // create timeout exception to pass to callback error method
                        // Add local and remote address information
                        String ioeMessage = "Socket operation timed out before it could be completed";
                        try {
                            SocketAddress iaLocal = req.getTCPConnLink().getSocketIOChannel().getSocket().getLocalSocketAddress();
                            SocketAddress iaRemote = req.getTCPConnLink().getSocketIOChannel().getSocket().getRemoteSocketAddress();
                            ioeMessage = ioeMessage + " local=" + iaLocal + " remote=" + iaRemote;
                        } catch (Exception x) {
                            // do not alter the message if the socket got nuked while we tried to look at it
                        }
                        IOException e = new SocketTimeoutException(ioeMessage);

                        if (wqm.dispatch(req, e)) {
                            // reset interest ops so selector won't fire again for this key
                            key.interestOps(0);
                        } else {
                            // try again in another second
                            nextTimeoutTime = now;
                        }
                    } else {
                        // adjust times for 1 second granularity of ApproxTime
                        if (req.getTimeoutTime() < nextTimeoutTime) {
                            nextTimeoutTime = req.getTimeoutTime();
                        }
                    }
                } catch (CancelledKeyException cke) {
                    // either we didn't get the key, or we already dispatched the
                    // error. In either case, there is nothing more to do
                    continue;
                }
            } // end-key-loop
        }
    }
1164076
public void waitUntilComplete(long timeout) {
        long base=System.currentTimeMillis();
        long now=0;
        lock.lock();
        try {
            while(processing || count.get() > 0) {
                long delay=timeout-now;
                if(delay <= 0)
                    break;
                try {
                    processing_done.await(delay, TimeUnit.MILLISECONDS);
                    now=System.currentTimeMillis()-base;
                }
                catch(InterruptedException e) {
                }
            }
        }
        finally {
            lock.unlock();
        }
    }
21626
private static boolean isRpcTimeout(Annotation[] annotations) {
		for (Annotation annotation : annotations) {
			if (annotation.annotationType().equals(RpcTimeout.class)) {
				return true;
			}
		}

		return false;
	}
434489
@CanIgnoreReturnValue
  @Override
  public <T> T callWithTimeout(
      Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible)
      throws Exception {
    checkNotNull(callable);
    checkNotNull(timeoutUnit);
    checkArgument(timeoutDuration > 0, "timeout must be positive: %s", timeoutDuration);
    Future<T> future = executor.submit(callable);
    try {
      if (amInterruptible) {
        try {
          return future.get(timeoutDuration, timeoutUnit);
        } catch (InterruptedException e) {
          future.cancel(true);
          throw e;
        }
      } else {
        return Uninterruptibles.getUninterruptibly(future, timeoutDuration, timeoutUnit);
      }
    } catch (ExecutionException e) {
      throw throwCause(e, true);
    } catch (TimeoutException e) {
      future.cancel(true);
      throw new UncheckedTimeoutException(e);
    }
  }
138770
void timeout() {
    long time = System.currentTimeMillis();
    Iterator<Map.Entry<Long, ContextualFuture>> iterator = responseFutures.entrySet().iterator();
    while (iterator.hasNext()) {
      ContextualFuture future = iterator.next().getValue();
      if (future.time + requestTimeout < time) {
        iterator.remove();
        future.context.executor().execute(() -> future.completeExceptionally(new TimeoutException("request timed out")));
      } else {
        break;
      }
    }
  }
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!");
	}
659343
public AndroidRemoveApplicationOptions withTimeout(Duration timeout) {
        checkArgument(!checkNotNull(timeout).isNegative(),
                "The timeout value cannot be negative");
        this.timeout = timeout;
        return this;
    }
306800
private long getTimeoutMillis(String type, Duration timeout) {
    return timeout != null ? timeout.toMillis() : computeTimeoutMillis(type);
  }
1202956
private void checkPotentiallyTimedOutConnection() {
    boolean stillCheckingTimeouts = true;
    while (stillCheckingTimeouts) {
      try {
        for (SelectionKey sk : selector.keys()) {
          MemcachedNode mn = (MemcachedNode) sk.attachment();
          if (mn.getContinuousTimeout() > timeoutExceptionThreshold) {
            getLogger().warn("%s exceeded continuous timeout threshold", sk);
            lostConnection(mn);
          }
        }
        stillCheckingTimeouts = false;
      } catch(ConcurrentModificationException e) {
        getLogger().warn("Retrying selector keys after "
          + "ConcurrentModificationException caught", e);
        continue;
      }
    }
  }
384042
@Override
    public void validate() {
        //validate the parameters
        String target = getTargetName();
        if (maxRetries() < -1) {

            throw new FaultToleranceDefinitionException(Tr.formatMessage(tc, "retry.parameter.invalid.value.CWMFT5010E", "maxRetries", maxRetries(), target, "-1"));
        }
        if ((delay() < 0)) {

            throw new FaultToleranceDefinitionException(Tr.formatMessage(tc, "retry.parameter.invalid.value.CWMFT5010E", "delay", delay(), target, "0"));
        }
        if ((jitter() < 0)) {

            throw new FaultToleranceDefinitionException(Tr.formatMessage(tc, "retry.parameter.invalid.value.CWMFT5010E", "jitter", jitter(), target, "0"));
        }
        if (maxDuration() < 0) {

            throw new FaultToleranceDefinitionException(Tr.formatMessage(tc, "retry.parameter.invalid.value.CWMFT5010E", "maxDuration", maxDuration(), target, "0"));
        }
        if (maxDuration() != 0) {
            Duration maxDuration = Duration.of(maxDuration(), durationUnit());
            Duration delay = Duration.of(delay(), delayUnit());
            if (maxDuration.compareTo(delay) < 0) {
                throw new FaultToleranceDefinitionException(Tr.formatMessage(tc, "retry.parameter.invalid.value.CWMFT5017E", maxDuration(), durationUnit(), target,
                                                                             delay(),
                                                                             delayUnit()));

            }
        }
        if (tc.isWarningEnabled()) {
            if ((delay() != 0) && (jitter() != 0)) {
                Duration jitter = Duration.of(jitter(), jitterDelayUnit());
                Duration delay = Duration.of(delay(), delayUnit());
                if (jitter.compareTo(delay) >= 0) {
                    Tr.warning(tc, "retry.parameter.invalid.value.CWMFT5019W", jitter(), jitterDelayUnit(), target,
                               delay(),
                               delayUnit());

                }
            }
        }
    }
875395
public static Timeout sum(Timeout... timeouts)
	{
		long sum = 0;

		for (Timeout timeout : timeouts)
			if (timeout != null)
				sum += timeout.getMilliseconds();

		if (sum != 0)
			return new Timeout(sum);
		else
			return Timeout.ZERO;
	}
300680
@Override
  public void setTimeout(int timeout) throws SocketException {
    lock.lock();
    try {
      this.socket.setSoTimeout(timeout);
    } finally {
      lock.unlock();
    }
  }
495694
public boolean connect(long timeout) {
    if (this.wmi.connect(timeout)) {
      this.wmi.setStayConnected(true);
//      this.isReady = true;
      return true;
    }
    return false;
  }
1244885
public void internalInvalidate(boolean timeoutOccurred) {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[INTERNAL_INVALIDATE], appNameAndIdString);
        }
        //if it's not valid, just return
        if (_isValid) {
            //sets the Thread's context (classLoader) so that we can handle app specific listeners
            try {
                _store.setThreadContext();
                // PM11279: Call callInvalidateFromInternalInvalidate, which is overridden in MTMSesion
                callInvalidateFromInternalInvalidate();
                if (timeoutOccurred) {
                    _storeCallback.sessionInvalidatedByTimeout(this);
                }
            } finally {
                _store.unsetThreadContext();
            }
        }
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[INTERNAL_INVALIDATE]);
        }
    }
137696
public static function setTimeout($timeout = 60) {
        if (!is_int($timeout) || $timeout < 0) {
            return false;
        }

        self::$timeout = $timeout;
        return true;
    }