@Override public boolean render() { Duration timeLeft = Duration.between(Instant.now(), endTime); return !timeLeft.isNegative(); }
private boolean checkExpired(Instant currentTime) { return isStarted() && !this.maxIdleTime.isNegative() && currentTime.minus(this.maxIdleTime).isAfter(this.lastAccessTime); }
/** * Sets the new duration for which to await the initialization of the suggester data. Does not affect already * running initialization. * @param awaitTerminationTime maximum duration for which to wait for initialization */ public final void setAwaitTerminationTime(final Duration awaitTerminationTime) { if (awaitTerminationTime.isNegative() || awaitTerminationTime.isZero()) { throw new IllegalArgumentException( "Time to await termination of building the suggester data cannot be 0 or negative"); } this.awaitTerminationTime = awaitTerminationTime; }
@Override public boolean isValid(final Duration duration, final ConstraintValidatorContext context) { return duration != null && !duration.isNegative() && !duration.isZero(); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getName()).append('=').append(getValue()); if (StringUtils.hasText(getPath())) { sb.append("; Path=").append(getPath()); } if (StringUtils.hasText(this.domain)) { sb.append("; Domain=").append(this.domain); } if (!this.maxAge.isNegative()) { sb.append("; Max-Age=").append(this.maxAge.getSeconds()); sb.append("; Expires="); long millis = this.maxAge.getSeconds() > 0 ? System.currentTimeMillis() + this.maxAge.toMillis() : 0; sb.append(HttpHeaders.formatDate(millis)); } if (this.secure) { sb.append("; Secure"); } if (this.httpOnly) { sb.append("; HttpOnly"); } if (StringUtils.hasText(this.sameSite)) { sb.append("; SameSite=").append(this.sameSite); } return sb.toString(); }
@Override public void setMaxInactiveInterval(Duration duration) { this.creationMetaData.setMaxInactiveInterval(duration.isNegative() ? Duration.ZERO : duration); } }
/** * Sets the idle timeout of a socket connection. The connection is closed if there is no request in * progress for this amount of time. */ public ClientFactoryBuilder idleTimeout(Duration idleTimeout) { requireNonNull(idleTimeout, "idleTimeout"); checkArgument(!idleTimeout.isNegative(), "idleTimeout: %s (expected: >= 0)", idleTimeout); return idleTimeoutMillis(idleTimeout.toMillis()); }
/** * Sets the interval between health check requests. Must be positive. */ public HttpHealthCheckedEndpointGroupBuilder retryInterval(Duration retryInterval) { requireNonNull(retryInterval, "retryInterval"); checkArgument(!retryInterval.isNegative() && !retryInterval.isZero(), "retryInterval: %s (expected > 0)", retryInterval); this.retryInterval = retryInterval; return this; }
/** * Sets the probe timeout. * * @param probeTimeout the probe timeout * @return the membership protocol configuration */ public SwimMembershipProtocolConfig setProbeTimeout(Duration probeTimeout) { checkNotNull(probeTimeout, "probeTimeout cannot be null"); checkArgument(!probeTimeout.isNegative() && !probeTimeout.isZero(), "probeTimeout must be positive"); this.probeTimeout = probeTimeout; return this; }
private boolean checkExpired(Instant currentTime) { return isStarted() && !this.maxIdleTime.isNegative() && currentTime.minus(this.maxIdleTime).isAfter(this.lastAccessTime); }
private Timeout(Duration timeout) { LettuceAssert.notNull(timeout, "Timeout must not be null"); LettuceAssert.isTrue(!timeout.isNegative(), "Timeout must be greater or equal to zero"); this.timeout = timeout; }
/** * Sets the command timeout for synchronous command execution. * * @param timeout the command timeout for synchronous command execution. * @since 5.0 */ public void setTimeout(Duration timeout) { LettuceAssert.notNull(timeout, "Timeout must not be null"); LettuceAssert.isTrue(!timeout.isNegative(), "Timeout must be greater or equal 0"); this.timeout = timeout; }
/** * Configures a timeout. * * @param timeout must not be {@literal null} or negative. * @return the builder */ public Builder withTimeout(Duration timeout) { LettuceAssert.notNull(timeout, "Timeout must not be null"); LettuceAssert.notNull(!timeout.isNegative(), "Timeout must be greater or equal 0"); this.timeout = timeout; return this; }
/** * Set the default timeout for connections created by this client. The timeout applies to connection attempts and * non-blocking commands. * * @param timeout default connection timeout, must not be {@literal null}. * @since 5.0 */ public void setDefaultTimeout(Duration timeout) { LettuceAssert.notNull(timeout, "Timeout duration must not be null"); LettuceAssert.isTrue(!timeout.isNegative(), "Timeout duration must be greater or equal to zero"); this.timeout = timeout; }
private CassandraSinkBaseConfig( int maxConcurrentRequests, Duration maxConcurrentRequestsTimeout) { Preconditions.checkArgument(maxConcurrentRequests > 0, "Max concurrent requests is expected to be positive"); Preconditions.checkNotNull(maxConcurrentRequestsTimeout, "Max concurrent requests timeout cannot be null"); Preconditions.checkArgument(!maxConcurrentRequestsTimeout.isNegative(), "Max concurrent requests timeout is expected to be positive"); this.maxConcurrentRequests = maxConcurrentRequests; this.maxConcurrentRequestsTimeout = maxConcurrentRequestsTimeout; }
@Override public void schedule(I id) { Duration timeout = this.expiration.getTimeout(); if (!timeout.isNegative()) { InfinispanEjbLogger.ROOT_LOGGER.tracef("Scheduling stateful session bean %s to expire in %s", id, timeout); Runnable task = new ExpirationTask(id); // Make sure the expiration future map insertion happens before map removal (during task execution). synchronized (task) { this.expirationFutures.put(id, this.expiration.getExecutor().schedule(task, timeout.toMillis(), TimeUnit.MILLISECONDS)); } } }
@Override public boolean render() { final boolean rendered = super.render(); if (rendered) { final Duration fromStart = Duration.between(getStartTime(), Instant.now()); return !fromStart.minus(timer.getInitialDelay()).isNegative(); } return false; }
@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new Cookie(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge((int) httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.response.addCookie(cookie); } } }
@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new CookieImpl(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge((int) httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.exchange.getResponseCookies().putIfAbsent(name, cookie); } } }
@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new DefaultCookie(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge(httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.response.addCookie(cookie); } } }