public static long writeFile(FileSystem fs, Path exportFilePath, InputStream is,
                               HiveConf conf) throws SemanticException {
    Retryable retryable = Retryable.builder()
      .withHiveConf(conf)
      .withRetryOnException(IOException.class).build();
    try {
      return retryable.executeCallable(() -> {
        FSDataOutputStream fos = null;
        try {
          long bytesWritten;
          fos = fs.create(exportFilePath);
          byte[] buffer = new byte[DEF_BUF_SIZE];
          int bytesRead;
          while ((bytesRead = is.read(buffer)) != -1) {
            fos.write(buffer, 0, bytesRead);
          }
          bytesWritten = fos.getPos();
          return bytesWritten;
        } finally {
          if (fos != null) {
            fos.close();
          }
        }
      });
    } catch (Exception e) {
      throw new SemanticException(e);
    }
  }
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