HADOOP-13321. Deprecate FileSystem APIs that promote inefficient call patterns. Contributed by Chris Nauroth and Mingliang Liu

This commit is contained in:
Mingliang Liu 2017-02-16 16:25:51 -08:00
parent a207aa9930
commit a4d4a23785
5 changed files with 18 additions and 0 deletions

View File

@ -605,6 +605,7 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
* Rename files/dirs
*/
@Override
@SuppressWarnings("deprecation")
public boolean rename(Path src, Path dst) throws IOException {
if (fs.isDirectory(src)) {
return fs.rename(src, dst);
@ -721,6 +722,7 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
* If src and dst are directories, the copyCrc parameter
* determines whether to copy CRC files.
*/
@SuppressWarnings("deprecation")
public void copyToLocalFile(Path src, Path dst, boolean copyCrc)
throws IOException {
if (!fs.isDirectory(src)) { // source is a file

View File

@ -1624,6 +1624,11 @@ public abstract class FileSystem extends Configured implements Closeable {
}
/** Check if a path exists.
*
* It is highly discouraged to call this method back to back with other
* {@link #getFileStatus(Path)} calls, as this will involve multiple redundant
* RPC calls in HDFS.
*
* @param f source path
* @return true if the path exists
* @throws IOException IO failure
@ -1639,9 +1644,12 @@ public abstract class FileSystem extends Configured implements Closeable {
/** True iff the named path is a directory.
* Note: Avoid using this method. Instead reuse the FileStatus
* returned by getFileStatus() or listStatus() methods.
*
* @param f path to check
* @throws IOException IO failure
* @deprecated Use {@link #getFileStatus(Path)} instead
*/
@Deprecated
public boolean isDirectory(Path f) throws IOException {
try {
return getFileStatus(f).isDirectory();
@ -1653,9 +1661,12 @@ public abstract class FileSystem extends Configured implements Closeable {
/** True iff the named path is a regular file.
* Note: Avoid using this method. Instead reuse the FileStatus
* returned by {@link #getFileStatus(Path)} or listStatus() methods.
*
* @param f path to check
* @throws IOException IO failure
* @deprecated Use {@link #getFileStatus(Path)} instead
*/
@Deprecated
public boolean isFile(Path f) throws IOException {
try {
return getFileStatus(f).isFile();

View File

@ -644,6 +644,7 @@ public class FTPFileSystem extends FileSystem {
* @return
* @throws IOException
*/
@SuppressWarnings("deprecation")
private boolean rename(FTPClient client, Path src, Path dst)
throws IOException {
Path workDir = new Path(client.printWorkingDirectory());

View File

@ -2142,6 +2142,7 @@ public class S3AFileSystem extends FileSystem {
* {@inheritDoc}
*/
@Override
@SuppressWarnings("deprecation")
public boolean isDirectory(Path f) throws IOException {
incrementStatistic(INVOCATION_IS_DIRECTORY);
return super.isDirectory(f);
@ -2152,6 +2153,7 @@ public class S3AFileSystem extends FileSystem {
* {@inheritDoc}
*/
@Override
@SuppressWarnings("deprecation")
public boolean isFile(Path f) throws IOException {
incrementStatistic(INVOCATION_IS_FILE);
return super.isFile(f);

View File

@ -201,6 +201,7 @@ public class SwiftNativeFileSystem extends FileSystem {
}
@Override
@SuppressWarnings("deprecation")
public boolean isFile(Path f) throws IOException {
try {
FileStatus fileStatus = getFileStatus(f);
@ -210,6 +211,7 @@ public class SwiftNativeFileSystem extends FileSystem {
}
}
@SuppressWarnings("deprecation")
@Override
public boolean isDirectory(Path f) throws IOException {