|
@@ -223,6 +223,14 @@ public class DFSck extends Configured implements Tool {
|
|
|
return errCode;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private Path getResolvedPath(String dir) throws IOException {
|
|
|
+ Configuration conf = getConf();
|
|
|
+ Path dirPath = new Path(dir);
|
|
|
+ FileSystem fs = dirPath.getFileSystem(conf);
|
|
|
+ return fs.resolvePath(dirPath);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Derive the namenode http address from the current file system,
|
|
|
* either default or as set by "-fs" in the generic options.
|
|
@@ -234,19 +242,12 @@ public class DFSck extends Configured implements Tool {
|
|
|
Configuration conf = getConf();
|
|
|
|
|
|
//get the filesystem object to verify it is an HDFS system
|
|
|
- final FileSystem fs;
|
|
|
- try {
|
|
|
- fs = target.getFileSystem(conf);
|
|
|
- } catch (IOException ioe) {
|
|
|
- System.err.println("FileSystem is inaccessible due to:\n"
|
|
|
- + StringUtils.stringifyException(ioe));
|
|
|
- return null;
|
|
|
- }
|
|
|
+ final FileSystem fs = target.getFileSystem(conf);
|
|
|
if (!(fs instanceof DistributedFileSystem)) {
|
|
|
System.err.println("FileSystem is " + fs.getUri());
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return DFSUtil.getInfoServer(HAUtil.getAddressOfActive(fs), conf,
|
|
|
DFSUtil.getHttpClientScheme(conf));
|
|
|
}
|
|
@@ -300,8 +301,16 @@ public class DFSck extends Configured implements Tool {
|
|
|
dir = "/";
|
|
|
}
|
|
|
|
|
|
- final Path dirpath = new Path(dir);
|
|
|
- final URI namenodeAddress = getCurrentNamenodeAddress(dirpath);
|
|
|
+ Path dirpath = null;
|
|
|
+ URI namenodeAddress = null;
|
|
|
+ try {
|
|
|
+ dirpath = getResolvedPath(dir);
|
|
|
+ namenodeAddress = getCurrentNamenodeAddress(dirpath);
|
|
|
+ } catch (IOException ioe) {
|
|
|
+ System.err.println("FileSystem is inaccessible due to:\n"
|
|
|
+ + StringUtils.stringifyException(ioe));
|
|
|
+ }
|
|
|
+
|
|
|
if (namenodeAddress == null) {
|
|
|
//Error message already output in {@link #getCurrentNamenodeAddress()}
|
|
|
System.err.println("DFSck exiting.");
|