LeaseRequest( final Object state, final Timeout requestTimeout, final BasicFuture<PoolEntry<T, C>> future) { super(); this.state = state; this.deadline = Deadline.calculate(requestTimeout); this.future = future; }
LeaseRequest( final Object state, final Timeout requestTimeout, final BasicFuture<PoolEntry<T, C>> future) { super(); this.state = state; this.deadline = Deadline.calculate(requestTimeout); this.future = future; }
/** * Calculates a deadline from now plus a given time value. Non-positive time values * represent an indefinite timeout without a deadline. * * @param timeValue time value to add to {@code timeMillis}. * @return a deadline representing the current time plus the given time value. */ public static Deadline calculate(final TimeValue timeValue) { return calculate(System.currentTimeMillis(), timeValue); }
/** * Calculates a deadline from now plus a given time value. Non-positive time values * represent an indefinite timeout without a deadline. * * @param timeValue time value to add to {@code timeMillis}. * @return a deadline representing the current time plus the given time value. */ public static Deadline calculate(final TimeValue timeValue) { return calculate(System.currentTimeMillis(), timeValue); }
/** * Constructor * * @param route route * @param state state * @param requestTimeout timeout to wait in a request queue until kicked off * @param future future callback */ public LeaseRequest( final T route, final Object state, final Timeout requestTimeout, final BasicFuture<PoolEntry<T, C>> future) { super(); this.route = route; this.state = state; this.deadline = Deadline.calculate(requestTimeout); this.future = future; this.completed = new AtomicBoolean(false); }
/** * Constructor * * @param route route * @param state state * @param requestTimeout timeout to wait in a request queue until kicked off * @param future future callback */ public LeaseRequest( final T route, final Object state, final Timeout requestTimeout, final BasicFuture<PoolEntry<T, C>> future) { super(); this.route = route; this.state = state; this.deadline = Deadline.calculate(requestTimeout); this.future = future; this.completed = new AtomicBoolean(false); }
/** * @since 5.0 */ public void assignConnection(final C conn) { Args.notNull(conn, "connection"); if (this.connRef.compareAndSet(null, conn)) { this.created = getCurrentTime(); this.updated = this.created; this.validityDeadline = Deadline.calculate(this.created, this.timeToLive); this.expiryDeadline = this.validityDeadline; this.state = null; } else { throw new IllegalStateException("Connection already assigned"); } }
/** * @since 5.0 */ public void assignConnection(final C conn) { Args.notNull(conn, "connection"); if (this.connRef.compareAndSet(null, conn)) { this.created = getCurrentTime(); this.updated = this.created; this.validityDeadline = Deadline.calculate(this.created, this.timeToLive); this.expiryDeadline = this.validityDeadline; this.state = null; } else { throw new IllegalStateException("Connection already assigned"); } }
/** * @since 5.0 */ public void updateExpiry(final TimeValue expiryTime) { Args.notNull(expiryTime, "Expiry time"); final long currentTime = getCurrentTime(); final Deadline newExpiry = Deadline.calculate(currentTime, expiryTime); this.expiryDeadline = newExpiry.min(this.validityDeadline); this.updated = currentTime; }
/** * @since 5.0 */ public void updateExpiry(final TimeValue expiryTime) { Args.notNull(expiryTime, "Expiry time"); final long currentTime = getCurrentTime(); final Deadline newExpiry = Deadline.calculate(currentTime, expiryTime); this.expiryDeadline = newExpiry.min(this.validityDeadline); this.updated = currentTime; }