aajisaka commented on a change in pull request #2327: URL: https://github.com/apache/hadoop/pull/2327#discussion_r494108913
########## File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/CallerContext.java ########## @@ -108,24 +117,86 @@ public String toString() { } /** The caller context builder. */ - public static final class Builder { - private final String context; + public static final class Builder implements Configurable { + private String context; private byte[] signature; + private Configuration conf = new Configuration(); public Builder(String context) { this.context = context; } + public Builder(String key, String value, String kvSeparator) { + this.context = new StringBuilder(key) + .append(kvSeparator) + .append(value) + .toString(); + } + public Builder setSignature(byte[] signature) { if (signature != null && signature.length > 0) { this.signature = Arrays.copyOf(signature, signature.length); } return this; } + /** + * Append new item to the context. + * @param item + * @return builder + */ + public Builder append(String item) { + if (CallerContext.isContextValid(context)) { + this.context = new StringBuilder(context) + .append(conf.get(HADOOP_CALLER_CONTEXT_ITEM_SEPARATOR_KEY, + HADOOP_CALLER_CONTEXT_ITEM_SEPARATOR_DEFAULT)) + .append(item) + .toString(); + } else { + this.context = item; + } + return this; + } + + /** + * Append new item which contains key and value to the context. + * @param key + * @param value + * @param kvSeparator + * @return builder + */ + public Builder append(String key, String value, String kvSeparator) { Review comment: Thank you @ferhui for providing the patch. Are there any use cases for this method instead of calling `append(key + kvSeparator + value)` directly? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org