code: @Override
    public synchronized boolean setSafeMode(boolean safeMode) {
      /**
       * If we are switching off the safe mode, so we need to reset the last
       * heartbeat timestamp for each of the sessions and nodes.
       */
      if (safeMode == false) {
        LOG.info("Resetting the heartbeat times for all sessions");
        sessionManager.resetSessionsLastHeartbeatTime();
        LOG.info("Resetting the heartbeat times for all nodes");
        nodeManager.resetNodesLastHeartbeatTime();
        /**
         * If we are setting the safe mode to false, we should first set it
         * in-memory, before we set it at the CPJT.
         */
        this.safeMode = false;
      }
      try {
        ClusterManagerAvailabilityChecker.getPJTClient(conf).
          setClusterManagerSafeModeFlag(safeMode);
      } catch (IOException e) {
        LOG.info("Exception while setting the safe mode flag in ProxyJobTracker: "
          + e.getMessage());
        return false;
      } catch (TException e) {
        LOG.info("Exception while setting the safe mode flag in ProxyJobTracker: "
          + e.getMessage());
        return false;
      }
      this.safeMode = safeMode;
      LOG.info("Flag successfully set in ProxyJobTracker");
      LOG.info("Safe mode is now: " + (this.safeMode ? "ON" : "OFF"));
      return true;
    }
docs: Sets the Safe Mode flag on the Cluster Manager, and on the ProxyJobTracker.
  If we fail to set the flag on the ProxyJobTracker, return false, which
  signals that setting the flag on the ProxyJobTracker failed. In that case,
  we should run coronaadmin with the -forceSetSafeModeOnPJT or
  -forceUnsetSafeModeOnPJT options.
  
  If we call this function multiple times, it wouldn't matter, because all
  operations (apart from resetting of the last heartbeat time) in this
  function, and in the setClusterManagerSafeModeFlag function in the
  ProxyJobTracker are idempotent.
  
  @param safeMode The value of Safe Mode flag that we want to be set.
  @return true, if setting the Safe Mode flag succeeded, false otherwise.