anuengineer commented on a change in pull request #110: HDDS-2321. Ozone Block Token verify should not apply to all datanode … URL: https://github.com/apache/hadoop-ozone/pull/110#discussion_r341825562
########## File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java ########## @@ -390,6 +391,52 @@ public static boolean isReadOnly( } } + /** + * Not all datanode container cmd protocol has embedded ozone block token. + * Block token are issued by Ozone Manager and return to Ozone client to + * read/write data on datanode via input/output stream. + * Ozone datanode uses this helper to decide which command requires block + * token. + * @param cmdType + * @return true if it is a cmd that block token should be checked when + * security is enabled + * false if block token does not apply to the command. + * + */ + public static boolean requireOmBlockToken( + ContainerProtos.Type cmdType) { + switch (cmdType) { + case ReadChunk: + case GetBlock: + case WriteChunk: + case PutBlock: + return true; + default: + return false; + } + } + + /** + * Return the block ID of container commands that are related to blocks. + * @param msg container command + * @return block ID. + */ + public static BlockID getBlockID(ContainerProtos.ContainerCommandRequestProto msg) { + switch (msg.getCmdType()) { + case ReadChunk: Review comment: While you are absolutely right in assuming that if we set the command type to something the corresponding object must be valid, in the proto file, these are all optional. So check if (msg.hasReadchunk()) before the block ID call. ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-dev-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org