public class DistCpUtils extends Object
| Constructor and Description |
|---|
DistCpUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkFileSystemAclSupport(FileSystem fs)
Determines if a file system supports ACLs by running a canary getAclStatus
request on the file system root.
|
static void |
checkFileSystemXAttrSupport(FileSystem fs)
Determines if a file system supports XAttrs by running a getXAttrs request
on the file system root.
|
static boolean |
checksumsAreEqual(FileSystem sourceFS,
Path source,
FileChecksum sourceChecksum,
FileSystem targetFS,
Path target)
Utility to compare checksums for the paths specified.
|
static boolean |
compareFs(FileSystem srcFs,
FileSystem destFs) |
static List<AclEntry> |
getAcl(FileSystem fileSystem,
FileStatus fileStatus)
Returns a file's full logical ACL.
|
static long |
getFileSize(Path path,
Configuration configuration)
Retrieves size of the file at the specified path.
|
static DecimalFormat |
getFormatter() |
static int |
getInt(Configuration configuration,
String label)
Utility to retrieve a specified key from a Configuration.
|
static long |
getLong(Configuration configuration,
String label)
Utility to retrieve a specified key from a Configuration.
|
static String |
getRelativePath(Path sourceRootPath,
Path childPath)
Gets relative path of child path with respect to a root path
For ex.
|
static Class<? extends InputFormat> |
getStrategy(Configuration conf,
DistCpOptions options)
Returns the class that implements a copy strategy.
|
static String |
getStringDescriptionFor(long nBytes) |
static Map<String,byte[]> |
getXAttrs(FileSystem fileSystem,
Path path)
Returns a file's all xAttrs.
|
static String |
packAttributes(EnumSet<DistCpOptions.FileAttribute> attributes)
Pack file preservation attributes into a string, containing
just the first character of each preservation attribute
|
static void |
preserve(FileSystem targetFS,
Path path,
CopyListingFileStatus srcFileStatus,
EnumSet<DistCpOptions.FileAttribute> attributes,
boolean preserveRawXattrs)
Preserve attribute on file matching that of the file status being sent
as argument.
|
static <T> void |
publish(Configuration configuration,
String label,
T value)
Utility to publish a value to a configuration.
|
static Path |
sortListing(FileSystem fs,
Configuration conf,
Path sourceListing)
Sort sequence file containing FileStatus and Text as key and value respecitvely
|
static CopyListingFileStatus |
toCopyListingFileStatus(FileSystem fileSystem,
FileStatus fileStatus,
boolean preserveAcls,
boolean preserveXAttrs,
boolean preserveRawXAttrs)
Converts a FileStatus to a CopyListingFileStatus.
|
static EnumSet<DistCpOptions.FileAttribute> |
unpackAttributes(String attributes)
Unpacks preservation attribute string containing the first character of
each preservation attribute back to a set of attributes to preserve
|
public static long getFileSize(Path path, Configuration configuration) throws IOException
path - The path of the file whose size is sought.configuration - Configuration, to retrieve the appropriate FileSystem.IOExceptionpublic static <T> void publish(Configuration configuration, String label, T value)
T - The type of the value.configuration - The Configuration to which the value must be written.label - The label for the value being published.value - The value being published.public static int getInt(Configuration configuration, String label)
configuration - The Configuration in which the key is sought.label - The key being sought.public static long getLong(Configuration configuration, String label)
configuration - The Configuration in which the key is sought.label - The key being sought.public static Class<? extends InputFormat> getStrategy(Configuration conf, DistCpOptions options)
conf - - Configuration objectoptions - - Handle to input optionspublic static String getRelativePath(Path sourceRootPath, Path childPath)
sourceRootPath - - Source root pathchildPath - - Path for which relative path is requiredpublic static String packAttributes(EnumSet<DistCpOptions.FileAttribute> attributes)
attributes - - Attribute set to preservepublic static EnumSet<DistCpOptions.FileAttribute> unpackAttributes(String attributes)
attributes - - Attribute stringpublic static void preserve(FileSystem targetFS, Path path, CopyListingFileStatus srcFileStatus, EnumSet<DistCpOptions.FileAttribute> attributes, boolean preserveRawXattrs) throws IOException
targetFS - - File systempath - - Path that needs to preserve original file statussrcFileStatus - - Original file statusattributes - - Attribute set that needs to be preservedpreserveRawXattrs - if true, raw.* xattrs should be preservedIOException - - Exception if any (particularly relating to group/owner
change or any transient error)public static List<AclEntry> getAcl(FileSystem fileSystem, FileStatus fileStatus) throws IOException
fileSystem - FileSystem containing the filefileStatus - FileStatus of fileIOException - if there is an I/O errorpublic static Map<String,byte[]> getXAttrs(FileSystem fileSystem, Path path) throws IOException
fileSystem - FileSystem containing the filepath - file pathIOException - if there is an I/O errorpublic static CopyListingFileStatus toCopyListingFileStatus(FileSystem fileSystem, FileStatus fileStatus, boolean preserveAcls, boolean preserveXAttrs, boolean preserveRawXAttrs) throws IOException
fileSystem - FileSystem containing the filefileStatus - FileStatus of filepreserveAcls - boolean true if preserving ACLspreserveXAttrs - boolean true if preserving XAttrspreserveRawXAttrs - boolean true if preserving raw.* XAttrsIOException - if there is an I/O errorpublic static Path sortListing(FileSystem fs, Configuration conf, Path sourceListing) throws IOException
fs - - File Systemconf - - ConfigurationsourceListing - - Source listing fileIOException - - Any exception during sort.public static void checkFileSystemAclSupport(FileSystem fs) throws CopyListing.AclsNotSupportedException
fs - FileSystem to checkCopyListing.AclsNotSupportedException - if fs does not support ACLspublic static void checkFileSystemXAttrSupport(FileSystem fs) throws CopyListing.XAttrsNotSupportedException
fs - FileSystem to checkCopyListing.XAttrsNotSupportedException - if fs does not support XAttrspublic static DecimalFormat getFormatter()
public static String getStringDescriptionFor(long nBytes)
public static boolean checksumsAreEqual(FileSystem sourceFS, Path source, FileChecksum sourceChecksum, FileSystem targetFS, Path target) throws IOException
sourceFS - FileSystem for the source path.source - The source path.sourceChecksum - The checksum of the source file. If it is null we
still need to retrieve it through sourceFS.targetFS - FileSystem for the target path.target - The target path.IOException - if there's an exception while retrieving checksums.public static boolean compareFs(FileSystem srcFs, FileSystem destFs)
Copyright © 2018 CERN. All Rights Reserved.