hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r615372 - /hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsServlet.java
Date Fri, 25 Jan 2008 22:07:22 GMT
Author: dhruba
Date: Fri Jan 25 14:07:21 2008
New Revision: 615372

URL: http://svn.apache.org/viewvc?rev=615372&view=rev
Log:
HADOOP-2652. This file was erroneously left out of
the previous commit.


Added:
    hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsServlet.java   (with props)

Added: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsServlet.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsServlet.java?rev=615372&view=auto
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsServlet.java (added)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsServlet.java Fri Jan 25 14:07:21 2008
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.dfs;
+
+import java.io.IOException;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.*;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.ipc.RemoteException;
+import org.apache.hadoop.security.*;
+import org.znerd.xmlenc.XMLOutputter;
+
+/**
+ * A base class for the servlets in DFS.
+ */
+abstract class DfsServlet extends HttpServlet {
+  static final Log LOG = LogFactory.getLog(DfsServlet.class.getCanonicalName());
+
+  /** Get {@link UserGroupInformation} from request */
+  protected UnixUserGroupInformation getUGI(HttpServletRequest request) {
+    String ugi = request.getParameter("ugi");
+    try {
+      return new UnixUserGroupInformation(ugi.split(","));
+    }
+    catch(Exception e) {
+      LOG.warn("Invalid ugi (= " + ugi + ")");
+    }
+    return JspHelper.webUGI;
+  }
+
+  /**
+   * Create a {@link NameNode} proxy from the current {@link ServletContext}. 
+   */
+  protected ClientProtocol createNameNodeProxy(UnixUserGroupInformation ugi
+      ) throws IOException {
+    ServletContext context = getServletContext();
+    NameNode nn = (NameNode)context.getAttribute("name.node");
+    Configuration conf = new Configuration(
+        (Configuration)context.getAttribute("name.conf"));
+    UnixUserGroupInformation.saveToConf(conf,
+        UnixUserGroupInformation.UGI_PROPERTY_NAME, ugi);
+    return DFSClient.createNamenode(nn.getNameNodeAddress(), conf);
+  }
+
+  static void writeRemoteException(String path, RemoteException re,
+      XMLOutputter doc) throws IOException {
+    doc.startTag("RemoteException");
+    doc.attribute("path", path);
+    doc.attribute("class", re.getClassName());
+    String msg = re.getLocalizedMessage();
+    int i = msg.indexOf("\n");
+    if (i >= 0) {
+      msg = msg.substring(0, i);
+    }
+    doc.attribute("message", msg.substring(msg.indexOf(":") + 1).trim());
+    doc.endTag();
+  }
+}
\ No newline at end of file

Propchange: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DfsServlet.java
------------------------------------------------------------------------------
    svn:keywords = Id Revision HeadURL



Mime
View raw message