@Override
  public int execute() {
    try {
      long exportCount = 0;
      Path filePath = null;
      LOG.info("Exporting Ranger Metadata");
      SecurityUtils.reloginExpiringKeytabUser();
      Map<String, Long> metricMap = new HashMap<>();
      metricMap.put(ReplUtils.MetricName.POLICIES.name(), 0L);
      work.getMetricCollector().reportStageStart(getName(), metricMap);
      replLogger = new RangerDumpLogger(work.getDbName(), work.getCurrentDumpPath().toString());
      replLogger.startLog();
      if (rangerRestClient == null) {
        rangerRestClient = getRangerRestClient();
      }
      URL url = work.getRangerConfigResource();
      if (url == null) {
        throw new SemanticException(ErrorMsg.REPL_INVALID_CONFIG_FOR_SERVICE
          .format("Ranger configuration is not valid "
          + ReplUtils.RANGER_CONFIGURATION_RESOURCE_NAME, ReplUtils.REPL_RANGER_SERVICE));
      }
      conf.addResource(url);
      String rangerHiveServiceName = conf.get(ReplUtils.RANGER_HIVE_SERVICE_NAME);
      String rangerEndpoint = conf.get(ReplUtils.RANGER_REST_URL);
      if (StringUtils.isEmpty(rangerEndpoint)) {
        throw new SemanticException(ErrorMsg.REPL_INVALID_CONFIG_FOR_SERVICE
          .format("Ranger endpoint is not valid "
            + rangerEndpoint, ReplUtils.REPL_RANGER_SERVICE));
      }
      if (!rangerRestClient.checkConnection(rangerEndpoint, conf)) {
        throw new SemanticException(ErrorMsg.REPL_EXTERNAL_SERVICE_CONNECTION_ERROR.format(ReplUtils
            .REPL_RANGER_SERVICE,
          "Ranger endpoint is not reachable " + rangerEndpoint));
      }
      RangerExportPolicyList rangerExportPolicyList = rangerRestClient.exportRangerPolicies(rangerEndpoint,
              work.getDbName(), rangerHiveServiceName, conf);
      List<RangerPolicy> rangerPolicies = rangerExportPolicyList.getPolicies();
      if (rangerPolicies.isEmpty()) {
        LOG.info("Ranger policy export request returned empty list or failed, Please refer Ranger admin logs.");
        rangerExportPolicyList = new RangerExportPolicyList();
      } else {
        rangerPolicies = rangerRestClient.removeMultiResourcePolicies(rangerPolicies);
      }
      if (!CollectionUtils.isEmpty(rangerPolicies)) {
        rangerExportPolicyList.setPolicies(rangerPolicies);
        filePath = rangerRestClient.saveRangerPoliciesToFile(rangerExportPolicyList,
                work.getCurrentDumpPath(), ReplUtils.HIVE_RANGER_POLICIES_FILE_NAME, conf);
        if (filePath != null) {
          LOG.info("Ranger policy export finished successfully");
          exportCount = rangerExportPolicyList.getListSize();
          work.getMetricCollector().reportStageProgress(getName(), ReplUtils.MetricName.POLICIES.name(), exportCount);
        }
      }
      replLogger.endLog(exportCount);
      work.getMetricCollector().reportStageEnd(getName(), Status.SUCCESS);
      LOG.debug("Ranger policy export filePath:" + filePath);
      LOG.info("Number of ranger policies exported {}", exportCount);
      return 0;
    } catch (RuntimeException e) {
      LOG.error("RuntimeException during Ranger dump", e);
      setException(e);
      try{
        ReplUtils.handleException(true, e, work.getCurrentDumpPath().getParent().toString(),
                work.getMetricCollector(), getName(), conf); 
      } catch (Exception ex){
        LOG.error("Failed to collect replication metrics: ", ex);
      }
      throw e;
    } catch (Exception e) {
      LOG.error("Ranger Dump Failed: ", e);
      setException(e);
      int errorCode = ErrorMsg.getErrorMsg(e.getMessage()).getErrorCode();
      try{
        return ReplUtils.handleException(true, e, work.getCurrentDumpPath().getParent().toString(),
                work.getMetricCollector(), getName(), conf);
      } catch (Exception ex){
        LOG.error("Failed to collect replication metrics: ", ex);
        return errorCode;        
      }
    }
  }
RangerDumpTask.

Exports the Ranger security policies to staging directory.
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/RangerDumpTask.java