[ https://issues.apache.org/jira/browse/HADOOP-17276?focusedWorklogId=490036&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-490036 ]
ASF GitHub Bot logged work on HADOOP-17276: ------------------------------------------- Author: ASF GitHub Bot Created on: 24/Sep/20 07:59 Start Date: 24/Sep/20 07:59 Worklog Time Spent: 10m Work Description: ferhui commented on a change in pull request #2327: URL: https://github.com/apache/hadoop/pull/2327#discussion_r494114383 ########## 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: Now there isn't. Want to use append in RBF, for example, add callerip to context, append("CallerIp", "x.x.x.x", ":"). If this method is useless, we can remove it. ---------------------------------------------------------------- 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 Issue Time Tracking ------------------- Worklog Id: (was: 490036) Time Spent: 2h (was: 1h 50m) > Extend CallerContext to make it include many items > -------------------------------------------------- > > Key: HADOOP-17276 > URL: https://issues.apache.org/jira/browse/HADOOP-17276 > Project: Hadoop Common > Issue Type: Improvement > Reporter: Fei Hui > Assignee: Fei Hui > Priority: Major > Labels: pull-request-available > Time Spent: 2h > Remaining Estimate: 0h > > Now context is string. We need to extend the CallerContext because context > may contains many items. > Items include > * router ip > * MR or CLI > * etc -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org