public boolean isExpired() { return expiry != null && expiry.isBefore(Instant.now()); }
public void checkIfNecessary(Instant now) { if (this.checkTime.isBefore(now)) { removeExpiredSessions(now); } }
private boolean validateIfUnmodifiedSince(Instant lastModified) { if (lastModified.isBefore(Instant.EPOCH)) { return false; } long ifUnmodifiedSince = getRequestHeaders().getIfUnmodifiedSince(); if (ifUnmodifiedSince == -1) { return false; } // We will perform this validation... Instant sinceInstant = Instant.ofEpochMilli(ifUnmodifiedSince); this.notModified = sinceInstant.isBefore(lastModified.truncatedTo(ChronoUnit.SECONDS)); return true; }
private void warnOnceAfter(Instant warningTime) { if (!warned && warningTime.isBefore(Instant.now())) { warning.run(); warned = true; } }
private void countBytesWritten(int byteCount) { this.byteCount += byteCount; Instant now = instantSupplier.get(); if (previousCallback.plus(delayBetweenCallbacks).isBefore(now)) { callByteCountConsumer(now); } }
public void checkIfNecessary(Instant now) { if (this.checkTime.isBefore(now)) { removeExpiredSessions(now); } }
private boolean validateIfModifiedSince(Instant lastModified) { if (lastModified.isBefore(Instant.EPOCH)) { return false; } long ifModifiedSince = getRequestHeaders().getIfModifiedSince(); if (ifModifiedSince == -1) { return false; } // We will perform this validation... this.notModified = ChronoUnit.SECONDS.between(lastModified, Instant.ofEpochMilli(ifModifiedSince)) >= 0; return true; }
public synchronized void waitForChange() throws InterruptedException { Instant now = Instant.now(); Instant timeoutTime = now.plus(pollDuration); Instant warningTime = now.plus(warningDelay); while (!membershipChanged && !cancelCondition.getAsBoolean() && Instant.now().isBefore(timeoutTime)) { warnOnceAfter(warningTime); wait(POLL_INTERVAL_MILLIS); } membershipChanged = false; }
public boolean isExpired() { return getExpirationTime().isBefore(Instant.now()); }
private boolean validateIfUnmodifiedSince(Instant lastModified) { if (lastModified.isBefore(Instant.EPOCH)) { return false; } long ifUnmodifiedSince = getRequestHeaders().getIfUnmodifiedSince(); if (ifUnmodifiedSince == -1) { return false; } // We will perform this validation... Instant sinceInstant = Instant.ofEpochMilli(ifUnmodifiedSince); this.notModified = sinceInstant.isBefore(lastModified.truncatedTo(ChronoUnit.SECONDS)); return true; }
protected Mono<Void> updateStatusForAllInstances() { log.debug("Updating status for all instances"); Instant expiryInstant = Instant.now().minus(statusLifetime); return Flux.fromIterable(lastQueried.entrySet()) .filter(e -> e.getValue().isBefore(expiryInstant)) .map(Map.Entry::getKey) .flatMap(this::updateStatus) .then(); }
/** * Wait until allocations are at 0, or the given duration elapses. */ protected void waitForDataBufferRelease(Duration duration) throws InterruptedException { Instant start = Instant.now(); while (Instant.now().isBefore(start.plus(duration))) { try { verifyAllocations(); break; } catch (AssertionError ex) { // ignore; } Thread.sleep(50); } }
@Override public boolean isExpired() { Duration maxInactiveInterval = this.getMaxInactiveInterval(); return !maxInactiveInterval.isZero() ? this.getLastAccessedTime().plus(maxInactiveInterval).isBefore(Instant.now()) : false; } }
private boolean validateIfModifiedSince(Instant lastModified) { if (lastModified.isBefore(Instant.EPOCH)) { return false; } long ifModifiedSince = getRequestHeaders().getIfModifiedSince(); if (ifModifiedSince == -1) { return false; } // We will perform this validation... this.notModified = ChronoUnit.SECONDS.between(lastModified, Instant.ofEpochMilli(ifModifiedSince)) >= 0; return true; }
@Override public void validate(Jwt token, Errors.Collector collector) { token.issueTime().ifPresent(it -> { // must be issued in the past if (latest().isBefore(it)) { collector.fatal(token, "Token was not issued in the past: " + it); } }); } }
@Override public void validate(Jwt token, Errors.Collector collector) { token.notBefore().ifPresent(it -> { if (latest().isBefore(it)) { collector.fatal(token, "Token not yet valid, not before: " + it); } }); } }
protected Mono<Void> sendReminders() { Instant now = Instant.now(); return Flux.fromIterable(this.reminders.values()) .filter(reminder -> reminder.getLastNotification().plus(reminderPeriod).isBefore(now)) .flatMap(reminder -> delegate.notify(reminder.getEvent()) .doOnSuccess(signal -> reminder.setLastNotification(now))) .then(); }
/** * Verifies that the actual {@code Instant} is <b>strictly</b> before the given one. * <p> * Example : * <pre><code class='java'> assertThat(parse("2007-12-03T10:15:30.00Z")).isBefore(parse("2007-12-03T10:15:31.00Z"));</code></pre> * * @param other the given {@link Instant}. * @return this assertion object. * @throws AssertionError if the actual {@code Instant} is {@code null}. * @throws IllegalArgumentException if other {@code Instant} is {@code null}. * @throws AssertionError if the actual {@code Instant} is not strictly before the given one. * @since 3.7.0 */ public SELF isBefore(Instant other) { assertNotNull(info, actual); assertInstantParameterIsNotNull(other); if (!actual.isBefore(other)) { throw Failures.instance().failure(info, shouldBeBefore(actual, other)); } return myself; }
@Override public void read(Message message) { Instant msgTime = message.getTimestamp(); assertTrue(msgTime.isAfter(startTime) || msgTime.equals(startTime)); assertNotNull(message.getSenderId()); StaticBuffer content = message.getContent(); assertTrue(content != null && content.length() > 0); TransactionLogHeader.Entry txentry = TransactionLogHeader.parse(content, serializer, times); Instant txTime = txentry.getHeader().getTimestamp(); assertTrue(txTime.isBefore(msgTime) || txTime.equals(msgTime)); assertTrue(txTime.isAfter(startTime) || txTime.equals(msgTime)); long txid = txentry.getHeader().getId(); assertTrue(txid > 0); for (TransactionLogHeader.Modification modification : txentry.getContentAsModifications(serializer)) { assertTrue(modification.state == Change.ADDED || modification.state == Change.REMOVED); userChangeCounter.get(modification.state).incrementAndGet(); } userLogMsgCounter.incrementAndGet(); } });
@Test public void lastAccessTimeIsUpdatedOnRetrieve() { WebSession session1 = this.store.createWebSession().block(); assertNotNull(session1); String id = session1.getId(); Instant time1 = session1.getLastAccessTime(); session1.start(); session1.save().block(); // Fast-forward a few seconds this.store.setClock(Clock.offset(this.store.getClock(), Duration.ofSeconds(5))); WebSession session2 = this.store.retrieveSession(id).block(); assertNotNull(session2); assertSame(session1, session2); Instant time2 = session2.getLastAccessTime(); assertTrue(time1.isBefore(time2)); }