Package org.apache.hadoop.fs
Class ChecksumFs
java.lang.Object
org.apache.hadoop.fs.AbstractFileSystem
org.apache.hadoop.fs.FilterFs
org.apache.hadoop.fs.ChecksumFs
- All Implemented Interfaces:
PathCapabilities
- Direct Known Subclasses:
LocalFs
Abstract Checksumed Fs.
It provide a basic implementation of a Checksumed Fs,
which creates a checksum file for each raw file.
It generates & verifies checksums at the client side.
-
Field Summary
Fields inherited from class org.apache.hadoop.fs.AbstractFileSystem
statistics -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateInternal(Path f, EnumSet<CreateFlag> createFlag, FsPermission absolutePermission, int bufferSize, short replication, long blockSize, Progressable progress, Options.ChecksumOpt checksumOpt, boolean createParent) The specification of this method matches that ofAbstractFileSystem.create(Path, EnumSet, Options.CreateOpts...)except that the opts have been declared explicitly.booleanImplement the delete(Path, boolean) in checksum file system.static doublegetApproxChkSumLength(long size) intReturn the bytes Per Checksum.getChecksumFile(Path file) Return the name of the checksum file associated with a file.longgetChecksumFileLength(Path file, long fileSize) Return the length of the checksum file given the size of the actual file.static longgetChecksumLength(long size, int bytesPerSum) Calculated the length of the checksum file in bytes.getRawFs()get the raw file system.static booleanisChecksumFile(Path file) Return true iff file is a checksum file name.The specification of this method matches that ofFileContext.listLocatedStatus(Path)except that Path f must be for this file system.listStatus(Path f) The specification of this method matches that ofFileContext.Util.listStatus(Path)except that Path f must be for this file system.Opens an FSDataInputStream at the indicated Path.voidrenameInternal(Path src, Path dst) Rename files/dirs.voidrenameInternal(Path src, Path dst, boolean overwrite) The specification of this method matches that ofFileContext.rename(Path, Path, Options.Rename...)except that Path f must be for this file system.booleanreportChecksumFailure(Path f, FSDataInputStream in, long inPos, FSDataInputStream sums, long sumsPos) Report a checksum error to the file system.booleansetReplication(Path src, short replication) Set replication for an existing file.voidsetVerifyChecksum(boolean inVerifyChecksum) Set whether to verify checksum.booleanThe specification of this method matches that ofFileContext.truncate(Path, long)except that Path f must be for this file system.Methods inherited from class org.apache.hadoop.fs.FilterFs
access, checkPath, createMultipartUploader, createSnapshot, createSymlink, deleteSnapshot, getAclStatus, getAllStoragePolicies, getCanonicalServiceName, getDelegationTokens, getEnclosingRoot, getFileBlockLocations, getFileChecksum, getFileLinkStatus, getFileStatus, getFsStatus, getFsStatus, getHomeDirectory, getInitialWorkingDirectory, getLinkTarget, getMyFs, getServerDefaults, getServerDefaults, getStatistics, getStoragePolicy, getUri, getUriDefaultPort, getUriPath, getXAttr, getXAttrs, getXAttrs, hasPathCapability, isValidName, listCorruptFileBlocks, listXAttrs, makeQualified, mkdir, modifyAclEntries, msync, open, openFileWithOptions, removeAcl, removeAclEntries, removeDefaultAcl, removeXAttr, renameSnapshot, resolvePath, satisfyStoragePolicy, setAcl, setOwner, setPermission, setStoragePolicy, setTimes, setXAttr, setXAttr, supportsSymlinks, unsetStoragePolicyMethods inherited from class org.apache.hadoop.fs.AbstractFileSystem
checkScheme, clearStatistics, create, createFileSystem, equals, get, getAllStatistics, getStatistics, hashCode, listStatusIterator, methodNotSupported, printStatistics, rename
-
Constructor Details
-
ChecksumFs
- Throws:
IOExceptionURISyntaxException
-
-
Method Details
-
getApproxChkSumLength
public static double getApproxChkSumLength(long size) -
setVerifyChecksum
public void setVerifyChecksum(boolean inVerifyChecksum) Set whether to verify checksum.- Overrides:
setVerifyChecksumin classFilterFs- Parameters:
inVerifyChecksum- verify check sum flag.
-
getRawFs
get the raw file system.- Returns:
- abstract file system.
-
getChecksumFile
Return the name of the checksum file associated with a file.- Parameters:
file- the file path.- Returns:
- the checksum file associated with a file.
-
isChecksumFile
Return true iff file is a checksum file name.- Parameters:
file- the file path.- Returns:
- if is checksum file true,not false.
-
getChecksumFileLength
Return the length of the checksum file given the size of the actual file.- Parameters:
file- the file path.fileSize- file size.- Returns:
- check sum file length.
-
getBytesPerSum
public int getBytesPerSum()Return the bytes Per Checksum.- Returns:
- bytes per sum.
-
truncate
Description copied from class:AbstractFileSystemThe specification of this method matches that ofFileContext.truncate(Path, long)except that Path f must be for this file system.- Overrides:
truncatein classFilterFs- Parameters:
f- the path.newLength- new length.- Returns:
- if successfully truncate success true, not false.
- Throws:
AccessControlException- access control exception.FileNotFoundException- file not found exception.UnresolvedLinkException- unresolved link exception.IOException- raised on errors performing I/O.
-
open
Opens an FSDataInputStream at the indicated Path.- Overrides:
openin classFilterFs- Parameters:
f- the file name to openbufferSize- the size of the buffer to be used.- Returns:
- if successfully open success true, not false.
- Throws:
AccessControlException- access control exception.FileNotFoundException- file not found exception.UnresolvedLinkException- unresolved link exception.IOException- raised on errors performing I/O.
-
getChecksumLength
public static long getChecksumLength(long size, int bytesPerSum) Calculated the length of the checksum file in bytes.- Parameters:
size- the length of the data file in bytesbytesPerSum- the number of bytes in a checksum block- Returns:
- the number of bytes in the checksum file
-
createInternal
public FSDataOutputStream createInternal(Path f, EnumSet<CreateFlag> createFlag, FsPermission absolutePermission, int bufferSize, short replication, long blockSize, Progressable progress, Options.ChecksumOpt checksumOpt, boolean createParent) throws IOException Description copied from class:AbstractFileSystemThe specification of this method matches that ofAbstractFileSystem.create(Path, EnumSet, Options.CreateOpts...)except that the opts have been declared explicitly.- Overrides:
createInternalin classFilterFs- Parameters:
f- the path.createFlag- create flag.absolutePermission- absolute permission.bufferSize- buffer size.replication- replications.blockSize- block size.progress- progress.checksumOpt- check sum opt.createParent- create parent.- Returns:
- output stream.
- Throws:
AccessControlException- access control exception.FileAlreadyExistsException- file already exists exception.FileNotFoundException- file not found exception.ParentNotDirectoryException- parent not directory exception.UnsupportedFileSystemException- unsupported filesystem exception.UnresolvedLinkException- unresolved link exception.IOException- raised on errors performing I/O.
-
setReplication
public boolean setReplication(Path src, short replication) throws IOException, UnresolvedLinkException Set replication for an existing file. Implement the abstractsetReplicationofFileSystem- Overrides:
setReplicationin classFilterFs- Parameters:
src- file namereplication- new replication- Returns:
- true if successful; false if file does not exist or is a directory
- Throws:
IOException- if an I/O error occurs.UnresolvedLinkException- unresolved link exception.
-
renameInternal
Rename files/dirs.- Overrides:
renameInternalin classFilterFs- Parameters:
src- src.dst- dst.- Throws:
AccessControlException- access control exception.FileAlreadyExistsException- file already exists exception.FileNotFoundException- file not found exception.ParentNotDirectoryException- parent not directory exception.UnresolvedLinkException- unresolved link exception.IOException- raised on errors performing I/O.
-
renameInternal
public void renameInternal(Path src, Path dst, boolean overwrite) throws AccessControlException, FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnresolvedLinkException, IOException Description copied from class:AbstractFileSystemThe specification of this method matches that ofFileContext.rename(Path, Path, Options.Rename...)except that Path f must be for this file system.- Overrides:
renameInternalin classFilterFs- Parameters:
src- src.dst- dst.overwrite- overwrite flag.- Throws:
AccessControlException- access control exception.FileAlreadyExistsException- file already exists exception.FileNotFoundException- file not found exception.ParentNotDirectoryException- parent not directory exception.UnresolvedLinkException- unresolved link exception.IOException- raised on errors performing I/O.
-
delete
Implement the delete(Path, boolean) in checksum file system.- Overrides:
deletein classFilterFs- Parameters:
f- the path.recursive- recursive flag.- Returns:
- if successfully deleted success true, not false.
- Throws:
AccessControlException- access control exception.FileNotFoundException- file not found exception.UnresolvedLinkException- unresolved link exception.IOException- raised on errors performing I/O.
-
reportChecksumFailure
public boolean reportChecksumFailure(Path f, FSDataInputStream in, long inPos, FSDataInputStream sums, long sumsPos) Report a checksum error to the file system.- Parameters:
f- the file name containing the errorin- the stream open on the fileinPos- the position of the beginning of the bad data in the filesums- the stream open on the checksum filesumsPos- the position of the beginning of the bad data in the checksum file- Returns:
- if retry is necessary
-
listStatus
Description copied from class:AbstractFileSystemThe specification of this method matches that ofFileContext.Util.listStatus(Path)except that Path f must be for this file system.- Overrides:
listStatusin classFilterFs- Parameters:
f- the path.- Returns:
- FileStatus Iterator.
- Throws:
AccessControlException- access control exception.FileNotFoundException- file not found exception.UnresolvedLinkException- unresolved link exception.IOException- raised on errors performing I/O.
-
listLocatedStatus
public RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f) throws AccessControlException, FileNotFoundException, UnresolvedLinkException, IOException Description copied from class:AbstractFileSystemThe specification of this method matches that ofFileContext.listLocatedStatus(Path)except that Path f must be for this file system. In HDFS implementation, the BlockLocation of returned LocatedFileStatus will have different formats for replicated and erasure coded file. Please refer toFileSystem.getFileBlockLocations(FileStatus, long, long)for more details.- Overrides:
listLocatedStatusin classFilterFs- Parameters:
f- the path.- Returns:
- FileStatus Iterator.
- Throws:
AccessControlException- access control exception.FileNotFoundException- file not found exception.UnresolvedLinkException- unresolved link exception.IOException- raised on errors performing I/O.
-