Check if the pool is starving now or not
@param now current timestampe
@return true if the pool is starving now, false otherwise
516080
public boolean isStarving(long now) {
    double starvingShare = getShare() * shareStarvingRatio;
    if (getGranted() >= Math.ceil(starvingShare)) {
      lastTimeAboveStarvingShare = now;
    }

    if (getGranted() >= Math.min(getShare(), getMinimum())) {
      lastTimeAboveMinimum = now;
    }
    if (now - lastPreemptTime < getMinPreemptPeriod()) {
      // Prevent duplicate preemption
      return false;
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("Pool:" + getName() +
          " lastTimeAboveMinimum:" + lastTimeAboveMinimum +
          " lastTimeAboveStarvingShare:" + lastTimeAboveStarvingShare +
          " minimumStarvingTime:" + getMinimumStarvingTime(now) +
          " shareStarvingTime:" + getShareStarvingTime(now) +
          " starvingTime:" + getStarvingTime(now));
    }
    if (getMinimumStarvingTime(now) >= 0) {
      LOG.info("Pool:" + getName() + " for type:" + getType() +
          " is starving min:" + getMinimum() +
          " granted:" + getGranted());
      lastPreemptTime = now;
      return true;
    }
    if (getShareStarvingTime(now) >= 0) {
      LOG.info("Pool:" + getName() + " for type:" + getType() +
          " is starving share:" + getShare() +
          " starvingRatio:" + shareStarvingRatio +
          " starvingShare:" + starvingShare +
          " granted:" + getGranted());
      lastPreemptTime = now;
      return true;
    }
    return false;
  }
1099683
public boolean isEmpty()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
    {
      SibTr.entry(this, tc, "isEmpty");
      SibTr.exit(tc, "isEmpty", new Object[] {Boolean.valueOf(streamSets.isEmpty()), 
          Boolean.valueOf(flushedStreamSets.isEmpty()),streamSets, this});
    }

    // Don't report empty until any pending flushes have completed.
    // Otherwise we may run into a race with an async delete thread
    // for the destination.
    return (streamSets.isEmpty() && flushedStreamSets.isEmpty());
  }
1129016
public boolean isNewerThan(Value other) {
    if (other == null) {
      return true;
    }
    return this.timestamp.isNewerThan(other.timestamp);
  }
234279
@Override
  public boolean isModified()
  {
    long now = CurrentTime.currentTime();
    long lastCheckTime = _lastCheckTime.get();
    
    if (now <= lastCheckTime + _checkInterval) {
      return _isModified;
    }

    if (! _lastCheckTime.compareAndSet(lastCheckTime, now)) {
      return _isModified;
    }

    if (isModifiedImpl()) {
      _isModified = true;
      //_lastCheckTime.set(0);
    }
    else {
      _isModified = false;
    }

    return _isModified;
  }
1293708
boolean canBeSpeculated(long currentTime) {
    if (skipping || !isRunnable() || !isRunning() || 
        completes != 0 || isOnlyCommitPending() ||
        activeTasks.size() > MAX_TASK_EXECS) {
      if (isMapTask() ? job.shouldLogCannotspeculativeMaps() :
            job.shouldLogCannotspeculativeReduces()) {
           LOG.info("Task "+ getTIPId() + " cannot be speculated because of " 
               + "skipping = "+ skipping + " isRunnable() = "+ isRunnable() 
               + " isRunning() = "+ isRunning() + " completes = " + completes
               + " isOnlyCommitPending() = "+ isOnlyCommitPending()  
               + " activetask-size = "+ activeTasks.size() 
               + " MAX_TASK_EXECS = " + MAX_TASK_EXECS);
      }
      return false;
    }

    if (isSpeculativeForced()) {
      return true;
    }

    // no speculation for first few seconds
    if (currentTime - lastDispatchTime < speculativeLag) {
      if (isMapTask() ? job.shouldLogCannotspeculativeMaps() :
            job.shouldLogCannotspeculativeReduces()) {
           LOG.info("Task "+ getTIPId() + " cannot be speculated because of "
               + "no speculation for first few seconds");
      }
      return false;
    }

    // if the task is making progress fast enough to complete within
    // the acceptable duration allowed for each task - do not speculate
    if ((maxProgressRateForSpeculation > 0) &&
        (progressRate > maxProgressRateForSpeculation)) {
      if (isMapTask() ? job.shouldLogCannotspeculativeMaps() :
            job.shouldLogCannotspeculativeReduces()) {
           LOG.info("Task "+ getTIPId() +" cannot be speculated because "
               + "the task progress rate is fast enough to complete."
               + " maxProgressRateForSpeculation = " 
               + maxProgressRateForSpeculation
               + " and progressRate = " + progressRate);
      }
      return false;
    }

    if (isMapTask() ? job.shouldSpeculateAllRemainingMaps() :
                      job.shouldSpeculateAllRemainingReduces()) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Speculate " + getTIPId() +
            " because the job is almost finished");
      }
      return true;
    }
    if (useProcessingRateForSpeculation) {
      return canBeSpeculatedUsingProcessingRate(currentTime);
    } else {
      return canBeSpeculatedUsingProgressRate(currentTime);
    }
  }
59696
boolean hasValidTimes() {

        if ((getEnd() > 0L) && (getEnd() < System.currentTimeMillis())) {
            return false;
        }

        return ((getEnd() == 0) | (getStart() == 0)) || (getEnd() >= getStart());
    }
1166280
public boolean hasExpired()
    {
        if ( expiresAt == null ) {
            LOGGER.debug( "hasExpired - token is not expirable" );
            return false;
        }

        long now = System.currentTimeMillis();
        if ( LOGGER.isDebugEnabled() ) {
            LOGGER.debug( "hasExpired? - now: {} expiredAt: {} ", new Date( now ), expiresAt );
        }
        return now > expiresAt.getTime();
    }
1241110
private boolean checkCache() {
        if (this.cacheValid) {
            long now = System.nanoTime();
            if ((now - this.cacheExpiryTime) > 0) {
                this.cacheValid = false;
            }
        }
        return this.cacheValid;
    }
455063
@SuppressWarnings("ShortCircuitBoolean")
  boolean hasExpired(Node<K, V> node, long now) {
    return (expiresAfterAccess() && (now - node.getAccessTime() >= expiresAfterAccessNanos()))
        | (expiresAfterWrite() && (now - node.getWriteTime() >= expiresAfterWriteNanos()))
        | (expiresVariable() && (now - node.getVariableTime() >= 0));
  }
1252883
protected function isTimestampValid($time, $now = null)
    {
        if (empty($now)) {
            $now = $this->getCurrentTimestamp();
        }

        return $time <= $now
            && $time > $now - 20 * 365 * 86400;
    }
792748
public boolean checkCondition() {
        long timeElapsed = System.currentTimeMillis() - start.get();
        if (timeElapsed > this.timeout.get()) {

            if (LOG.isDebugEnabled()) {
                //LOG.info("Current Thread="+Thread.currentThread()+" Condition="+this+" Checkpoint "+ System.currentTimeMillis() +" timeout="+(System.currentTimeMillis() - start));
                String logString = " violated at " + System.currentTimeMillis() +
                        " (elapsed time=" + timeElapsed + ")";
                LOG.debug(new CheckConditionFailedLog(this, logString).toString());
            }
            return false;
        }
        return true;
    }
1060565
private boolean executionIsTimedOut(long aStartTime, int aTimeout) {
        if (aTimeout != 0) {
            long now = System.currentTimeMillis() / 1000;
            if ((now - aStartTime) >= aTimeout) {
                return true;
            }
        }
        return false;
    }
1333693
public boolean isHot() {
        return getBThreadSnapshots().stream()
                    .map(BThreadSyncSnapshot::getSyncStatement)
                    .filter(SyncStatement::isHot)
                    .findAny().isPresent();
    }
670815
def is_obsolete(self):
        
        if self.cache_updated:
            now = timezone.now()
            delta = now - self.cache_updated
            if delta.seconds < self.cache_validity:
                return False
        return True
211895
public boolean isActive() {

        if (!m_enabled) {
            return false;
        }
        long currentTime = System.currentTimeMillis();
        return ((currentTime > m_timeStart) && (currentTime < m_timeEnd));
    }
971765
public static Long update(final long now) {
        final long estNow = EstTime.m_now;
        if (estNow == now) {
            return null;
        }

        EstTime.m_now = now;

        /*
         * Check if updating the estimated time was especially tardy.
         * I am concerned that the thread responsible for updating the estimated
         * time might be blocking on something and want to be able to log if
         * that happens
         */
        if (now - estNow > ESTIMATED_TIME_WARN_INTERVAL) {
            /*
             * Only report the error every 60 seconds to cut down on log spam
             */
            if (lastErrorReport > now) {
                //Time moves backwards on occasion, check and reset
                lastErrorReport = now;
            }
            if (now - lastErrorReport > maxErrorReportInterval) {
                lastErrorReport = now;
                return now - estNow;
            }
        }
        return null;
    }
1189183
private void checkIdleSlot() {

		// The timestamp in SlotAndTimestamp is relative
		final long currentRelativeTimeMillis = clock.relativeTimeMillis();

		final List<AllocatedSlot> expiredSlots = new ArrayList<>(availableSlots.size());

		for (SlotAndTimestamp slotAndTimestamp : availableSlots.availableSlots.values()) {
			if (currentRelativeTimeMillis - slotAndTimestamp.timestamp > idleSlotTimeout.toMilliseconds()) {
				expiredSlots.add(slotAndTimestamp.slot);
			}
		}

		final FlinkException cause = new FlinkException("Releasing idle slot.");

		for (AllocatedSlot expiredSlot : expiredSlots) {
			final AllocationID allocationID = expiredSlot.getAllocationId();
			if (availableSlots.tryRemove(allocationID) != null) {

				log.info("Releasing idle slot [{}].", allocationID);
				final CompletableFuture<Acknowledge> freeSlotFuture = expiredSlot.getTaskManagerGateway().freeSlot(
					allocationID,
					cause,
					rpcTimeout);

				FutureUtils.whenCompleteAsyncIfNotDone(
					freeSlotFuture,
					componentMainThreadExecutor,
					(Acknowledge ignored, Throwable throwable) -> {
						if (throwable != null) {
							if (registeredTaskManagers.contains(expiredSlot.getTaskManagerId())) {
								log.debug("Releasing slot [{}] of registered TaskExecutor {} failed. " +
										"Trying to fulfill a different slot request.", allocationID, expiredSlot.getTaskManagerId(),
									throwable);
								tryFulfillSlotRequestOrMakeAvailable(expiredSlot);
							} else {
								log.debug("Releasing slot [{}] failed and owning TaskExecutor {} is no " +
									"longer registered. Discarding slot.", allocationID, expiredSlot.getTaskManagerId());
							}
						}
					});
			}
		}

		scheduleRunAsync(this::checkIdleSlot, idleSlotTimeout);
	}