/**
   * Initiate the SessionPool's keep-alive system. This will run until <a
   * href=#shutdown()>shutdown</a> is invoked on the SessionManager.
   */
  @Override
  public void run() {
    debugLogger.finest("enter");

    if (state != SMState.STARTED) {
      return;
    }

    runThread = Thread.currentThread();
    state = SMState.RUNNING;

    try {
      while (state == SMState.RUNNING) {
        long sleepInterval = sessionPool.keepAlive();

        boolean interrupted = false;
        int retry = 0;
        int maxRetries = MAX_SLEEP_INTERRUPTS_TO_FAIL;

        long sleepTime, awakenTime;
        do {
          sleepTime = Timer.now();

          try {
            retry++;
            if (sleepInterval > 0) {
              Thread.sleep(sleepInterval);
            }
            interrupted = false;
          } catch (InterruptedException ie) {
            // reduce the remaining sleep interval
            awakenTime = Timer.now();
            sleepInterval += sleepTime - awakenTime;
            interrupted = true;
          }
        } while (interrupted && retry < maxRetries && state == SMState.RUNNING);
      }
    } catch (IOException ioe) {
      userLogger.severe(ioe.getMessage());
      userLogger.severe(ioe.getCause().getMessage());
      userLogger.severe(ErrorPkg.getMessage("epp.session.poll.cfg.fail"));
    }

    debugLogger.finest("exit");
  }
 @Before
 public void setUp() throws Exception {
   Timer.setTime("20070101.010101");
   CLTRID.setClID("JTKUTEST");
 }