Details
Description
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.
I printed thread name and the value of "REMOTE_ADDRESS" in log, the log is shown below:
2020-05-27 19:15:18,797 INFO router.RouterWebHdfsMethods (RouterWebHdfsMethods.java:<init>(138)) - RouterWebHdfsMethods REMOTE_ADDRESS: 14.39.39.28, current thread: qtp476579021-1090 2020-05-27 19:15:18,827 INFO router.RouterWebHdfsMethods (RouterWebHdfsMethods.java:init(150)) - init REMOTE_ADDRESS: 14.39.39.28, current thread: qtp476579021-1090 2020-05-27 19:15:18,836 INFO router.RouterWebHdfsMethods (RouterWebHdfsMethods.java:getRemoteAddr(170)) - getRemoteAddr REMOTE_ADDRESS: null, current thread: IPC Server handler 75 on 8888 2020-05-27 19:15:18,837 INFO router.RouterWebHdfsMethods (RouterWebHdfsMethods.java:getRemoteAddr(170)) - getRemoteAddr REMOTE_ADDRESS: null, current thread: IPC Server handler 75 on 8888 2020-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
Attachments
Attachments
Issue Links
- is related to
-
HDFS-12512 RBF: Add WebHDFS
- Resolved