When current session expired, use {@link SessionManager} to refresh the session id.
326110
void refreshSession(boolean forceRefresh) throws AzkabanClientException {
    Preconditions.checkArgument(this.sessionCreationTime != 0);
    boolean expired = (System.nanoTime() - this.sessionCreationTime) > Duration
        .ofMinutes(this.sessionExpireInMin)
        .toNanos();

    if (expired) {
      log.info("Session expired. Generating a new session.");
    } else if (forceRefresh) {
      log.info("Force to refresh session. Generating a new session.");
    }

    if (expired || forceRefresh) {
      this.sessionId = this.sessionManager.fetchSession();
      this.sessionCreationTime = System.nanoTime();
    }
  }
1096176
@Override
    public void renew(IEntityLock lock, int duration) throws LockingException {
        if (isValid(lock)) {
            Date newExpiration = getNewExpiration(duration);
            getLockStore().update(lock, newExpiration);
            ((EntityLockImpl) lock).setExpirationTime(newExpiration);
        } else {
            throw new LockingException("Could not renew " + lock + " : lock is invalid.");
        }
    }
893907
public synchronized void checkNotExpired() {
        if (Utils.currentTimeSeconds() > getExpiryTime()) {
            stateMachine.transition(State.EXPIRED);
            disconnectFromChannel();
            throw new IllegalStateException("Channel expired");
        }
    }
716446
public void sessionReady(boolean isReady) {
	if (isReady) {
	    speedSlider.setValue(session.getClockPeriod());
	}
	startAction.setEnabled(isReady);
	speedSlider.setEnabled(isReady);
	stepAction.setEnabled(isReady);
	reloadAction.setEnabled(isReady);

    }
148031
public void expireSession(PrimaryBackupSession session) {
    if (sessions.remove(session.sessionId().id()) != null) {
      session.expire();
      listeners.forEach(l -> l.onExpire(session));
    }
  }
239731
private void expireOrphanSessions(long timestamp) {
    // Iterate through registered sessions.
    for (RaftSession session : raft.getSessions().getSessions()) {
      if (session.getService().deleted() && session.isTimedOut(timestamp)) {
        logger.debug("Orphaned session expired in {} milliseconds: {}", timestamp - session.getLastUpdated(), session);
        session = raft.getSessions().removeSession(session.sessionId());
        if (session != null) {
          session.expire();
        }
      }
    }
  }
1073383
private void saveSession(Session session) throws UnknownSessionException{
		if(session == null || session.getId() == null){
			logger.error("session or session id is null");
			return;
		}
		
		byte[] key = getByteKey(session.getId());
		byte[] value = SerializeUtils.serialize(session);
		
		
		session.setTimeout(this.getExpire()*1000);		
		
		if(redisTemplate!=null) {
			redisTemplate.opsForValue().set(getKey(session.getId()), value, this.getExpire(), TimeUnit.SECONDS);
		}else {
			this.redisManager.set(key, value, this.getExpire());
		}
		
	}
866989
private void saveSession(Session session) throws UnknownSessionException {
		if (session == null || session.getId() == null) {
			logger.error("session or session id is null");
			throw new UnknownSessionException("session or session id is null");
		}
		byte[] key;
		byte[] value;
		try {
			key = keySerializer.serialize(getRedisSessionKey(session.getId()));
			value = valueSerializer.serialize(session);
		} catch (SerializationException e) {
			logger.error("serialize session error. session id=" + session.getId());
			throw new UnknownSessionException(e);
		}
		if (expire == DEFAULT_EXPIRE) {
			this.redisManager.set(key, value, (int) (session.getTimeout() / MILLISECONDS_IN_A_SECOND));
			return;
		}
		if (expire != NO_EXPIRE && expire * MILLISECONDS_IN_A_SECOND < session.getTimeout()) {
			logger.warn("Redis session expire time: "
					+ (expire * MILLISECONDS_IN_A_SECOND)
					+ " is less than Session timeout: "
					+ session.getTimeout()
					+ " . It may cause some problems.");
		}
		this.redisManager.set(key, value, expire);
	}
1288473
public void refresh() {
        QueryCache.instance().purgeTableCache(metaModelLocal);
        Model fresh = ModelDelegate.findById(this.getClass(), getId());
        if (fresh == null) {
            throw new StaleModelException("Failed to refresh self because probably record with " +
                    "this ID does not exist anymore. Stale model: " + this);
        }
        fresh.copyTo(this);
        dirtyAttributeNames.clear();
    }
284069
public void refresh() {
        if (credentialFile.lastModified() > credentialFileLastModified) {
            credentialFileLastModified = credentialFile.lastModified();
            credentials = loadCredentials(credentialFile);
        }
        credentialProvider = new JsonStaticCredentialsProvider(credentials);
    }
1206339
protected void onBackupWithoutLoadedSession( @Nonnull final String sessionId, @Nonnull final String requestId,
            @Nonnull final BackupSessionService backupSessionService ) {

        if ( !_sessionIdFormat.isValid( sessionId ) ) {
            return;
        }

        try {

            final long start = System.currentTimeMillis();

            final String validityKey = _sessionIdFormat.createValidityInfoKeyName( sessionId );
            final SessionValidityInfo validityInfo = loadSessionValidityInfoForValidityKey( validityKey );
            if ( validityInfo == null ) {
                _log.warn( "Found no validity info for session id " + sessionId );
                return;
            }

            final int maxInactiveInterval = validityInfo.getMaxInactiveInterval();
            final byte[] validityData = encode( maxInactiveInterval, System.currentTimeMillis(),
                    System.currentTimeMillis() );
            // fix for #88, along with the change in session.getMemcachedExpirationTimeToSet
            final int expiration = maxInactiveInterval <= 0 ? 0 : maxInactiveInterval;
            final Future<Boolean> validityResult = _storage.set( validityKey, toMemcachedExpiration(expiration), validityData );
            if ( !_manager.isSessionBackupAsync() ) {
                validityResult.get( _manager.getSessionBackupTimeout(), TimeUnit.MILLISECONDS );
            }

            /*
             * - ping session
             * - ping session backup
             * - save validity backup
             */
            final Callable<?> backupSessionTask = new OnBackupWithoutLoadedSessionTask( sessionId,
                    _storeSecondaryBackup, validityKey, validityData, maxInactiveInterval );
            _executor.submit( backupSessionTask );

            if ( _log.isDebugEnabled() ) {
                _log.debug( "Stored session validity info for session " + sessionId );
            }

            _stats.registerSince( NON_STICKY_ON_BACKUP_WITHOUT_LOADED_SESSION, start );

        } catch( final Throwable e ) {
            _log.warn( "An error when trying to load/update validity info.", e );
        }

    }
965343
protected function refresh()
    {
        if (Session::get()->exists(App::get()->shortName . $this->sessionKey)) {
            $state = Session::get()->value(App::get()->shortName . $this->sessionKey);
            $this->_userData = $state['vars'];
            $this->_rights = $state['rights'];
            $this->connected = (count($this->_userData) > 0);
        }
    }
439087
void invalidate() {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "invalidate");
        }

        _sessionInvalidated = true;

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "invalidate");
        }

    }
286761
def query_by_expired(cls):
        """"""
        lifetime = current_app.permanent_session_lifetime
        expired_moment = datetime.utcnow() - lifetime
        return cls.query.filter(cls.created < expired_moment)
904661
private Session loadSession(String id) throws Exception {
        if (sessionDataStore == null) {
            return null; // can't load it
        }
        try {
            SessionData data = sessionDataStore.load(id);
            if (data == null) { // session doesn't exist
                return null;
            }
            return newSession(data);
        } catch (UnreadableSessionDataException e) {
            // can't load the session, delete it
            if (isRemoveUnloadableSessions()) {
                sessionDataStore.delete(id);
            }
            throw e;
        }
    }
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) {

            }
        }
    }
330027
public RefreshSessionResponse refreshSession(RefreshSessionRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkStringNotEmpty(request.getSessionId(), "The parameter sessionId should NOT be null or empty string.");
        InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_SESSION,
                request.getSessionId());
        internalRequest.addParameter(REFRESH, null);
        return invokeHttpClient(internalRequest, RefreshSessionResponse.class);
    }