HDFS-15389. DFSAdmin should close filesystem and dfsadmin -setBalancerBandwidth should work with ViewFSOverloadScheme. Contributed by Ayush Saxena
(cherry picked from commit cc671b16f7
)
This commit is contained in:
parent
418580446b
commit
bee2846bee
|
@ -481,7 +481,7 @@ public class DFSAdmin extends FsShell {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DistributedFileSystem getDFS() throws IOException {
|
protected DistributedFileSystem getDFS() throws IOException {
|
||||||
return AdminHelper.getDFS(getConf());
|
return AdminHelper.checkAndGetDFS(getFS(), getConf());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1036,14 +1036,7 @@ public class DFSAdmin extends FsShell {
|
||||||
System.err.println("Bandwidth should be a non-negative integer");
|
System.err.println("Bandwidth should be a non-negative integer");
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
DistributedFileSystem dfs = getDFS();
|
||||||
FileSystem fs = getFS();
|
|
||||||
if (!(fs instanceof DistributedFileSystem)) {
|
|
||||||
System.err.println("FileSystem is " + fs.getUri());
|
|
||||||
return exitCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
DistributedFileSystem dfs = (DistributedFileSystem) fs;
|
|
||||||
try{
|
try{
|
||||||
dfs.setBalancerBandwidth(bandwidth);
|
dfs.setBalancerBandwidth(bandwidth);
|
||||||
System.out.println("Balancer bandwidth is set to " + bandwidth);
|
System.out.println("Balancer bandwidth is set to " + bandwidth);
|
||||||
|
|
|
@ -263,4 +263,24 @@ public class TestViewFileSystemOverloadSchemeWithDFSAdmin {
|
||||||
assertOutMsg("Disallowing snapshot on / succeeded", 1);
|
assertOutMsg("Disallowing snapshot on / succeeded", 1);
|
||||||
assertEquals(0, ret);
|
assertEquals(0, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests setBalancerBandwidth with ViewFSOverloadScheme.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testSetBalancerBandwidth() throws Exception {
|
||||||
|
final Path hdfsTargetPath = new Path(defaultFSURI + HDFS_USER_FOLDER);
|
||||||
|
addMountLinks(defaultFSURI.getAuthority(),
|
||||||
|
new String[] {HDFS_USER_FOLDER, LOCAL_FOLDER },
|
||||||
|
new String[] {hdfsTargetPath.toUri().toString(),
|
||||||
|
localTargetDir.toURI().toString() },
|
||||||
|
conf);
|
||||||
|
final DFSAdmin dfsAdmin = new DFSAdmin(conf);
|
||||||
|
redirectStream();
|
||||||
|
int ret = ToolRunner.run(dfsAdmin,
|
||||||
|
new String[] {"-fs", defaultFSURI.toString(), "-setBalancerBandwidth",
|
||||||
|
"1000"});
|
||||||
|
assertOutMsg("Balancer bandwidth is set to 1000", 0);
|
||||||
|
assertEquals(0, ret);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue