Ping the server if deemed necessary because automatic server pings are
enabled ({@link #setPingInterval(int)}) and the ping interval has expired.
358705
public void pingServerIfNecessary() {
        final XMPPConnection connection = connection();
        if (connection == null) {
            // connection has been collected by GC
            // which means we can stop the thread by breaking the loop
            return;
        }
        if (pingInterval <= 0) {
            // Ping has been disabled
            return;
        }
        long lastStanzaReceived = connection.getLastStanzaReceived();
        if (lastStanzaReceived > 0) {
            long now = System.currentTimeMillis();
            // Delta since the last stanza was received
            int deltaInSeconds = (int)  ((now - lastStanzaReceived) / 1000);
            // If the delta is small then the ping interval, then we can defer the ping
            if (deltaInSeconds < pingInterval) {
                maybeSchedulePingServerTask(deltaInSeconds);
                return;
            }
        }
        if (!connection.isAuthenticated()) {
            LOGGER.warning(connection + " was not authenticated");
            return;
        }

        final long minimumTimeout = TimeUnit.MINUTES.toMillis(2);
        final long connectionReplyTimeout = connection.getReplyTimeout();
        final long timeout = connectionReplyTimeout > minimumTimeout ? connectionReplyTimeout : minimumTimeout;

        SmackFuture<Boolean, Exception> pingFuture = pingAsync(connection.getXMPPServiceDomain(), timeout);
        pingFuture.onSuccess(new SuccessCallback<Boolean>() {
            @Override
            public void onSuccess(Boolean result) {
                // Ping was successful, wind-up the periodic task again
                maybeSchedulePingServerTask();
            }
        });
        pingFuture.onError(new ExceptionCallback<Exception>() {
            @Override
            public void processException(Exception exception) {
                long lastStanzaReceived = connection.getLastStanzaReceived();
                if (lastStanzaReceived > 0) {
                    long now = System.currentTimeMillis();
                    // Delta since the last stanza was received
                    int deltaInSeconds = (int)  ((now - lastStanzaReceived) / 1000);
                    // If the delta is smaller then the ping interval, we have got an valid stanza in time
                    // So not error notification needed
                    if (deltaInSeconds < pingInterval) {
                        maybeSchedulePingServerTask(deltaInSeconds);
                        return;
                    }
                }

                for (PingFailedListener l : pingFailedListeners) {
                    l.pingFailed();
                }
            }
        });
    }
631680
public static void end() {
    if (!active) return;

    TimerStack stack = curStack.get();
    if (null == stack) return;

    TimerNode currentNode = stack.pop();

    if (currentNode != null) {
      TimerNode parent = stack.peek();
      long total = currentNode.end();
      // if we are the root timer, then print out the times
      if (parent == null) {
        printTimes(currentNode);
        curStack.set(null); // for those servers that use thread pooling
      } else {
        if (total > mintime) parent.children.add(currentNode);
      }
    }
  }
1095256
@Override
	public void run()
    {
        try
        {
        	if (pingInterval > 0)
        		ActivityWatchdog.getInstance().register(this);
        	
            while (!stopRequired)
            {
            	int actualMaxPacketSize = Integer.MAX_VALUE;
            	if (maxPacketSize != -1)
            		actualMaxPacketSize = trustedConnection ? maxPacketSize : 1024;

                AbstractPacket packet = receive(actualMaxPacketSize);
                if (packet == null)
                {
                	if (stopRequired)
                		break;
                	
                	// Report connection closed
                    log.debug("#"+id+" connection closed by remote peer.");
                    transport.closeTransport(true);
                    break;
                }
                
                if (traceEnabled)
                    log.trace("#"+id+" Received "+packet);
                
                lastActivity = System.currentTimeMillis();
                if (listener != null)
                	trustedConnection = listener.packetReceived(packet);
            }
        }
        catch (Exception e)
        {
            if (!stopRequired)
            {
            	log.error("#"+id+" transport failed : "+e.toString());
            	transport.closeTransport(true);
            }
        }
        catch (Throwable e)
        {
        	log.fatal("#"+id+" TCP packet receiver died",e);
        }
        
        log.debug("#"+id+" stopping.");
    }
1099929
@ReflectiveAccess
    protected void setInterval(String interval) {
        this.interval = ConversionService.SHARED.convert(interval, Duration.class).orElseThrow(() -> new IllegalArgumentException("Invalid Duration Specified"));
    }
333034
public final void expiredRequest(long tick)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "expiredRequest", Long.valueOf(tick));
    expiredRequest(tick, false);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "expiredRequest");
  }
272677
function () {

	var currTime = new Date();
	var overtime = (SR.Settings.INTERVAL_STAT_REPORT * 2);

	// remove servers no longer reporting
	for (var serverID in SR.Report.servers) {
		var stat = SR.Report.servers[serverID];
		
		if (!stat || !stat.reportedTime)
			continue;
		
		// server considered dead
		if (currTime - stat.reportedTime > overtime) {
			var ip_port = stat.server.IP + ':' + stat.server.port;
			LOG.sys(ip_port + ' overtime: ' + overtime + ' last: ' + stat.reportedTime);

			LOG.error('server: ' + ip_port + ' (' + stat.server.type + ') not responding after ' + overtime + ' ms, mark dead...', 'SR.Monitor');
			SR.Report.removeStat(serverID);
			
			// recycle port if it's from a local server
			if (stat.server.IP === SR.Settings.SERVER_INFO.IP) {
				LOG.warn('server is a local server, re-cycle its ports...', 'SR.Monitor');
				l_recyclePort(stat.ports);
			}
		}
	}
}
117753
public static long timedPing( final String    server )
        throws
            UnknownHostException,
            IOException
    {
        StopWatch    stopwatch = new StopWatch();
        stopwatch.start();

        boolean    reachable;
        reachable = ping( server );

        stopwatch.stop();

        if ( reachable )
        {
            return stopwatch.getTime();
        }

        return -1;
    }
993213
private void tickIfNecessary() {
        final long oldTick = lastTick.get();
        final long newTick = clock.tick();
        final long age = newTick - oldTick;
        if (age > TICK_INTERVAL) {
            final long newIntervalStartTick = newTick - age % TICK_INTERVAL;
            if (lastTick.compareAndSet(oldTick, newIntervalStartTick)) {
                final long requiredTicks = age / TICK_INTERVAL;
                for (long i = 0; i < requiredTicks; i++) {
                    m15Rate.tick();
                    m120Rate.tick();
                }
            }
        }
    }
1303593
public static int setSessionTimeout(final int interval)
	{
		final HttpSession session = getHttpSession();
		if (session != null)
		{
			session.setMaxInactiveInterval(interval);
			return interval;
		}
		return -1;
	}
254012
protected void tick ()
    {
        // if we're not connected, skip it
        if (_comm == null) {
            return;
        }

        long now = RunAnywhere.currentTimeMillis();
        if (_dcalc != null) {
            // if our current calculator is done, clear it out
            if (_dcalc.isDone()) {
                if (debugLogMessages()) {
                    log.info("Time offset from server: " + _serverDelta + "ms.");
                }
                _dcalc = null;
            } else if (_dcalc.shouldSendPing()) {
                // otherwise, send another ping
                PingRequest req = new PingRequest();
                _comm.postMessage(req);
                _dcalc.sentPing(req);
            }

        } else if (now - _comm.getLastWrite() > PingRequest.PING_INTERVAL) {
            // if we haven't sent anything over the network in a while, we ping the server to let
            // it know that we're still alive
            _comm.postMessage(new PingRequest());

        } else if (now - _lastSync > CLOCK_SYNC_INTERVAL) {
            // resync our clock with the server
            establishClockDelta(now);
        }
    }
1236974
public void setInterval(ReadableInstant start, ReadableInstant end) {
        if (start == null && end == null) {
            long now = DateTimeUtils.currentTimeMillis();
            setInterval(now, now);
        } else {
            long startMillis = DateTimeUtils.getInstantMillis(start);
            long endMillis = DateTimeUtils.getInstantMillis(end);
            Chronology chrono = DateTimeUtils.getInstantChronology(start);
            super.setInterval(startMillis, endMillis, chrono);
        }
    }
393701
public final void setInterval(LocalTime startTime, LocalTime endTime) {
        setInterval(startTime, endTime, ZoneId.systemDefault());
    }
964735
public void endInterval(int lastIndex) {
        if (isOpen) {
            currentDetail.setLast(lastIndex);
            pathDetails.add(currentDetail);
        }
        isOpen = false;
    }
729408
@Override
    public void ping() {
        sendPingCommand();
        TaskScheduler scheduler = SmartFoxServer
                    .getInstance()
                    .getTaskScheduler();
        schedule(scheduler);
    }
948210
@Override
    boolean ping_i(final boolean fwd) {
	if (proxy == null) {
	    return false;
	}
	try {
	    proxy.ping();
	} catch (final DevFailed df) {
	    return false;
	}
	return true;
    }
235171
protected void doWarning (int level, int minutes)
    {
        _rebootSoon = (level > -1);

        int[] warnings = getWarnings();
        if (level == warnings.length) {
            if (checkLocks()) {
                return;
            }

            // that's it! do the reboot
            log.info("Performing automatic server reboot/shutdown, as scheduled by: " + _initiator);
            broadcast("m.rebooting_now");

            // wait 1 second, then do it
            new Interval(Interval.RUN_DIRECT) {
                @Override public void expired () {
                    _server.queueShutdown(); // this posts a LongRunnable
                }
            }.schedule(1000);
            return;
        }

        // issue the warning
        if (_rebootSoon) {
            notifyObservers(level);
            broadcast(getRebootMessage("m.reboot_warning", minutes));
        }

        // schedule the next warning
        final int nextLevel = level + 1;
        final int nextMinutes = (nextLevel == warnings.length) ? 0 : warnings[nextLevel];
        _interval = _omgr.newInterval(new Runnable() {
            public void run () {
                doWarning(nextLevel, nextMinutes);
            }
        });
        _interval.schedule(
            Math.max(0L, _nextReboot - (nextMinutes * 60L * 1000L) - System.currentTimeMillis()));
    }
419850
public synchronized void onTransportIdle() {
    if (keepAliveDuringTransportIdle) {
      return;
    }
    if (state == State.PING_SCHEDULED || state == State.PING_DELAYED) {
      state = State.IDLE;
    }
    if (state == State.PING_SENT) {
      state = State.IDLE_AND_PING_SENT;
    }
  }