Class HdfsUtils

java.lang.Object
cern.nxcals.api.utils.HdfsUtils

public final class HdfsUtils extends Object
Utility class for interacting with HDFS.

Provides methods to list files in a directory and copy files to a local destination.

  • Method Details

    • listFiles

      public static List<org.apache.hadoop.fs.Path> listFiles(String srcDir)
      Lists all files in the specified HDFS directory.

      Only files are returned; directories are ignored. If the directory is empty, an exception is thrown.

      Parameters:
      srcDir - the HDFS directory path
      Returns:
      a list of file paths in the specified directory
      Throws:
      IllegalArgumentException - if the directory is empty
      UncheckedIOException - if an error occurs while accessing HDFS
    • copyToLocal

      public static void copyToLocal(String source, String destination)
      Copies files from the given source directory to the local destination.

      Only files will be copied; directories are ignored.

      Parameters:
      source - the source directory containing the files to be copied
      destination - the local destination directory where files will be copied
    • setFileSystem

      public static void setFileSystem(org.apache.hadoop.fs.FileSystem fileSystem)