Package org.apache.hadoop.io.wrappedio
Class WrappedIO
java.lang.Object
org.apache.hadoop.io.wrappedio.WrappedIO
Reflection-friendly access to APIs which are not available in
some of the older Hadoop versions which libraries still
compile against.
The intent is to avoid the need for complex reflection operations including wrapping of parameter classes, direct instantiation of new classes etc.
-
Method Summary
Modifier and TypeMethodDescriptionbulkDelete_delete(FileSystem fs, Path base, Collection<Path> paths) Delete a list of files/objects.static intbulkDelete_pageSize(FileSystem fs, Path path) Get the maximum number of objects/files to delete in a single request.static voidbyteBufferPositionedReadable_readFully(InputStream in, long position, ByteBuffer buf) Delegate toByteBufferPositionedReadable.read(long, ByteBuffer).static booleanProbe to see if the input stream is an instance of ByteBufferPositionedReadable.static PathfileSystem_getEnclosingRoot(FileSystem fs, Path path) Return path of the enclosing root for a given path.static FSDataInputStreamfileSystem_openFile(FileSystem fs, Path path, String policy, FileStatus status, Long length, Map<String, String> options) OpenFile assistant, easy reflection-based access toFileSystem.openFile(Path)and blocks awaiting the operation completion.static booleanpathCapabilities_hasPathCapability(Object fs, Path path, String capability) Does a path have a given capability?static booleanstreamCapabilities_hasCapability(Object object, String capability) Does an object implementStreamCapabilitiesand, if so, what is the result of the probe for the capability?
-
Method Details
-
bulkDelete_pageSize
Get the maximum number of objects/files to delete in a single request.- Parameters:
fs- filesystempath- path to delete under.- Returns:
- a number greater than or equal to zero.
- Throws:
UnsupportedOperationException- bulk delete under that path is not supported.IllegalArgumentException- path not valid.UncheckedIOException- if an IOE was raised.
-
bulkDelete_delete
public static List<Map.Entry<Path,String>> bulkDelete_delete(FileSystem fs, Path base, Collection<Path> paths) Delete a list of files/objects.- Files must be under the path provided in
base. - The size of the list must be equal to or less than the page size.
- Directories are not supported; the outcome of attempting to delete directories is undefined (ignored; undetected, listed as failures...).
- The operation is not atomic.
- The operation is treated as idempotent: network failures may trigger resubmission of the request -any new objects created under a path in the list may then be deleted.
- There is no guarantee that any parent directories exist after this call.
- Parameters:
fs- filesystembase- path to delete under.paths- list of paths which must be absolute and under the base path.- Returns:
- a list of all the paths which couldn't be deleted for a reason other than "not found" and any associated error message.
- Throws:
UnsupportedOperationException- bulk delete under that path is not supported.UncheckedIOException- if an IOE was raised.IllegalArgumentException- if a path argument is invalid.
- Files must be under the path provided in
-
pathCapabilities_hasPathCapability
Does a path have a given capability? CallsPathCapabilities.hasPathCapability(Path, String), mapping IOExceptions to false.- Parameters:
fs- filesystempath- path to query the capability of.capability- non-null, non-empty string to query the path for support.- Returns:
- true if the capability is supported under that part of the FS. resolving paths or relaying the call.
- Throws:
IllegalArgumentException- invalid arguments
-
streamCapabilities_hasCapability
Does an object implementStreamCapabilitiesand, if so, what is the result of the probe for the capability? CallsStreamCapabilities.hasCapability(String),- Parameters:
object- object to probecapability- capability string- Returns:
- true iff the object implements StreamCapabilities and the capability is declared available.
-
fileSystem_openFile
@Stable public static FSDataInputStream fileSystem_openFile(FileSystem fs, Path path, String policy, @Nullable FileStatus status, @Nullable Long length, @Nullable Map<String, String> options) OpenFile assistant, easy reflection-based access toFileSystem.openFile(Path)and blocks awaiting the operation completion.- Parameters:
fs- filesystempath- pathpolicy- read policystatus- optional file statuslength- optional file lengthoptions- nullable map of other options- Returns:
- stream of the opened file
- Throws:
UncheckedIOException- if an IOE was raised.
-
fileSystem_getEnclosingRoot
Return path of the enclosing root for a given path. The enclosing root path is a common ancestor that should be used for temp and staging dirs as well as within encryption zones and other restricted directories.- Parameters:
fs- filesystempath- file path to find the enclosing root path for- Returns:
- a path to the enclosing root
- Throws:
IOException- early checks like failure to resolve path cause IO failures
-
byteBufferPositionedReadable_readFully
public static void byteBufferPositionedReadable_readFully(InputStream in, long position, ByteBuffer buf) Delegate toByteBufferPositionedReadable.read(long, ByteBuffer).- Parameters:
in- input streamposition- position within filebuf- the ByteBuffer to receive the results of the read operation. Note: that is the default behaviour ofFSDataInputStream.readFully(long, ByteBuffer).
-
byteBufferPositionedReadable_readFullyAvailable
Probe to see if the input stream is an instance of ByteBufferPositionedReadable. If the stream is an FSDataInputStream, the wrapped stream is checked.- Parameters:
in- input stream- Returns:
- true if the stream implements the interface (including a wrapped stream) and that it declares the stream capability.
-