@Override
    public void run() {
      TOP: while (!shutDown) {
        SystemFailure.checkFailure();
        try {
          agent.connected = false;
          agent.initialized = false;
          if (!shutDown) {
            agent.connectToDS();

            // If we're successful, this thread is done
            if (agent.isListening()) {
              Assert.assertTrue(agent.system != null);
            }
            return;
          }
        } catch (IncompatibleSystemException ise) {
          logger.fatal(ise.getMessage(), ise);
          agent.callAlertListener(new VersionMismatchAlert(agent, ise.getMessage()));
        } catch (Exception e) {
          for (Throwable cause = e; cause != null; cause = cause.getCause()) {
            if (cause instanceof InterruptedException) {
              // We were interrupted while connecting. Most likely we are being shutdown.
              if (shutDown) {
                break TOP;
              }
            }

            if (cause instanceof AuthenticationFailedException) {
              // Incorrect credentials. Log & Shutdown
              shutDown = true;
              agent.securityLogWriter.warning(
                  "[RemoteGfManagerAgent]: An AuthenticationFailedException was caught while connecting to DS",
                  e);
              break TOP;
            }
          }

          logger.debug("[RemoteGfManagerAgent] While connecting to DS", e);
        }
        try {
          sleep(1000);
        } catch (InterruptedException ignore) {
          // We're just exiting, no need to restore the interrupt bit.
        }
      }
      agent.connected = false;
      agent.initialized = false;
    }
Keep trying to connect to the distributed system. If we have problems connecting, the agent
will not be marked as "connected".
geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteGfManagerAgent.java