vinayakumarb commented on a change in pull request #1803: HADOOP-16621. 
[pb-upgrade] Remove Protobuf classes from signatures of Public APIs.
URL: https://github.com/apache/hadoop/pull/1803#discussion_r365758096
 
 

 ##########
 File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufHelper.java
 ##########
 @@ -46,4 +52,67 @@ public static IOException 
getRemoteException(ServiceException se) {
     }
     return e instanceof IOException ? (IOException) e : new IOException(se);
   }
+
+
+  /**
+   * Map used to cache fixed strings to ByteStrings. Since there is no
+   * automatic expiration policy, only use this for strings from a fixed, small
+   * set.
+   * <p/>
+   * This map should not be accessed directly. Used the getFixedByteString
+   * methods instead.
+   */
+  private static ConcurrentHashMap<Object, ByteString> fixedByteStringCache =
+      new ConcurrentHashMap<>();
+
+  /**
+   * Get the ByteString for frequently used fixed and small set strings.
+   * @param key string
+   * @return
+   */
+  public static ByteString getFixedByteString(Text key) {
 
 Review comment:
   This is for frequently converting the fixed strings, such as 'token kind' 
and 'token service' in client side. These numbers will be fixed. ex: 
HDFS_DELEGATION_TOKEN, HDFS_BLOCK_TOKEN, etc.
   For the other bytestrings (such as datanode network location) guava cache is 
used in PBHelperClient with expiry.
   So it should be fine.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to