HDFS-2338. Add configuration option to enable/disable webhdfs. Contributed by jitendra

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1171379 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2011-09-16 04:01:51 +00:00
parent d9ba4670ed
commit cde0e484e7
4 changed files with 20 additions and 10 deletions

View File

@ -10,6 +10,9 @@ Trunk (unreleased changes)
HDFS-2317. Support read access to HDFS in webhdfs. (szetszwo) HDFS-2317. Support read access to HDFS in webhdfs. (szetszwo)
HDFS-2338. Add configuration option to enable/disable webhdfs.
(jitendra via szetszwo)
IMPROVEMENTS IMPROVEMENTS
HADOOP-7524 Change RPC to allow multiple protocols including multuple versions of the same protocol (sanjay Radia) HADOOP-7524 Change RPC to allow multiple protocols including multuple versions of the same protocol (sanjay Radia)

View File

@ -101,6 +101,8 @@ public class DFSConfigKeys extends CommonConfigurationKeys {
public static final int DFS_NAMENODE_REPLICATION_PENDING_TIMEOUT_SEC_DEFAULT = -1; public static final int DFS_NAMENODE_REPLICATION_PENDING_TIMEOUT_SEC_DEFAULT = -1;
public static final String DFS_NAMENODE_REPLICATION_MAX_STREAMS_KEY = "dfs.namenode.replication.max-streams"; public static final String DFS_NAMENODE_REPLICATION_MAX_STREAMS_KEY = "dfs.namenode.replication.max-streams";
public static final int DFS_NAMENODE_REPLICATION_MAX_STREAMS_DEFAULT = 2; public static final int DFS_NAMENODE_REPLICATION_MAX_STREAMS_DEFAULT = 2;
public static final String DFS_WEBHDFS_ENABLED_KEY = "dfs.webhdfs.enabled";
public static final boolean DFS_WEBHDFS_ENABLED_DEFAULT = false;
public static final String DFS_PERMISSIONS_ENABLED_KEY = "dfs.permissions.enabled"; public static final String DFS_PERMISSIONS_ENABLED_KEY = "dfs.permissions.enabled";
public static final boolean DFS_PERMISSIONS_ENABLED_DEFAULT = true; public static final boolean DFS_PERMISSIONS_ENABLED_DEFAULT = true;
public static final String DFS_PERMISSIONS_SUPERUSERGROUP_KEY = "dfs.permissions.superusergroup"; public static final String DFS_PERMISSIONS_SUPERUSERGROUP_KEY = "dfs.permissions.superusergroup";

View File

@ -62,6 +62,8 @@
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_FEDERATION_NAMESERVICES; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_FEDERATION_NAMESERVICES;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_DEFAULT; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_DEFAULT;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_WEBHDFS_ENABLED_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_WEBHDFS_ENABLED_DEFAULT;
import static org.apache.hadoop.hdfs.server.common.Util.now; import static org.apache.hadoop.hdfs.server.common.Util.now;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
@ -549,10 +551,11 @@ conf, new AccessControlList(conf.get(DFS_ADMIN, " ")),
this.infoServer.addServlet(null, "/blockScannerReport", this.infoServer.addServlet(null, "/blockScannerReport",
DataBlockScanner.Servlet.class); DataBlockScanner.Servlet.class);
infoServer.addJerseyResourcePackage( if (conf.getBoolean(DFS_WEBHDFS_ENABLED_KEY, DFS_WEBHDFS_ENABLED_DEFAULT)) {
DatanodeWebHdfsMethods.class.getPackage().getName() infoServer.addJerseyResourcePackage(DatanodeWebHdfsMethods.class
+ ";" + Param.class.getPackage().getName(), .getPackage().getName() + ";" + Param.class.getPackage().getName(),
"/" + WebHdfsFileSystem.PATH_PREFIX + "/*"); "/" + WebHdfsFileSystem.PATH_PREFIX + "/*");
}
this.infoServer.start(); this.infoServer.start();
} }

View File

@ -128,7 +128,7 @@ public HttpServer run() throws IOException, InterruptedException {
nn.getNameNodeAddress()); nn.getNameNodeAddress());
httpServer.setAttribute(FSIMAGE_ATTRIBUTE_KEY, nn.getFSImage()); httpServer.setAttribute(FSIMAGE_ATTRIBUTE_KEY, nn.getFSImage());
httpServer.setAttribute(JspHelper.CURRENT_CONF, conf); httpServer.setAttribute(JspHelper.CURRENT_CONF, conf);
setupServlets(httpServer); setupServlets(httpServer, conf);
httpServer.start(); httpServer.start();
// The web-server port can be ephemeral... ensure we have the correct // The web-server port can be ephemeral... ensure we have the correct
@ -159,7 +159,7 @@ public InetSocketAddress getHttpAddress() {
return httpAddress; return httpAddress;
} }
private static void setupServlets(HttpServer httpServer) { private static void setupServlets(HttpServer httpServer, Configuration conf) {
httpServer.addInternalServlet("getDelegationToken", httpServer.addInternalServlet("getDelegationToken",
GetDelegationTokenServlet.PATH_SPEC, GetDelegationTokenServlet.PATH_SPEC,
GetDelegationTokenServlet.class, true); GetDelegationTokenServlet.class, true);
@ -182,10 +182,12 @@ private static void setupServlets(HttpServer httpServer) {
httpServer.addInternalServlet("contentSummary", "/contentSummary/*", httpServer.addInternalServlet("contentSummary", "/contentSummary/*",
ContentSummaryServlet.class, false); ContentSummaryServlet.class, false);
httpServer.addJerseyResourcePackage( if (conf.getBoolean(DFSConfigKeys.DFS_WEBHDFS_ENABLED_KEY,
NamenodeWebHdfsMethods.class.getPackage().getName() DFSConfigKeys.DFS_WEBHDFS_ENABLED_DEFAULT)) {
+ ";" + Param.class.getPackage().getName(), httpServer.addJerseyResourcePackage(NamenodeWebHdfsMethods.class
"/" + WebHdfsFileSystem.PATH_PREFIX + "/*"); .getPackage().getName() + ";" + Param.class.getPackage().getName(),
"/" + WebHdfsFileSystem.PATH_PREFIX + "/*");
}
} }
public static FSImage getFsImageFromContext(ServletContext context) { public static FSImage getFsImageFromContext(ServletContext context) {