/*
(non-Javadoc)

@see com.ibm.ws.sib.msgstore.MessageStore#expirerStop()
962598
@Override
    public final void expirerStop()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "expirerStop");

        _expirer.stop();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "expirerStop");
    }
1116411
@SuppressWarnings({"fallthrough", "PMD.MissingBreakInSwitch",
    "PMD.SwitchStmtsShouldHaveDefault", "NullAway"})
  private @Nullable Expirable<V> postProcess(Expirable<V> expirable,
      EntryProcessorEntry<K, V> entry, long currentTimeMS) {
    switch (entry.getAction()) {
      case NONE:
        if (expirable == null) {
          return null;
        } else if (expirable.isEternal()) {
          return expirable;
        }
        if (currentTimeMS == 0) {
          currentTimeMS = currentTimeMillis();
        }
        if (expirable.hasExpired(currentTimeMS)) {
          dispatcher.publishExpired(this, entry.getKey(), expirable.get());
          statistics.recordEvictions(1);
          return null;
        }
        return expirable;
      case READ: {
        setAccessExpirationTime(expirable, 0L);
        return expirable;
      }
      case CREATED:
        this.publishToCacheWriter(writer::write, () -> entry);
        // fall through
      case LOADED:
        statistics.recordPuts(1L);
        dispatcher.publishCreated(this, entry.getKey(), entry.getValue());
        return new Expirable<>(entry.getValue(), getWriteExpireTimeMS(/* created */ true));
      case UPDATED: {
        statistics.recordPuts(1L);
        publishToCacheWriter(writer::write, () -> entry);
        dispatcher.publishUpdated(this, entry.getKey(), expirable.get(), entry.getValue());
        long expireTimeMS = getWriteExpireTimeMS(/* created */ false);
        if (expireTimeMS == Long.MIN_VALUE) {
          expireTimeMS = expirable.getExpireTimeMS();
        }
        return new Expirable<>(entry.getValue(), expireTimeMS);
      }
      case DELETED:
        statistics.recordRemovals(1L);
        publishToCacheWriter(writer::delete, entry::getKey);
        dispatcher.publishRemoved(this, entry.getKey(), entry.getValue());
        return null;
    }
    throw new IllegalStateException("Unknown state: " + entry.getAction());
  }
342820
public Expiring<T> withDefault(long expireTime, TimeUnit expireUnit) {
		checkArgument(expireTime > 0);
		this.defaultExpireTime = Optional.of(expireTime);
		this.defaultExpireUnit = Optional.of(expireUnit);
		return this;
	}
503988
private DateTime credentialExpirationTime(JsonNode credentialsJson) {
        String expiration = getText(credentialsJson, "Expiration");

        if (expiration != null) {
            DateTime credentialExpiration = new DateTime(DateUtils.parseISO8601Date(expiration));
            credentialExpiration = credentialExpiration.minus(expirationBufferUnit.toMillis(expirationBufferValue));
            return credentialExpiration;
        } else {
            return DateTime.now().plusYears(9999);
        }
    }
65244
public void setExpiredEnd(Date expiredEnd) throws InvalidArgumentException {
        if (expiredEnd == null) {
            throw new InvalidArgumentException("Date can't be null");
        }
        queryParms.put("expired_end", Util.dateToString(expiredEnd));
    }
1183885
@SuppressWarnings(value="unchecked")
	public int setExpires(int deltaMinutes) {
		if(!isValid()) {
			throw new IllegalStateException("Impossible to change the sip application " +
					"session timeout when it has been invalidated !");
		}
		expired = false;
		if(logger.isDebugEnabled()) {
			logger.debug("Postponing the expiratin of the sip application session "
					+ key +" to expire in " + deltaMinutes + " minutes.");
		}
		if(deltaMinutes <= 0) {
			if(logger.isDebugEnabled()) {
				logger.debug("The sip application session "+ key +" won't expire anymore ");
			}
			// If the session timeout value is 0 or less, then an application session timer
			// never starts for the SipApplicationSession object and the container
			// does not consider the object to ever have expired
//			this.expirationTime = -1;
			if(expirationTimerTask != null) {
				cancelExpirationTimer();
				// Fix for Issue 1678 : SipApplicationSession.setExpires() doesn't work sometimes
				// the global sipApplicationSessionTimeout needs to be reset as well
				sipApplicationSessionTimeout = deltaMinutes;
			}
			return Integer.MAX_VALUE;
		} else {
			long deltaMilliseconds = 0;
//			if(expirationTimerTask != null) {
				//extending the app session life time
//				expirationTime = expirationTimerFuture.getDelay(TimeUnit.MILLISECONDS) + deltaMinutes * 1000 * 60;
				deltaMilliseconds = deltaMinutes * 1000L * 60;
//			} else {
				//the app session was scheduled to never expire and now an expiration time is set
//				deltaMilliseconds = deltaMinutes * 1000L * 60;
//			}
			// Fix for Issue 1678 : SipApplicationSession.setExpires() doesn't work sometimes
			// the global sipApplicationSessionTimeout needs to be reset as well
			sipApplicationSessionTimeout = deltaMilliseconds;
			expirationTime = System.currentTimeMillis() + deltaMilliseconds;
			if(logger.isDebugEnabled()) {
				logger.debug("Setting expirationTime to "+ expirationTime + " on sip application session " + key);
				logger.debug("Re-Scheduling sip application session "+ key +" to expire in " + deltaMinutes + " minutes");
				Calendar calendar = Calendar.getInstance();
				calendar.setTimeInMillis(expirationTime);
				logger.debug("sip application session "+ key +" will expires at " + new SimpleDateFormat().format(calendar.getTime()));
			}


			final long milisecondsToGive = deltaMilliseconds;


			//Run the timer in different transaction
			new Thread(){

				@Override
				public void run() {
					if(expirationTimerTask != null) {
						cancelExpirationTimer();
//						expirationTimerFuture = null;
					}
					expirationTimerTask = sipContext.getSipApplicationSessionTimerService().createSipApplicationSessionTimerTask(SipApplicationSessionImpl.this);
					expirationTimerTask = sipContext.getSipApplicationSessionTimerService().schedule(expirationTimerTask, milisecondsToGive, TimeUnit.MILLISECONDS);
				}

			}.start();


			return deltaMinutes;
		}
	}
1279987
public CompletableFuture<Void> expire() {
    CompletableFuture<Void> future = new CompletableFuture<>();
    context.executor().execute(() -> {
      if (keepAlive != null)
        keepAlive.cancel();
      state.setState(Session.State.EXPIRED);
      future.complete(null);
    });
    return future;
  }
786889
public long getExpirationTime() {
		if(!isValid()) {
			throw new IllegalStateException("this sip application session is not valid anymore");
		}
		if(expirationTimerTask == null) {
			return 0;
		}
		long delay = expirationTimerTask.getDelay();
		if(delay <= 0) {
			return 0;
		}
		if(expired) {
			return Long.MIN_VALUE;
		}
		return this.expirationTime;
	}
529740
private void offer(ResultStream<? super T> resultStream)
  {
    long expires = 600 * 1000L;

    try (OutboxAmp outbox = OutboxAmp.currentOrCreate(_serviceRef.services())) {
      HeadersAmp headers = HeadersNull.NULL;
    
      ResultStream<U> stream = build(resultStream);
    
      StreamCallMessage<U> msg;
      msg = new StreamCallMessage<U>(outbox, outbox.inbox(), headers,
                                     _serviceRef, _method, 
                                     stream,
                                     expires, _args);
      
      long timeout = 10000;

      msg.offer(timeout);
    }
  }
46297
@Override
  public boolean hasExpired(SlotInfo<? extends T> info) throws Exception {
    return firstExpiration.hasExpired(info)
            || secondExpiration.hasExpired(info);
  }
1304369
public boolean setExpire(long seconds) {
		if(seconds <= 0)return true;
		try {
			if(!isBinary)return getJedisCommands(groupName).expire(key, (int)seconds) == 1;
			if(isCluster(groupName)){
				return getBinaryJedisClusterCommands(groupName).expire(keyBytes, (int)seconds) == 1;
			}
			return getBinaryJedisCommands(groupName).expire(keyBytes, (int)seconds) == 1;
		} finally {
			getJedisProvider(groupName).release();
		}

	}
23958
public static <T> T get (ExpiringReference<T> value)
    {
        return (value == null) ? null : value.getValue();
    }
1257012
public static void setFirstLaunchDate(Context context, long firstLaunchDate) {
        SharedPreferences prefs = getSharedPreferences(context);
        SharedPreferences.Editor prefsEditor = prefs.edit();

        prefsEditor.putLong(PREF_KEY_APP_FIRST_LAUNCHED_DATE, firstLaunchDate);

        prefsEditor.commit();
    }
882328
private static Date getExpireAt(final Ticket ticket) {
        val expirationPolicy = ticket.getExpirationPolicy();
        val ttl = ticket instanceof TicketState
            ? expirationPolicy.getTimeToLive((TicketState) ticket)
            : expirationPolicy.getTimeToLive();

        if (ttl < 1) {
            return null;
        }

        return new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(ttl));
    }
602186
@GuardedBy("evictionLock")
  void expireAfterWriteEntries(long now) {
    if (!expiresAfterWrite()) {
      return;
    }
    long duration = expiresAfterWriteNanos();
    for (;;) {
      final Node<K, V> node = writeOrderDeque().peekFirst();
      if ((node == null) || ((now - node.getWriteTime()) < duration)) {
        break;
      }
      evictEntry(node, RemovalCause.EXPIRED, now);
    }
  }
835465
public void expire() {
        synchronized (this) {
            expired = true;
        }
        int i = loadCount.get();
        debug(String.format("expire jar provider loader for: %s (loadCount: %d)", pluginJar, i));
        if (i <= 0) {
            try {
                close();
            } catch (IOException e) {

            }
        }
    }
504253
public void setExpirationTime(long expirationTime) {
	  if (lock == SET) {
		 throw new IllegalStateException("EntryInfo is locked");
	  }
	  expirationTimeFlag = SET;
	  this.expirationTime = expirationTime;
	  this.timeLimit = (int) ((expirationTime - System.currentTimeMillis()) / 1000L);
   }