public static String replaceNameserviceInEncodedURI(String cmEncodedURI, HiveConf hiveConf) throws SemanticException {
    String newNS = hiveConf.get(HiveConf.ConfVars.REPL_HA_DATAPATH_REPLACE_REMOTE_NAMESERVICE_NAME.varname);
    if (StringUtils.isEmpty(newNS)) {
      throw new SemanticException(ErrorMsg.REPL_INVALID_CONFIG_FOR_SERVICE
              .format("Configuration 'hive.repl.ha.datapath.replace.remote.nameservice.name' is not valid "
                      + newNS == null ? "null" : newNS, ReplUtils.REPL_HIVE_SERVICE));
    }
    String[] decodedURISplits = ReplChangeManager.decodeFileUri(cmEncodedURI);
    // replace both data path and repl cm root path and construct new URI. Checksum and subDir will be same as old.
    String modifiedURI =  ReplChangeManager.encodeFileUri(replaceHost(decodedURISplits[0], newNS), decodedURISplits[1],
                                                          replaceHost(decodedURISplits[2], newNS), decodedURISplits[3]);
    LOG.debug("Modified encoded uri {}, to {} ", cmEncodedURI, modifiedURI);
    return modifiedURI;
  }
Given a ReplChangeManger's encoded uri, it replaces the nameservice and returns the modified encoded uri.
ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java