@Override
    public void run() {
      LOG.info("Terminal Session Clean Task started");
      LOG.info(
          "Terminal Session Clean Task, check interval: " + SESSION_TIMEOUT_CHECK_INTERVAL + " ms");
      LOG.info("Terminal Session Timeout: {} minutes", sessionTimeout);
      while (running) {
        try {
          List<TerminalSessionContext> sessionToRelease = checkIdleSession();
          sessionToRelease.forEach(this::releaseSession);
          if (!sessionToRelease.isEmpty()) {
            LOG.info("Terminal Session release count: {}", sessionToRelease.size());
          }
        } catch (Throwable t) {
          LOG.error("error when check and release session", t);
        }

        try {
          TimeUnit.MILLISECONDS.sleep(SESSION_TIMEOUT_CHECK_INTERVAL);
        } catch (InterruptedException e) {
          LOG.error("Interrupted when sleep", e);
        }
      }
    }
Get last execution info

@param terminalId - id of terminal window
@return last session info
amoro-ams/src/main/java/org/apache/amoro/server/terminal/TerminalManager.java