[ 
https://issues.apache.org/jira/browse/HDDS-6796?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Attila Doroszlai updated HDDS-6796:
-----------------------------------
    Labels: GoodForNewContributors good-first-issue  (was: newbie)

> Refactor TrashOzoneFilesystem client requests.
> ----------------------------------------------
>
>                 Key: HDDS-6796
>                 URL: https://issues.apache.org/jira/browse/HDDS-6796
>             Project: Apache Ozone
>          Issue Type: Improvement
>          Components: OM
>            Reporter: Sadanand Shenoy
>            Priority: Major
>              Labels: GoodForNewContributors, good-first-issue
>
> TrashOzoneFileSystem has 3 pieces of similar code where it builds OMRequest:
> {code:title=https://github.com/apache/ozone/blob/82d27595958f70a7468a38899bf48b2208bebe64/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java#L486-L492}
>       omRequest = OzoneManagerProtocolProtos.OMRequest.newBuilder()
>               .setClientId(CLIENT_ID.toString())
>               .setVersion(ClientVersion.CURRENT_VERSION)
>               .setUserInfo(getUserInfo())
>               .setRenameKeyRequest(renameKeyRequest)
>               .setCmdType(OzoneManagerProtocolProtos.Type.RenameKey)
>               .build();
> {code}
> {code:title=https://github.com/apache/ozone/blob/82d27595958f70a7468a38899bf48b2208bebe64/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java#L552-L559}
>       omRequest =
>           OzoneManagerProtocolProtos.OMRequest.newBuilder()
>               .setClientId(CLIENT_ID.toString())
>               .setVersion(ClientVersion.CURRENT_VERSION)
>               .setUserInfo(getUserInfo())
>               .setDeleteKeyRequest(deleteKeyRequest)
>               .setCmdType(OzoneManagerProtocolProtos.Type.DeleteKey)
>               .build();
> {code}
> {code:title=https://github.com/apache/ozone/blob/82d27595958f70a7468a38899bf48b2208bebe64/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java#L622-L628}
>         omRequest = OzoneManagerProtocolProtos.OMRequest.newBuilder()
>             .setClientId(CLIENT_ID.toString())
>             .setVersion(ClientVersion.CURRENT_VERSION)
>             .setUserInfo(getUserInfo())
>             .setDeleteKeysRequest(deleteKeysRequest)
>             .setCmdType(OzoneManagerProtocolProtos.Type.DeleteKeys)
>             .build();
> {code}
> The goal of this task is to
>  * create a new method that creates a new {{OMRequest.Builder}}, and returns 
> it after setting the properties that are the same in all 3 snippets
>  * use this new method to replace the duplicated part of the code
> Example for the same pattern elsewhere:
> {code:title=https://github.com/apache/ozone/blob/82d27595958f70a7468a38899bf48b2208bebe64/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java#L288-L293}
>   private OMRequest.Builder createOMRequest(Type cmdType) {
>     return OMRequest.newBuilder()
>         .setCmdType(cmdType)
>         .setVersion(ClientVersion.CURRENT_VERSION)
>         .setClientId(clientID);
>   }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to