You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sh...@apache.org on 2008/01/23 03:20:20 UTC
svn commit: r614410 - in /lucene/hadoop/trunk: CHANGES.txt
src/java/org/apache/hadoop/dfs/FSNamesystem.java
src/java/org/apache/hadoop/dfs/NameNode.java
Author: shv
Date: Tue Jan 22 18:20:06 2008
New Revision: 614410
URL: http://svn.apache.org/viewvc?rev=614410&view=rev
Log:
HADOOP-2659. Introduce superuser permissions for admin operations. Contributed by Tsz Wo (Nicholas), SZE
Modified:
lucene/hadoop/trunk/CHANGES.txt
lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=614410&r1=614409&r2=614410&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Tue Jan 22 18:20:06 2008
@@ -278,6 +278,9 @@
HADOOP-2469. WritableUtils.clone should take a Configuration
instead of a JobConf. (stack via omalley)
+ HADOOP-2659. Introduce superuser permissions for admin operations.
+ (Tsz Wo (Nicholas), SZE via shv)
+
OPTIMIZATIONS
HADOOP-1898. Release the lock protecting the last time of the last stack
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java?rev=614410&r1=614409&r2=614410&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSNamesystem.java Tue Jan 22 18:20:06 2008
@@ -423,6 +423,7 @@
* Dump all metadata into specified file
*/
void metaSave(String filename) throws IOException {
+ checkSuperuserPrivilege();
File file = new File(System.getProperty("hadoop.log.dir"),
filename);
PrintWriter out = new PrintWriter(new BufferedWriter(
@@ -2740,6 +2741,13 @@
pendingReplications.remove(block);
}
+ long[] getStats() throws IOException {
+ checkSuperuserPrivilege();
+ synchronized(heartbeats) {
+ return new long[]{totalCapacity(), totalDfsUsed(), totalRemaining()};
+ }
+ }
+
/**
* Total raw bytes including non-dfs used space.
*/
@@ -2829,7 +2837,9 @@
return nodes;
}
- public synchronized DatanodeInfo[] datanodeReport( DatanodeReportType type ) {
+ public synchronized DatanodeInfo[] datanodeReport( DatanodeReportType type
+ ) throws AccessControlException {
+ checkSuperuserPrivilege();
ArrayList<DatanodeDescriptor> results = getDatanodeListForReport(type);
DatanodeInfo[] arr = new DatanodeInfo[results.size()];
@@ -3282,6 +3292,7 @@
* 4. Removed from exclude --> stop decommission.
*/
void refreshNodes() throws IOException {
+ checkSuperuserPrivilege();
hostsReader.refresh();
synchronized (this) {
for (Iterator<DatanodeDescriptor> it = datanodeMap.values().iterator();
@@ -3308,6 +3319,10 @@
}
+ void finalizeUpgrade() throws IOException {
+ checkSuperuserPrivilege();
+ getFSImage().finalizeUpgrade();
+ }
/**
* Checks if the node is not on the hosts list. If it is not, then
@@ -3731,6 +3746,20 @@
return System.currentTimeMillis();
}
+ boolean setSafeMode(SafeModeAction action) throws IOException {
+ checkSuperuserPrivilege();
+ switch(action) {
+ case SAFEMODE_LEAVE: // leave safe mode
+ leaveSafeMode(false);
+ break;
+ case SAFEMODE_ENTER: // enter safe mode
+ enterSafeMode();
+ break;
+ case SAFEMODE_GET: // get safe mode
+ }
+ return isInSafeMode();
+ }
+
/**
* Check whether the name node is in safe mode.
* @return true if safe mode is ON, false otherwise
@@ -3937,6 +3966,16 @@
private PermissionChecker checkTraverse(String path
) throws AccessControlException {
return checkPermission(path, false, null, null, null, null);
+ }
+
+ private void checkSuperuserPrivilege() throws AccessControlException {
+ if (isPermissionEnabled) {
+ PermissionChecker pc = new PermissionChecker(
+ fsOwner.getUserName(), supergroup);
+ if (!pc.isSuper) {
+ throw new AccessControlException("Superuser privilege is required");
+ }
+ }
}
/**
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java?rev=614410&r1=614409&r2=614410&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java Tue Jan 22 18:20:06 2008
@@ -430,7 +430,8 @@
return files;
}
- /* Get the file info for a specific file.
+ /**
+ * Get the file info for a specific file.
* @param src The string representation of the path to the file
* @throws IOException if file does not exist
* @return object containing information regarding the file
@@ -439,14 +440,9 @@
return namesystem.getFileInfo(src);
}
- /**
- */
+ /** @inheritDoc */
public long[] getStats() throws IOException {
- long results[] = new long[3];
- results[0] = namesystem.totalCapacity();
- results[1] = namesystem.totalDfsUsed();
- results[2] = namesystem.totalRemaining();
- return results;
+ return namesystem.getStats();
}
/**
@@ -464,16 +460,7 @@
* @inheritDoc
*/
public boolean setSafeMode(SafeModeAction action) throws IOException {
- switch(action) {
- case SAFEMODE_LEAVE: // leave safe mode
- namesystem.leaveSafeMode(false);
- break;
- case SAFEMODE_ENTER: // enter safe mode
- namesystem.enterSafeMode();
- break;
- case SAFEMODE_GET: // get safe mode
- }
- return namesystem.isInSafeMode();
+ return namesystem.setSafeMode(action);
}
/**
@@ -513,7 +500,7 @@
}
public void finalizeUpgrade() throws IOException {
- getFSImage().finalizeUpgrade();
+ namesystem.finalizeUpgrade();
}
public UpgradeStatusReport distributedUpgradeProgress(UpgradeAction action