code: public static void waitWhileClusterManagerInSafeMode(CoronaConf conf)
      throws IOException {
  
      CoronaProxyJobTrackerService.Client pjtClient = getPJTClient(conf);
      while (true) {
        try {
          // If this condition holds true, then two things can happen:
          // 1. The CM was never in Safe Mode
          // 2. CM was in Safe Mode, just before we made this method call, and
          //    came out of Safe Mode before the RPC call.
          if (!pjtClient.getClusterManagerSafeModeFlag()) {
            break;
          }
  
          // If the safe mode flag is indeed set
          LOG.info("Safe mode flag is set on the ProxyJobTracker");
          try {
            Thread.sleep(1000);
          } catch (InterruptedException e) {
            throw new IOException(e);
          }
        } catch (TException e) {
          throw new IOException(
            "Could not check the safe mode flag on the ProxyJobTracker", e);
        }
      }
    }
docs: This helper method simply polls the ProxyJobTracker if and until the
  clusterManagerSafeMode flag is set there.
  @param conf
  @throws IOException