tomscut commented on a change in pull request #3538:
URL: https://github.com/apache/hadoop/pull/3538#discussion_r731559954
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
##########
@@ -369,11 +369,22 @@ public static int getCallRetryCount() {
}
/** Returns the remote side ip address when invoked inside an RPC
- * Returns null incase of an error.
+ * Returns null in case of an error.
*/
public static InetAddress getRemoteIp() {
Call call = CurCall.get();
- return (call != null ) ? call.getHostInetAddress() : null;
+ return (call != null) ? call.getHostInetAddress() : null;
+ }
+
+ /**
+ * Returns the remote side port when invoked inside an RPC
+ * Returns an empty string in case of an error.
+ */
+ public static String getRemoteIpAndPort() {
+ Call call = CurCall.get();
+ return (call != null) ?
+ new StringBuffer().append(call.getHostInetAddress()).
+ append(":").append(call.getRemotePort()).toString() : "";
Review comment:
> StringBuffer is thread safe and that's why it is slower than
StringBuilder. Here I think using '+' is sufficient to concatenate strings
because '+' is translated to StringBuilder when compiled.
Thanks @aajisaka for your suggestion, I made some updates. PTAL. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]