Gets how long (in milliseconds) the {@link #isRegistered(Context)}
property is valid.

@return value set by {@link #setRegisteredOnServer(Context, boolean)} or
{@link #DEFAULT_ON_SERVER_LIFESPAN_MS} if not set.
972003
public static long getRegisterOnServerLifespan(Context context) {
        final SharedPreferences prefs = getGCMPreferences(context);
        long lifespan = prefs.getLong(PROPERTY_ON_SERVER_LIFESPAN,
                DEFAULT_ON_SERVER_LIFESPAN_MS);
        return lifespan;
    }
344382
public boolean isExpired()
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "isExpired");
        boolean expired = false;
        long curTime = System.currentTimeMillis();
        //TODO:
        if (curTime - _leaseTime > _leaseTimeout * 1000) //  30 seconds default for timeout
        {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Lease has EXPIRED for " + _recoveryIdentity + ", currenttime: " + curTime + ", storedTime: " + _leaseTime);
            expired = true;
        }
        else
        {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Lease has not expired for " + _recoveryIdentity + ", currenttime: " + curTime + ", storedTime: " + _leaseTime);
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "isExpired", expired);
        return expired;
    }
103128
@Override
	public Long getValue() {
		final JobStatus status = eg.getState();

		if (status == JobStatus.RUNNING) {
			// running right now - report the uptime
			final long runningTimestamp = eg.getStatusTimestamp(JobStatus.RUNNING);
			// we use 'Math.max' here to avoid negative timestamps when clocks change
			return Math.max(System.currentTimeMillis() - runningTimestamp, 0);
		}
		else if (status.isTerminalState()) {
			// not running any more -> finished or not on leader
			return NO_LONGER_RUNNING;
		}
		else {
			// not yet running or not up at the moment
			return 0L;
		}
	}
250377
@Override
   public boolean isExpired(long address) {
      // 16 bytes for eviction if needed (optional)
      // 8 bytes for linked pointer
      int offset = evictionEnabled ? 24 : 8;

      byte metadataType = MEMORY.getByte(address, offset);
      if ((metadataType & IMMORTAL) != 0) {
         return false;
      }
      // type
      offset += 1;
      // hashCode
      offset += 4;
      // key length
      int keyLength = MEMORY.getInt(address, offset);
      offset += 4;

      long now = timeService.wallClockTime();

      byte[] metadataBytes;
      if ((metadataType & CUSTOM) == CUSTOM) {
         // TODO: this needs to be fixed in ISPN-8539
         return false;
//         int metadataLength = MEMORY.getInt(address, offset);
//         metadataBytes = new byte[metadataLength];
//
//         // value and keyLength
//         offset += 4 + keyLength;
//
//         MEMORY.getBytes(address, offset, metadataBytes, 0, metadataBytes.length);
//
//         Metadata metadata;
//         try {
//            metadata = (Metadata) marshaller.objectFromByteBuffer(metadataBytes);
//            // TODO: custom metadata is not implemented properly for expiration
//            return false;
//         } catch (IOException | ClassNotFoundException e) {
//            throw new CacheException(e);
//         }
      } else {
         // value and keyLength
         offset += 4 + keyLength;

         // If it has version that means we wrote the size as well which goes after key length
         if ((metadataType & HAS_VERSION) != 0) {
            offset += 4;
         }

         switch (metadataType & 0xFC) {
            case MORTAL:
               metadataBytes = new byte[16];
               MEMORY.getBytes(address, offset, metadataBytes, 0, metadataBytes.length);
               return ExpiryHelper.isExpiredMortal(Bits.getLong(metadataBytes, 0), Bits.getLong(metadataBytes, 8), now);
            case TRANSIENT:
               metadataBytes = new byte[16];
               MEMORY.getBytes(address, offset, metadataBytes, 0, metadataBytes.length);
               return ExpiryHelper.isExpiredTransient(Bits.getLong(metadataBytes, 0), Bits.getLong(metadataBytes, 8), now);
            case TRANSIENT_MORTAL:
               metadataBytes = new byte[32];
               MEMORY.getBytes(address, offset, metadataBytes, 0, metadataBytes.length);
               long lifespan = Bits.getLong(metadataBytes, 0);
               long maxIdle = Bits.getLong(metadataBytes, 8);
               long created = Bits.getLong(metadataBytes, 16);
               long lastUsed = Bits.getLong(metadataBytes, 24);
               return ExpiryHelper.isExpiredTransientMortal(maxIdle, lastUsed, lifespan, created, now);
            default:
               return false;
         }
      }
   }
916777
@Override
    public long getHiddenExpiryTime()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(tc, "getHiddenExpiryTime");
        }

        long hiddenExpiryTime =
                        getMessageItem().getHiddenExpiryTime();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.exit(tc, "getHiddenExpiryTime", Long.valueOf(hiddenExpiryTime));
        }
        return hiddenExpiryTime;
    }
316452
@Override
  public long getDuration() {
    final long end = running.get() ? System.nanoTime() : endTime.get();
    return end - startTime.get();
  }
356487
@Override
    public long getHiddenExpiryTime()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(tc, "getHiddenExpiryTime");
            SibTr.exit(tc, "getHiddenExpiryTime", Long.valueOf(hiddenExpiryTime));
        }
        return hiddenExpiryTime;
    }
225711
def is_timed_out(self):
        
        if (self.is_expired):
            return True

        try:
            if (not self.last_access_time):
                msg = ("session.last_access_time for session with id [" +
                       str(self.session_id) + "] is null. This value must be"
                       "set at least once, preferably at least upon "
                       "instantiation. Please check the " +
                       self.__class__.__name__ +
                       " implementation and ensure self value will be set "
                       "(perhaps in the constructor?)")
                raise ValueError(msg)

            """
             Calculate at what time a session would have been last accessed
             for it to be expired at this point.  In other words, subtract
             from the current time the amount of time that a session can
             be inactive before expiring.  If the session was last accessed
             before this time, it is expired.
            """
            if self.is_absolute_timed_out:
                return True

            if self.is_idle_timed_out:
                return True

        except AttributeError:
            msg2 = ("Timeouts not set for session with id [" +
                    str(self.session_id) + "]. Session is not considered "
                    "expired.")
            logger.debug(msg2)

        return False
1325167
@Override
    public boolean checkSessionStillValid(ISession s, long accessedTime) {
        final String methodName = "checkSessionStillValid";
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[CHECK_SESSION_STILL_VALID]);
        }
        long nowTime = System.currentTimeMillis();
        boolean rc = true;
        synchronized (s) {
            if (s.isValid()) {
                if (s.getMaxInactiveInterval() != -1) {
                    long maxinact = 1000 * (long) s.getMaxInactiveInterval();
                    boolean active = s.getRefCount() > 0;
                    if (_isApplicationSessionStore) {
                        //the RefCount is not correct when dealing with an applicationSessionStore
                        s.setRefCount(0);
                        active = false;
                    }
                    boolean timedOut = (accessedTime <= nowTime - maxinact);
                    /*
                     * invalidate if:
                     * session has timedOut AND (is not active OR (the Invalidation Multiple has not been set to 0
                     * and the session is that many times the invalidation interval)
                     * 
                     * The default value for the invalidation interval is 3.
                     * 
                     * PK03711 removed check for active and always invalidated timedout sessions for v6.1 and earlier
                     * v7 CTS defect 391577 forced us to put this code back, so we introduced the InvalidateIfActive property
                     * In the service stream, the ForceSessionInvalidationMultiple was used, so we are using the same property
                     */
                    if ((timedOut) && ((!active) ||
                            ((_smc.getForceSessionInvalidationMultiple() != 0) &&
                                    (accessedTime <= nowTime - (_smc.getForceSessionInvalidationMultiple() * maxinact))))) {
                        if (maxinact != 0) {
                            _storeCallback.sessionInvalidatedByTimeout(s);
                        }
                        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                            String message = "Going to invalidate session with id=" + s.getId();
                            LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[CHECK_SESSION_STILL_VALID], message);
                        }
                        s.invalidate();
                        rc = false;
                    }
                }
            } else { //isValid
                rc = false;
            }
        }
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[CHECK_SESSION_STILL_VALID]);
        }
        return rc;
    }
901707
public boolean isPreviewSessionExpired(){
        Long urlCreationTime = getUrlCreationTime();
        if (urlCreationTime == null){
            return true;
        }
        return (System.currentTimeMillis() - urlCreationTime) < (60 * 60 * 1000);
    }
124639
boolean expiringSoon(TokenInfo info) {
        // TODO(jasonhall): Consider varying the definition of "soon" based on the
        // original expires_in value (e.g., "soon" = 1/10th of the total time before
        // it's expired).
        return Double.valueOf(info.getExpires()) < (clock.now() + TEN_MINUTES);
    }
178392
final public boolean isSingleServer() {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "isSingleServer");
        if (!_singleServerSet) {
            JsAdminService service = JsMainAdminComponentImpl.getJsAdminService();
            if (service.isInitialized())
                _isSingleServer = service.isStandaloneServer();
            else
                // If admin service isn't initialised, then assume we are single
                // service.
                _isSingleServer = true;

            _singleServerSet = true;
        }

        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "isSingleServer", new Boolean(_isSingleServer));
        return _isSingleServer;
    }
426001
public boolean expired(int expiration) {
        if (null == cliContext) {
            return true;
        }
        if ((daemon || cliContext.inProgress()) && !cliContext.disconnected()) {
            return false;
        }
        long l = expiration * 1000;
        return l < ($.ms() - ts);
    }
605280
boolean detectAndHandleBackupTimeout(long timeoutMillis) {
        // if the backups have completed, we are done; this also filters out all non backup-aware operations
        // since the backupsAcksExpected will always be equal to the backupsAcksReceived
        boolean backupsCompleted = backupsAcksExpected == backupsAcksReceived;
        long responseReceivedMillis = pendingResponseReceivedMillis;

        // if this has not yet expired (so has not been in the system for a too long period) we ignore it
        long expirationTime = responseReceivedMillis + timeoutMillis;
        boolean timeout = expirationTime > 0 && expirationTime < Clock.currentTimeMillis();

        // if no response has yet been received, we we are done; we are only going to re-invoke an operation
        // if the response of the primary has been received, but the backups have not replied
        boolean responseReceived = pendingResponse != VOID;

        if (backupsCompleted || !responseReceived || !timeout) {
            return false;
        }

        if (shouldFailOnIndeterminateOperationState()) {
            complete(new IndeterminateOperationStateException(this + " failed because backup acks missed."));
            return true;
        }

        boolean targetDead = context.clusterService.getMember(targetAddress) == null;
        if (targetDead) {
            // the target doesn't exist, so we are going to re-invoke this invocation;
            // the reason for the re-invocation is that otherwise it's possible to lose data,
            // e.g. when a map.put() was done and the primary node has returned the response,
            // but has not yet completed the backups and then the primary node fails;
            // the consequence would be that the backups are never be made and the effects of the map.put() will never be visible,
            // even though the future returned a value;
            // so if we would complete the future, a response is sent even though its changes never made it into the system
            resetAndReInvoke();
            return false;
        }

        // the backups have not yet completed, but we are going to release the future anyway if a pendingResponse has been set
        complete(pendingResponse);
        return true;
    }
338940
public static String getRegistrationId(Context context) {
        final SharedPreferences prefs = getGcmPreferences(context);
        final String registrationId = prefs.getString(PROPERTY_REG_ID, "");
        if (registrationId.isEmpty()) {
            Logger.d("Registration not found.");
            return "";
        }
        // Check if app was updated; if so, it must clear the registration ID
        // since the existing regID is not guaranteed to work with the new
        // app version.
        final int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
        final int currentVersion = GcmUtils.getAppVersion(context);
        if (registeredVersion != currentVersion) {
            Logger.d("App version changed.");
            return "";
        }
        return registrationId;
    }
90810
public static RegisteredService getRegisteredService(final RequestContext context) {
        return context != null ? (RegisteredService) context.getFlowScope().get(PARAMETER_REGISTERED_SERVICE) : null;
    }
159658
@Override
  public boolean isIdleAlmostExpired(long delta)
  {
    long now = CurrentTime.currentTime();

    return (_pool.getLoadBalanceIdleTime() < now - _idleStartTime + delta);
  }