Package cern.nxcals.api.utils
Class HdfsUtils
java.lang.Object
cern.nxcals.api.utils.HdfsUtils
Utility class for interacting with HDFS.
Provides methods to list files in a directory and copy files to a local destination.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyToLocal(String source, String destination) Copies files from the given source directory to the local destination.static List<org.apache.hadoop.fs.Path> Lists all files in the specified HDFS directory.static voidsetFileSystem(org.apache.hadoop.fs.FileSystem fileSystem)
-
Method Details
-
listFiles
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 emptyUncheckedIOException- if an error occurs while accessing HDFS
-
copyToLocal
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 copieddestination- the local destination directory where files will be copied
-
setFileSystem
public static void setFileSystem(org.apache.hadoop.fs.FileSystem fileSystem)
-