[ 
https://issues.apache.org/jira/browse/HDFS-15380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

tomscut updated HDFS-15380:
---------------------------
    Attachment:     (was: PATCH)

> Could not fetch real remote ip in RouterWebHdfsMethods.java
> -----------------------------------------------------------
>
>                 Key: HDFS-15380
>                 URL: https://issues.apache.org/jira/browse/HDFS-15380
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: webhdfs
>    Affects Versions: 3.1.0
>            Reporter: tomscut
>            Priority: Minor
>              Labels: router, webhdfs
>         Attachments: HDFS-15380.001.patch
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> We plan to add audit log for hdfs router, then we fetch remote ip via 
> Server.getRemoteIp(), but the result is "localhost/127.0.0.1".
>  
> "REMOTE_ADDRESS" in RouterWebHdfsMethods.java is a ThreadLocal field, setting 
> in construction method RouterWebHdfsMethods() and init(). When we call method 
> Server.getRemoteIp() to fetch remote ip, the thread would be changed, so the 
> ThreadLocal field "REMOTE_ADDRESS" is null, and would be passed to 
> "localhost/127.0.0.1" via InetAddress.getByName().
>  
> So we can change this field "REMOTE_ADDRESS" to a String value, just like 
> NamenodeWebHdfsMethods does.
>  
> {code:java}
> 2020-05-27 19:15:18,797 INFO  router.RouterWebHdfsMethods 
> (RouterWebHdfsMethods.java:<init>(138)) - RouterWebHdfsMethods 
> REMOTE_ADDRESS: 14.39.39.28, current thread: qtp476579021-10902020-05-27 
> 19:15:18,827 INFO  router.RouterWebHdfsMethods 
> (RouterWebHdfsMethods.java:init(150)) - init REMOTE_ADDRESS: 14.39.39.28, 
> current thread: qtp476579021-10902020-05-27 19:15:18,836 INFO  
> router.RouterWebHdfsMethods (RouterWebHdfsMethods.java:getRemoteAddr(170)) - 
> getRemoteAddr REMOTE_ADDRESS: null, current thread: IPC Server handler 75 on 
> 88882020-05-27 19:15:18,837 INFO  router.RouterWebHdfsMethods 
> (RouterWebHdfsMethods.java:getRemoteAddr(170)) - getRemoteAddr 
> REMOTE_ADDRESS: null, current thread: IPC Server handler 75 on 88882020-05-27 
> 19:15:18,883 INFO  router.RouterWebHdfsMethods 
> (RouterWebHdfsMethods.java:reset(164)) - reset REMOTE_ADDRESS: null, current 
> thread: IPC Server handler 75 on 8888
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to