|
64 | 64 | public class RawLocalFileSystem extends FileSystem { |
65 | 65 | static final URI NAME = URI.create("file:///"); |
66 | 66 | private Path workingDir; |
| 67 | + private long defaultBlockSize; |
67 | 68 | // Temporary workaround for HADOOP-9652. |
68 | 69 | private static boolean useDeprecatedFileStatus = true; |
69 | 70 |
|
@@ -100,6 +101,7 @@ public File pathToFile(Path path) { |
100 | 101 | public void initialize(URI uri, Configuration conf) throws IOException { |
101 | 102 | super.initialize(uri, conf); |
102 | 103 | setConf(conf); |
| 104 | + defaultBlockSize = getDefaultBlockSize(new Path(uri)); |
103 | 105 | } |
104 | 106 |
|
105 | 107 | /******************************************************* |
@@ -518,7 +520,12 @@ public FileStatus[] listStatus(Path f) throws IOException { |
518 | 520 | } |
519 | 521 | return new FileStatus[] { |
520 | 522 | new DeprecatedRawLocalFileStatus(localf, |
521 | | - getDefaultBlockSize(f), this) }; |
| 523 | + defaultBlockSize, this) }; |
| 524 | + } |
| 525 | + |
| 526 | + @Override |
| 527 | + public boolean exists(Path f) throws IOException { |
| 528 | + return pathToFile(f).exists(); |
522 | 529 | } |
523 | 530 |
|
524 | 531 | protected boolean mkOneDir(File p2f) throws IOException { |
@@ -663,7 +670,7 @@ private FileStatus deprecatedGetFileStatus(Path f) throws IOException { |
663 | 670 | File path = pathToFile(f); |
664 | 671 | if (path.exists()) { |
665 | 672 | return new DeprecatedRawLocalFileStatus(pathToFile(f), |
666 | | - getDefaultBlockSize(f), this); |
| 673 | + defaultBlockSize, this); |
667 | 674 | } else { |
668 | 675 | throw new FileNotFoundException("File " + f + " does not exist"); |
669 | 676 | } |
@@ -1051,7 +1058,7 @@ private FileStatus deprecatedGetFileLinkStatusInternal(final Path f) |
1051 | 1058 | private FileStatus getNativeFileLinkStatus(final Path f, |
1052 | 1059 | boolean dereference) throws IOException { |
1053 | 1060 | checkPath(f); |
1054 | | - Stat stat = new Stat(f, getDefaultBlockSize(f), dereference, this); |
| 1061 | + Stat stat = new Stat(f, defaultBlockSize, dereference, this); |
1055 | 1062 | FileStatus status = stat.getFileStatus(); |
1056 | 1063 | return status; |
1057 | 1064 | } |
|
0 commit comments