@ThreadSafe public class HdfsUnderFileSystem extends ConsistentUnderFileSystem implements AtomicFileOutputStreamCallback
UnderFileSystem
implementation.UnderFileSystem.Factory, UnderFileSystem.SpaceType
Modifier and Type | Field and Description |
---|---|
protected static String |
CHECKSUM_COMBINE_MODE |
protected static String |
HADOOP_AUTH_METHOD |
protected static String |
HDFS_ACL_PROVIDER_CLASS
Name of the class for the HDFS Acl provider.
|
protected static String |
HDFS_EC_CODEC_REGISTRY_CLASS
Name of the class for the HDFS EC Codec Registry.
|
protected static String |
HDFS_EC_MIN_VERSION
The minimum HDFS production version required for EC.
|
protected static String |
HDFS_USER |
protected static String |
JAVAX_WS_RS_CORE_MEDIA_TYPE |
protected static String |
KRB_KEYTAB_LOGIN_AUTO_RENEW |
protected static String |
KRB5_CONF_FILE |
protected static int |
MAX_TRY |
protected HdfsAclProvider |
mHdfsAclProvider |
EMPTY_ACL, mUfsConf, mUri
Modifier | Constructor and Description |
---|---|
|
HdfsUnderFileSystem(AlluxioURI ufsUri,
UnderFileSystemConfiguration conf,
org.apache.hadoop.conf.Configuration hdfsConf)
Constructs a new HDFS
UnderFileSystem . |
protected |
HdfsUnderFileSystem(AlluxioURI ufsUri,
UnderFileSystemConfiguration conf,
org.apache.hadoop.conf.Configuration hdfsConf,
boolean useLoadingCache) |
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Cleans up the under file system.
|
void |
close() |
void |
connectFromMaster(String host)
Takes any necessary actions required to establish a connection to the under file system from
the given master host e.g.
|
void |
connectFromWorker(String host)
Takes any necessary actions required to establish a connection to the under file system from
the given worker host e.g.
|
OutputStream |
create(String path,
CreateOptions options)
Creates a file in the under file system with the specified
CreateOptions . |
static org.apache.hadoop.conf.Configuration |
createConfiguration(UnderFileSystemConfiguration conf)
Prepares the Hadoop configuration necessary to successfully obtain a
FileSystem
instance that can access the provided path. |
OutputStream |
createDirect(String path,
CreateOptions options)
Creates a file in the under file system with the specified
CreateOptions . |
static HdfsUnderFileSystem |
createInstance(AlluxioURI ufsUri,
UnderFileSystemConfiguration conf)
Factory method to constructs a new HDFS
UnderFileSystem instance. |
boolean |
deleteDirectory(String path,
DeleteOptions options)
Deletes a directory from the under file system with the indicated name.
|
boolean |
deleteFile(String path)
Deletes a file from the under file system with the indicated name.
|
boolean |
exists(String path)
Checks if a file or directory exists in under file system.
|
Pair<AccessControlList,DefaultAccessControlList> |
getAclPair(String path)
Gets the ACL and the Default ACL of a file or directory in under file system.
|
long |
getBlockSizeByte(String path)
Gets the block size of a file in under file system, in bytes.
|
UfsDirectoryStatus |
getDirectoryStatus(String path)
Gets the directory status.
|
List<String> |
getFileLocations(String path)
Gets the list of locations of the indicated path.
|
List<String> |
getFileLocations(String path,
FileLocationOptions options)
Gets the list of locations of the indicated path given options.
|
UfsFileStatus |
getFileStatus(String path,
GetStatusOptions options)
Gets the file status.
|
org.apache.hadoop.fs.FileSystem |
getFs() |
long |
getSpace(String path,
UnderFileSystem.SpaceType type)
Queries the under file system about the space of the indicated path (e.g., space left, space
used and etc).
|
UfsStatus |
getStatus(String path,
GetStatusOptions options)
Gets the file or directory status.
|
String |
getUnderFSType()
Returns the name of the under filesystem implementation.
|
boolean |
isDirectory(String path)
Checks if a directory exists in under file system.
|
boolean |
isFile(String path)
Checks if a file exists in under file system.
|
boolean |
isSeekable()
Denotes if the under storage supports seeking.
|
UfsStatus[] |
listStatus(String path)
Returns an array of statuses of the files and directories in the directory denoted by this
abstract pathname.
|
boolean |
mkdirs(String path,
MkdirsOptions options)
Creates the directory named by this abstract pathname, with specified
MkdirsOptions . |
InputStream |
open(String path,
OpenOptions options)
Opens an
InputStream for a file in under filesystem at the indicated path. |
HdfsPositionedUnderFileInputStream |
openPositionRead(String path,
long fileLength)
Opens a file for position read.
|
boolean |
renameDirectory(String src,
String dst)
Renames a directory from
src to dst in under file system. |
boolean |
renameFile(String src,
String dst)
Renames a file from
src to dst in under file system. |
void |
setAclEntries(String path,
List<AclEntry> aclEntries)
Sets the access control list of a file or directory in under file system.
|
void |
setMode(String path,
short mode)
Changes posix file mode.
|
void |
setOwner(String path,
String user,
String group)
Sets the user and group of the given path.
|
boolean |
supportsFlush()
Whether this type of UFS supports flush.
|
createNonexistingFile, createNonexistingFile, deleteExistingDirectory, deleteExistingDirectory, deleteExistingFile, getExistingDirectoryStatus, getExistingFileStatus, getExistingStatus, isExistingDirectory, openExistingFile, openExistingFile, renameRenamableDirectory, renameRenamableFile
create, deleteDirectory, getConfiguration, getFingerprint, getOperationMode, getParsedFingerprint, getParsedFingerprint, getPhysicalStores, isObjectStorage, listStatus, listStatusIterable, mkdirs, open, performListingAsync, resolveUri, validatePath
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
create, createNonexistingFile, createNonexistingFile, deleteDirectory, deleteExistingDirectory, deleteExistingDirectory, deleteExistingFile, getConfiguration, getExistingDirectoryStatus, getExistingFileStatus, getExistingStatus, getFileStatus, getFingerprint, getOperationMode, getParsedFingerprint, getParsedFingerprint, getPhysicalStores, getStatus, getTemporaryToken, isExistingDirectory, isObjectStorage, isTemporaryConnectionToken, listStatus, listStatuses, listStatusIterable, mkdirs, open, openExistingFile, openExistingFile, refreshTemporaryToken, renameRenamableDirectory, renameRenamableFile, resolveUri, setTemporaryTokenRefreshContext
performListingAsync
protected static final int MAX_TRY
protected static final String HDFS_USER
protected static final String HDFS_ACL_PROVIDER_CLASS
protected static final String HDFS_EC_MIN_VERSION
protected static final String HDFS_EC_CODEC_REGISTRY_CLASS
protected static final String JAVAX_WS_RS_CORE_MEDIA_TYPE
protected static final String HADOOP_AUTH_METHOD
protected static final String KRB5_CONF_FILE
protected static final String KRB_KEYTAB_LOGIN_AUTO_RENEW
protected static final String CHECKSUM_COMBINE_MODE
protected final HdfsAclProvider mHdfsAclProvider
public HdfsUnderFileSystem(AlluxioURI ufsUri, UnderFileSystemConfiguration conf, org.apache.hadoop.conf.Configuration hdfsConf)
UnderFileSystem
.ufsUri
- the AlluxioURI
for this UFSconf
- the configuration for this UFShdfsConf
- the configuration for HDFSprotected HdfsUnderFileSystem(AlluxioURI ufsUri, UnderFileSystemConfiguration conf, org.apache.hadoop.conf.Configuration hdfsConf, boolean useLoadingCache)
public static HdfsUnderFileSystem createInstance(AlluxioURI ufsUri, UnderFileSystemConfiguration conf)
UnderFileSystem
instance.ufsUri
- the AlluxioURI
for this UFSconf
- the configuration for HadoopUnderFileSystem
instancepublic String getUnderFSType()
UnderFileSystem
getUnderFSType
in interface UnderFileSystem
public static org.apache.hadoop.conf.Configuration createConfiguration(UnderFileSystemConfiguration conf)
FileSystem
instance that can access the provided path.
Derived implementations that work with specialised Hadoop FileSystem API compatible implementations can override this method to add implementation specific configuration necessary for obtaining a usable FileSystem instance.
conf
- the configuration for this UFSpublic void cleanup()
UnderFileSystem
cleanup
in interface UnderFileSystem
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class BaseUnderFileSystem
public OutputStream create(String path, CreateOptions options) throws IOException
UnderFileSystem
CreateOptions
.
Implementations should make sure that the path under creation appears in listings only
after a successful close and that contents are written in its entirety or not at all.create
in interface UnderFileSystem
path
- the file nameoptions
- the options for createOutputStream
objectIOException
public OutputStream createDirect(String path, CreateOptions options) throws IOException
AtomicFileOutputStreamCallback
CreateOptions
. This stream
writes directly to the underlying storage without any atomicity guarantees.createDirect
in interface AtomicFileOutputStreamCallback
path
- the file nameoptions
- the options for createOutputStream
objectIOException
public boolean deleteDirectory(String path, DeleteOptions options) throws IOException
UnderFileSystem
deleteDirectory
in interface UnderFileSystem
path
- of the directory to deleteoptions
- for directory delete semanticsIOException
public boolean deleteFile(String path) throws IOException
UnderFileSystem
deleteFile
in interface UnderFileSystem
path
- of the file to deleteIOException
public boolean exists(String path) throws IOException
UnderFileSystem
exists
in interface UnderFileSystem
exists
in class BaseUnderFileSystem
path
- the absolute pathIOException
public Pair<AccessControlList,DefaultAccessControlList> getAclPair(String path) throws IOException
UnderFileSystem
getAclPair
in interface UnderFileSystem
getAclPair
in class BaseUnderFileSystem
path
- the path to the file or directoryIOException
- if ACL is supported and enabled but cannot be retrievedpublic void setAclEntries(String path, List<AclEntry> aclEntries) throws IOException
UnderFileSystem
setAclEntries
in interface UnderFileSystem
setAclEntries
in class BaseUnderFileSystem
path
- the path to the file or directoryaclEntries
- the access control list + default acl represented in a list of acl entriesIOException
public long getBlockSizeByte(String path) throws IOException
UnderFileSystem
getBlockSizeByte
in interface UnderFileSystem
path
- the file nameIOException
public UfsDirectoryStatus getDirectoryStatus(String path) throws IOException
UnderFileSystem
getDirectoryStatus
in interface UnderFileSystem
path
- the path to the directoryFileNotFoundException
- when the path does not existIOException
public List<String> getFileLocations(String path) throws IOException
UnderFileSystem
getFileLocations
in interface UnderFileSystem
path
- the file nameIOException
@Nullable public List<String> getFileLocations(String path, FileLocationOptions options) throws IOException
UnderFileSystem
getFileLocations
in interface UnderFileSystem
path
- the file nameoptions
- method optionsIOException
public UfsFileStatus getFileStatus(String path, GetStatusOptions options) throws IOException
UnderFileSystem
getFileStatus
in interface UnderFileSystem
path
- the path to the fileoptions
- method optionsFileNotFoundException
- when the path does not existIOException
public long getSpace(String path, UnderFileSystem.SpaceType type) throws IOException
UnderFileSystem
getSpace
in interface UnderFileSystem
path
- the path to querytype
- the type of queriesIOException
public UfsStatus getStatus(String path, GetStatusOptions options) throws IOException
UnderFileSystem
getStatus
in interface UnderFileSystem
path
- the path to get the statusoptions
- method optionsFileNotFoundException
- when the path does not existIOException
public boolean isDirectory(String path) throws IOException
UnderFileSystem
isDirectory
in interface UnderFileSystem
path
- the absolute directory pathIOException
public boolean isFile(String path) throws IOException
UnderFileSystem
isFile
in interface UnderFileSystem
path
- the absolute file pathIOException
@Nullable public UfsStatus[] listStatus(String path) throws IOException
UnderFileSystem
If this abstract pathname does not denote a directory, then this method returns null
.
Otherwise an array of statuses is returned, one for each file or directory in the directory.
Names denoting the directory itself and the directory's parent directory are not included in
the result. Each string is a file name rather than a complete path.
There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
listStatus
in interface UnderFileSystem
path
- the abstract pathname to listnull
if this abstract pathname does not denote a directory.IOException
public void connectFromMaster(String host) throws IOException
UnderFileSystem
Depending on the implementation this may be a no-op
connectFromMaster
in interface UnderFileSystem
host
- the host that wants to connect to the under file systemIOException
public void connectFromWorker(String host) throws IOException
UnderFileSystem
Depending on the implementation this may be a no-op
connectFromWorker
in interface UnderFileSystem
host
- the host that wants to connect to the under file systemIOException
public boolean mkdirs(String path, MkdirsOptions options) throws IOException
UnderFileSystem
MkdirsOptions
. If the folder already exists, the method returns false.mkdirs
in interface UnderFileSystem
path
- the folder to createoptions
- the options for mkdirstrue
if and only if the directory was created; false
otherwiseIOException
public InputStream open(String path, OpenOptions options) throws IOException
UnderFileSystem
InputStream
for a file in under filesystem at the indicated path.open
in interface UnderFileSystem
path
- the file nameoptions
- to open input streamInputStream
objectIOException
public HdfsPositionedUnderFileInputStream openPositionRead(String path, long fileLength)
UnderFileSystem
openPositionRead
in interface UnderFileSystem
path
- the path to readfileLength
- the file lengthpublic boolean renameDirectory(String src, String dst) throws IOException
UnderFileSystem
src
to dst
in under file system.renameDirectory
in interface UnderFileSystem
src
- the source directory pathdst
- the destination directory pathIOException
public boolean renameFile(String src, String dst) throws IOException
UnderFileSystem
src
to dst
in under file system.renameFile
in interface UnderFileSystem
src
- the source file pathdst
- the destination file pathIOException
public void setOwner(String path, String user, String group) throws IOException
UnderFileSystem
setOwner
in interface UnderFileSystem
path
- the path of the fileuser
- the new owner to set, unchanged if nullgroup
- the new group to set, unchanged if nullIOException
public void setMode(String path, short mode) throws IOException
UnderFileSystem
setMode
in interface UnderFileSystem
path
- the path of the filemode
- the mode to set in short format, e.g. 0777IOException
public boolean supportsFlush()
UnderFileSystem
supportsFlush
in interface UnderFileSystem
public boolean isSeekable()
UnderFileSystem
SeekableUnderFileInputStream
in the UnderFileSystem.open(String, OpenOptions)
method.isSeekable
in interface UnderFileSystem
isSeekable
in class BaseUnderFileSystem
public org.apache.hadoop.fs.FileSystem getFs() throws IOException
FileSystem
objectIOException
Copyright © 2023. All Rights Reserved.