|
@@ -132,6 +132,7 @@ public class RouterRpcClient {
|
|
|
Pattern.compile("\\tat (.*)\\.(.*)\\((.*):(\\d*)\\)");
|
|
|
|
|
|
private static final String CLIENT_IP_STR = "clientIp";
|
|
|
+ private static final String CLIENT_PORT_STR = "clientPort";
|
|
|
|
|
|
/** Fairness manager to control handlers assigned per NS. */
|
|
|
private RouterRpcFairnessPolicyController routerRpcFairnessPolicyController;
|
|
@@ -465,7 +466,7 @@ public class RouterRpcClient {
|
|
|
+ router.getRouterId());
|
|
|
}
|
|
|
|
|
|
- appendClientIpToCallerContextIfAbsent();
|
|
|
+ appendClientIpPortToCallerContextIfAbsent();
|
|
|
|
|
|
Object ret = null;
|
|
|
if (rpcMonitor != null) {
|
|
@@ -586,25 +587,20 @@ public class RouterRpcClient {
|
|
|
|
|
|
/**
|
|
|
* For tracking which is the actual client address.
|
|
|
- * It adds trace info "clientIp:ip" to caller context if it's absent.
|
|
|
+ * It adds trace info "clientIp:ip" and "clientPort:port"
|
|
|
+ * to caller context if they are absent.
|
|
|
*/
|
|
|
- private void appendClientIpToCallerContextIfAbsent() {
|
|
|
- String clientIpInfo = CLIENT_IP_STR + ":" + Server.getRemoteAddress();
|
|
|
- final CallerContext ctx = CallerContext.getCurrent();
|
|
|
- if (isClientIpInfoAbsent(clientIpInfo, ctx)) {
|
|
|
- String origContext = ctx == null ? null : ctx.getContext();
|
|
|
- byte[] origSignature = ctx == null ? null : ctx.getSignature();
|
|
|
- CallerContext.setCurrent(
|
|
|
- new CallerContext.Builder(origContext, contextFieldSeparator)
|
|
|
- .append(clientIpInfo)
|
|
|
- .setSignature(origSignature)
|
|
|
- .build());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private boolean isClientIpInfoAbsent(String clientIpInfo, CallerContext ctx){
|
|
|
- return ctx == null || ctx.getContext() == null
|
|
|
- || !ctx.getContext().contains(clientIpInfo);
|
|
|
+ private void appendClientIpPortToCallerContextIfAbsent() {
|
|
|
+ CallerContext ctx = CallerContext.getCurrent();
|
|
|
+ String origContext = ctx == null ? null : ctx.getContext();
|
|
|
+ byte[] origSignature = ctx == null ? null : ctx.getSignature();
|
|
|
+ CallerContext.setCurrent(
|
|
|
+ new CallerContext.Builder(origContext, contextFieldSeparator)
|
|
|
+ .appendIfAbsent(CLIENT_IP_STR, Server.getRemoteAddress())
|
|
|
+ .appendIfAbsent(CLIENT_PORT_STR,
|
|
|
+ Integer.toString(Server.getRemotePort()))
|
|
|
+ .setSignature(origSignature)
|
|
|
+ .build());
|
|
|
}
|
|
|
|
|
|
/**
|