HDFS-3331. In namenode, check superuser privilege for setBalancerBandwidth and acquire the write lock for finalizeUpgrade.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1331598 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2012-04-27 21:17:53 +00:00
parent 920b8fac18
commit cd271773ac
4 changed files with 26 additions and 9 deletions

View File

@ -917,7 +917,11 @@ Release 0.23.3 - UNRELEASED
HDFS-3321. Fix safe mode turn off tip message. (Ravi Prakash via szetszwo)
HDFS-3334. Fix ByteRangeInputStream stream leakage. (Daryn Sharp via szetszwo)
HDFS-3334. Fix ByteRangeInputStream stream leakage. (Daryn Sharp via
szetszwo)
HDFS-3331. In namenode, check superuser privilege for setBalancerBandwidth
and acquire the write lock for finalizeUpgrade. (szetszwo)
Release 0.23.2 - UNRELEASED

View File

@ -651,7 +651,6 @@ nodes with its data cleared (or user can just remove the StorageID
* checks if any of the hosts have changed states:
*/
public void refreshNodes(final Configuration conf) throws IOException {
namesystem.checkSuperuserPrivilege();
refreshHostsReader(conf);
namesystem.writeLock();
try {

View File

@ -3332,8 +3332,26 @@ Date getStartTime() {
}
void finalizeUpgrade() throws IOException {
writeLock();
try {
checkOperation(OperationCategory.WRITE);
checkSuperuserPrivilege();
getFSImage().finalizeUpgrade();
} finally {
writeUnlock();
}
}
void refreshNodes() throws IOException {
checkOperation(OperationCategory.UNCHECKED);
checkSuperuserPrivilege();
getFSImage().finalizeUpgrade();
getBlockManager().getDatanodeManager().refreshNodes(new HdfsConfiguration());
}
void setBalancerBandwidth(long bandwidth) throws IOException {
checkOperation(OperationCategory.UNCHECKED);
checkSuperuserPrivilege();
getBlockManager().getDatanodeManager().setBalancerBandwidth(bandwidth);
}
/**

View File

@ -707,9 +707,7 @@ public void saveNamespace() throws IOException {
@Override // ClientProtocol
public void refreshNodes() throws IOException {
namesystem.checkOperation(OperationCategory.UNCHECKED);
namesystem.getBlockManager().getDatanodeManager().refreshNodes(
new HdfsConfiguration());
namesystem.refreshNodes();
}
@Override // NamenodeProtocol
@ -732,7 +730,6 @@ public RemoteEditLogManifest getEditLogManifest(long sinceTxId)
@Override // ClientProtocol
public void finalizeUpgrade() throws IOException {
namesystem.checkOperation(OperationCategory.WRITE);
namesystem.finalizeUpgrade();
}
@ -772,8 +769,7 @@ public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie)
*/
@Override // ClientProtocol
public void setBalancerBandwidth(long bandwidth) throws IOException {
namesystem.checkOperation(OperationCategory.UNCHECKED);
namesystem.getBlockManager().getDatanodeManager().setBalancerBandwidth(bandwidth);
namesystem.setBalancerBandwidth(bandwidth);
}
@Override // ClientProtocol