hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r931357 - in /hadoop/hdfs/trunk: CHANGES.txt src/contrib/hdfsproxy/build.xml src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/LdapIpDirFilter.java
Date Tue, 06 Apr 2010 22:38:05 GMT
Author: szetszwo
Date: Tue Apr  6 22:38:05 2010
New Revision: 931357

URL: http://svn.apache.org/viewvc?rev=931357&view=rev
Log:
HDFS-1011. hdfsproxy: Improve log messages by restoring the previous thread name.  Contributed
by Srikanth Sundarrajan

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/contrib/hdfsproxy/build.xml
    hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/LdapIpDirFilter.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=931357&r1=931356&r2=931357&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Tue Apr  6 22:38:05 2010
@@ -121,6 +121,9 @@ Trunk (unreleased changes)
 
     HDFS-1024. SecondaryNameNode verifies size of fsimage and edits file.
     (Dmytro Molkov via dhruba)
+    
+    HDFS-1011. hdfsproxy: Improve log messages by restoring the previous
+    thread name.  (Srikanth Sundarrajan via szetszwo)
 
     HDFS-997. Allow datanode storage directory permissions to be configurable.
     (Luke Lu via cdouglas)

Modified: hadoop/hdfs/trunk/src/contrib/hdfsproxy/build.xml
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/contrib/hdfsproxy/build.xml?rev=931357&r1=931356&r2=931357&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/contrib/hdfsproxy/build.xml (original)
+++ hadoop/hdfs/trunk/src/contrib/hdfsproxy/build.xml Tue Apr  6 22:38:05 2010
@@ -223,7 +223,7 @@
 	<target name="test" depends="compile,compile-test,test-junit,test-cactus" description="Automated
Test Framework" if="test.available"/>
 	
 	<target name="test-junit" depends="compile,compile-test" if="test.available">
-		<junit fork="yes" printsummary="withOutAndErr" errorProperty="tests.failed" failureProperty="tests.failed">
+		<junit fork="yes" printsummary="yes" errorProperty="tests.failed" failureProperty="tests.failed">
         <classpath refid="test.classpath"/>
         <sysproperty key="test.build.data" value="${build.test}/data"/>
 	      <sysproperty key="build.test" value="${build.test}"/>
@@ -291,7 +291,7 @@
 		<copy file="${tomcat.conf.test}/web.xml" tofile="${tomcatconfig.dir}/conf/web.xml"/>
 		<copy file="${tomcat.conf.test}/tomcat-users.xml" tofile="${tomcatconfig.dir}/conf/tomcat-users.xml"/>
 	
-		<cactus warfile="${target.dir}/${cactus.warfile.name}.war" fork="yes" haltonfailure="no"
printsummary="withOutAndErr" failureproperty="tests.failed">
+		<cactus warfile="${target.dir}/${cactus.warfile.name}.war" fork="yes" haltonfailure="no"
printsummary="yes" failureproperty="tests.failed">
 			<classpath>
 				<path refid="cactus.classpath"/>
 				<pathelement location="${build.classes}"/>

Modified: hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/LdapIpDirFilter.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/LdapIpDirFilter.java?rev=931357&r1=931356&r2=931357&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/LdapIpDirFilter.java
(original)
+++ hadoop/hdfs/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/LdapIpDirFilter.java
Tue Apr  6 22:38:05 2010
@@ -144,48 +144,57 @@ public class LdapIpDirFilter implements 
   public void doFilter(ServletRequest request, ServletResponse response,
       FilterChain chain) throws IOException, ServletException {
 
-    HttpServletRequest rqst = (HttpServletRequest) request;
-    HttpServletResponse rsp = (HttpServletResponse) response;
+    String prevThreadName = Thread.currentThread().getName();
 
-    if (LOG.isDebugEnabled()) {
-      StringBuilder b = new StringBuilder("Request from ").append(
-          rqst.getRemoteHost()).append("/").append(rqst.getRemoteAddr())
-          .append(":").append(rqst.getRemotePort());
-      b.append("\n The Scheme is " + rqst.getScheme());
-      b.append("\n The Path Info is " + rqst.getPathInfo());
-      b.append("\n The Translated Path Info is " + rqst.getPathTranslated());
-      b.append("\n The Context Path is " + rqst.getContextPath());
-      b.append("\n The Query String is " + rqst.getQueryString());
-      b.append("\n The Request URI is " + rqst.getRequestURI());
-      b.append("\n The Request URL is " + rqst.getRequestURL());
-      b.append("\n The Servlet Path is " + rqst.getServletPath());
-      LOG.debug(b.toString());
-    }
-    LdapRoleEntry ldapent = new LdapRoleEntry();
-    // check ip address
-    String userIp = rqst.getRemoteAddr();
     try {
-      boolean isAuthorized = getLdapRoleEntryFromUserIp(userIp, ldapent);
-      if (!isAuthorized) {
-        rsp.sendError(HttpServletResponse.SC_FORBIDDEN, "IP " + userIp
-            + " is not authorized to access");
-        return;
+      HttpServletRequest rqst = (HttpServletRequest) request;
+      HttpServletResponse rsp = (HttpServletResponse) response;
+
+      String contextPath = rqst.getContextPath();
+      Thread.currentThread().setName(contextPath);
+
+      if (LOG.isDebugEnabled()) {
+        StringBuilder b = new StringBuilder("Request from ").append(
+            rqst.getRemoteHost()).append("/").append(rqst.getRemoteAddr())
+            .append(":").append(rqst.getRemotePort());
+        b.append("\n The Scheme is " + rqst.getScheme());
+        b.append("\n The Path Info is " + rqst.getPathInfo());
+        b.append("\n The Translated Path Info is " + rqst.getPathTranslated());
+        b.append("\n The Context Path is " + rqst.getContextPath());
+        b.append("\n The Query String is " + rqst.getQueryString());
+        b.append("\n The Request URI is " + rqst.getRequestURI());
+        b.append("\n The Request URL is " + rqst.getRequestURL());
+        b.append("\n The Servlet Path is " + rqst.getServletPath());
+        LOG.debug(b.toString());
+      }
+      LdapRoleEntry ldapent = new LdapRoleEntry();
+      // check ip address
+      String userIp = rqst.getRemoteAddr();
+      try {
+        boolean isAuthorized = getLdapRoleEntryFromUserIp(userIp, ldapent);
+        if (!isAuthorized) {
+          rsp.sendError(HttpServletResponse.SC_FORBIDDEN, "IP " + userIp
+              + " is not authorized to access");
+          return;
+        }
+      } catch (NamingException ne) {
+        throw new IOException("NamingException while searching ldap"
+            + ne.toString());
       }
-    } catch (NamingException ne) {
-      throw new IOException("NamingException while searching ldap"
-          + ne.toString());
-    }
 
-    // since we cannot pass ugi object cross context as they are from
-    // different
-    // classloaders in different war file, we have to use String attribute.
-    rqst.setAttribute("org.apache.hadoop.hdfsproxy.authorized.userID",
+      // since we cannot pass ugi object cross context as they are from
+      // different
+      // classloaders in different war file, we have to use String attribute.
+      rqst.setAttribute("org.apache.hadoop.hdfsproxy.authorized.userID",
         ldapent.userId);
-    rqst.setAttribute("org.apache.hadoop.hdfsproxy.authorized.paths",
+      rqst.setAttribute("org.apache.hadoop.hdfsproxy.authorized.paths",
         ldapent.paths);
-    LOG.info("User: " + ldapent.userId + ", Request: " + rqst.getPathInfo() +
-            " From: " + rqst.getRemoteAddr());
-    chain.doFilter(request, response);
+      LOG.info("User: " + ldapent.userId + ", Request: " + rqst.getPathInfo() +
+              " From: " + rqst.getRemoteAddr());
+      chain.doFilter(request, response);
+    } finally {
+      Thread.currentThread().setName(prevThreadName);
+    }
   }
 
   /**



Mime
View raw message