public class HdfsFileSystem extends FileSystem
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEid, log, name, TIMESTAMP_FORMAT| Constructor and Description |
|---|
HdfsFileSystem(String hdfsUri)
Enables access to Hadoop Distributed File System with the user name supplied through a
CredentialsResolver (see setCredentialsResolver(CredentialsResolver)).URI Example: "hdfs://localhost:9000" |
HdfsFileSystem(String hdfsUri,
String userName)
Enables access to Hadoop Distributed File System.
URI Example: "hdfs://localhost:9000" |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the HDFS connection.
|
List<FileStatus> |
listFolder(String folderName)
Returns the contents of the folder.
|
List<FileStatus> |
listRootFolder()
Returns a
List of all HDFS files and folders under the root folder. |
void |
open()
Opens a connection to the Hadoop Distributed File System.
|
InputStream |
readFile(String fileName)
Reads the specified file in the HDFS root folder.
|
InputStream |
readFile(String folderName,
String fileName)
Reads the file in the specified HDFS folder.
|
HdfsFileSystem |
setCredentialsResolver(CredentialsResolver credentialsResolver)
Sets the resolver supplying this file system's user name (
Credentials.USERNAME) —
resolved on each open(), never at construction, so rotated values are picked up on
the next connection. |
OutputStream |
writeFile(String fileName)
Writes the file to the HDFS File System.
|
OutputStream |
writeFile(String folderName,
String fileName)
Writes the file to the HDFS File System.
|
credentialValue, getCredentialsResolver, getCurrentCredentials, refreshCredentials, resolveCredentialsaddElapsedtime, addExceptionProperties, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getNestedEndpoint, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getRootEndpoint, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription, toStringpublic HdfsFileSystem(String hdfsUri, String userName)
hdfsUri - the URI of the Hadoop Distributed File Systempublic HdfsFileSystem(String hdfsUri)
CredentialsResolver (see setCredentialsResolver(CredentialsResolver)).hdfsUri - the URI of the Hadoop Distributed File Systempublic HdfsFileSystem setCredentialsResolver(CredentialsResolver credentialsResolver)
Credentials.USERNAME) —
resolved on each open(), never at construction, so rotated values are picked up on
the next connection. When the resolved credentials don't contain a user name, the
constructor-supplied value is used.setCredentialsResolver in class FileSystempublic void open()
throws DataException
open in class EndpointDataExceptionpublic void close()
throws DataException
close in class FileSystemDataExceptionpublic InputStream readFile(String folderName, String fileName) throws Throwable
folderName - the name of the folderfileName - the file name to read.InputStreamThrowablepublic InputStream readFile(String fileName) throws Throwable
fileName - the file name to read.InputStreamThrowablepublic List<FileStatus> listFolder(String folderName) throws Throwable
Throwablepublic List<FileStatus> listRootFolder() throws Throwable
List of all HDFS files and folders under the root folder.ListThrowablepublic OutputStream writeFile(String fileName) throws Throwable
fileName - the name of the fileOutputStream for writingThrowablepublic OutputStream writeFile(String folderName, String fileName) throws Throwable
folderName - the destination folderfileName - the name of the fileOutputStream for writingThrowableCopyright (c) 2006-2026 North Concepts Inc. All Rights Reserved.