[ 
https://issues.apache.org/jira/browse/HADOOP-17276?focusedWorklogId=491504&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-491504
 ]

ASF GitHub Bot logged work on HADOOP-17276:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Sep/20 02:04
            Start Date: 26/Sep/20 02:04
    Worklog Time Spent: 10m 
      Work Description: liuml07 commented on a change in pull request #2327:
URL: https://github.com/apache/hadoop/pull/2327#discussion_r495375367



##########
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 {

Review comment:
       I am not sure we need to implement the `Configurable` to make this 
flexible. How about:
   1. Add a new final `separator` field
   1. Add a new final `StringBuilder sb = new StringBuilder();` field and 
remove `context` variable
   1. Existing constructor `public Builder(String context)` will simply 
call`sb.append(context)` and assign `separator` field with default value `,` 
aka `HADOOP_CALLER_CONTEXT_ITEM_SEPARATOR_DEFAULT`
   1. Create a new constructor `public Builder(Configuration conf)` which 
initializes the `separator` with the config, do not save the `conf` since we do 
not need it
   1. Add a new method `public append(String key, String value)` which calls 
`sb.append(key).append(separator).append(value)`
   1. Replace all places using `builder.context` with `builder.sb.toString()`, 
especially in `CallerContext(Builder b)` constructor.
   
   This seems very straightforward without losing configurability:
   1. it will not allow user to mix different separator when appending multiple 
key/values since it's final either from the default `,` or from Configuration
   1. no need to create a new string builder every time calling `append(key, 
value)`
   1. user does not need to call `builder.setConf(conf)`
   1. we do not  save `conf` by implementing `Configurable` interface so this 
builder lightweight
   
   Thoughts?
   




----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 491504)
    Time Spent: 2h 50m  (was: 2h 40m)

> 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: Hui Fei
>            Assignee: Hui Fei
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2h 50m
>  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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to