Repository: hadoop
Updated Branches:
  refs/heads/branch-2 a36fd8867 -> a58f88056


HDFS-7232. Populate hostname in httpfs audit log (Zoran Dimitrijevic via aw)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a58f8805
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a58f8805
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a58f8805

Branch: refs/heads/branch-2
Commit: a58f88056cc102e7c4d68c657ff64ef4c897031a
Parents: a36fd88
Author: Allen Wittenauer <[email protected]>
Authored: Thu Oct 23 14:07:07 2014 -0700
Committer: Allen Wittenauer <[email protected]>
Committed: Thu Oct 23 14:07:07 2014 -0700

----------------------------------------------------------------------
 .../hadoop/fs/http/server/HttpFSServer.java     | 22 ++++++++++++++------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 +++
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/a58f8805/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
 
b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
index db11361..f9eb454 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
@@ -59,6 +59,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -164,9 +165,10 @@ public class HttpFSServer {
   @GET
   @Produces(MediaType.APPLICATION_JSON)
   public Response getRoot(@QueryParam(OperationParam.NAME) OperationParam op,
-                          @Context Parameters params)
+                          @Context Parameters params,
+                          @Context HttpServletRequest request)
     throws IOException, FileSystemAccessException {
-    return get("", op, params);
+    return get("", op, params, request);
   }
 
   private String makeAbsolute(String path) {
@@ -193,12 +195,14 @@ public class HttpFSServer {
   @Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
   public Response get(@PathParam("path") String path,
                       @QueryParam(OperationParam.NAME) OperationParam op,
-                      @Context Parameters params)
+                      @Context Parameters params,
+                      @Context HttpServletRequest request)
     throws IOException, FileSystemAccessException {
     UserGroupInformation user = HttpUserGroupInformation.get();
     Response response;
     path = makeAbsolute(path);
     MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
+    MDC.put("hostname", request.getRemoteAddr());
     switch (op.value()) {
       case OPEN: {
         //Invoking the command directly using an unmanaged FileSystem that is
@@ -334,12 +338,14 @@ public class HttpFSServer {
   @Produces(MediaType.APPLICATION_JSON)
   public Response delete(@PathParam("path") String path,
                          @QueryParam(OperationParam.NAME) OperationParam op,
-                         @Context Parameters params)
+                         @Context Parameters params,
+                         @Context HttpServletRequest request)
     throws IOException, FileSystemAccessException {
     UserGroupInformation user = HttpUserGroupInformation.get();
     Response response;
     path = makeAbsolute(path);
     MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
+    MDC.put("hostname", request.getRemoteAddr());
     switch (op.value()) {
       case DELETE: {
         Boolean recursive =
@@ -385,12 +391,14 @@ public class HttpFSServer {
                        @Context UriInfo uriInfo,
                        @PathParam("path") String path,
                        @QueryParam(OperationParam.NAME) OperationParam op,
-                       @Context Parameters params)
+                       @Context Parameters params,
+                       @Context HttpServletRequest request)
     throws IOException, FileSystemAccessException {
     UserGroupInformation user = HttpUserGroupInformation.get();
     Response response;
     path = makeAbsolute(path);
     MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
+    MDC.put("hostname", request.getRemoteAddr());
     switch (op.value()) {
       case APPEND: {
         Boolean hasData = params.get(DataParam.NAME, DataParam.class);
@@ -469,12 +477,14 @@ public class HttpFSServer {
                        @Context UriInfo uriInfo,
                        @PathParam("path") String path,
                        @QueryParam(OperationParam.NAME) OperationParam op,
-                       @Context Parameters params)
+                       @Context Parameters params,
+                       @Context HttpServletRequest request)
     throws IOException, FileSystemAccessException {
     UserGroupInformation user = HttpUserGroupInformation.get();
     Response response;
     path = makeAbsolute(path);
     MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
+    MDC.put("hostname", request.getRemoteAddr());
     switch (op.value()) {
       case CREATE: {
         Boolean hasData = params.get(DataParam.NAME, DataParam.class);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a58f8805/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt 
b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 1256550..cdf1462 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -69,6 +69,9 @@ Release 2.7.0 - UNRELEASED
 
     HDFS-7277. Remove explicit dependency on netty 3.2 in BKJournal. (wheat9)
 
+    HDFS-7232. Populate hostname in httpfs audit log (Zoran Dimitrijevic
+    via aw)
+
 Release 2.6.0 - UNRELEASED
 
   INCOMPATIBLE CHANGES

Reply via email to