HDFS-15380. RBF: Could not fetch real remote IP in RouterWebHdfsMethods. Contributed by tomscut.
(cherry picked from commit 5ab1db9e21
)
This commit is contained in:
parent
580634882e
commit
e4217be749
|
@ -115,20 +115,18 @@ public class RouterWebHdfsMethods extends NamenodeWebHdfsMethods {
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
LoggerFactory.getLogger(RouterWebHdfsMethods.class);
|
LoggerFactory.getLogger(RouterWebHdfsMethods.class);
|
||||||
|
|
||||||
private static final ThreadLocal<String> REMOTE_ADDRESS =
|
|
||||||
new ThreadLocal<String>();
|
|
||||||
|
|
||||||
private @Context HttpServletRequest request;
|
private @Context HttpServletRequest request;
|
||||||
private String method;
|
private String method;
|
||||||
private String query;
|
private String query;
|
||||||
private String reqPath;
|
private String reqPath;
|
||||||
|
private String remoteAddr;
|
||||||
|
|
||||||
public RouterWebHdfsMethods(@Context HttpServletRequest request) {
|
public RouterWebHdfsMethods(@Context HttpServletRequest request) {
|
||||||
super(request);
|
super(request);
|
||||||
this.method = request.getMethod();
|
this.method = request.getMethod();
|
||||||
this.query = request.getQueryString();
|
this.query = request.getQueryString();
|
||||||
this.reqPath = request.getServletPath();
|
this.reqPath = request.getServletPath();
|
||||||
REMOTE_ADDRESS.set(JspHelper.getRemoteAddr(request));
|
this.remoteAddr = JspHelper.getRemoteAddr(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -139,7 +137,7 @@ public class RouterWebHdfsMethods extends NamenodeWebHdfsMethods {
|
||||||
final Param<?, ?>... parameters) {
|
final Param<?, ?>... parameters) {
|
||||||
super.init(ugi, delegation, username, doAsUser, path, op, parameters);
|
super.init(ugi, delegation, username, doAsUser, path, op, parameters);
|
||||||
|
|
||||||
REMOTE_ADDRESS.set(JspHelper.getRemoteAddr(request));
|
remoteAddr = JspHelper.getRemoteAddr(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -153,12 +151,12 @@ public class RouterWebHdfsMethods extends NamenodeWebHdfsMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reset() {
|
private void reset() {
|
||||||
REMOTE_ADDRESS.set(null);
|
remoteAddr = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getRemoteAddr() {
|
protected String getRemoteAddr() {
|
||||||
return REMOTE_ADDRESS.get();
|
return remoteAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue