Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Implemented
-
None
Description
TrashOzoneFileSystem has 3 pieces of similar code where it builds OMRequest:
omRequest = OzoneManagerProtocolProtos.OMRequest.newBuilder() .setClientId(CLIENT_ID.toString()) .setVersion(ClientVersion.CURRENT_VERSION) .setUserInfo(getUserInfo()) .setRenameKeyRequest(renameKeyRequest) .setCmdType(OzoneManagerProtocolProtos.Type.RenameKey) .build();
omRequest = OzoneManagerProtocolProtos.OMRequest.newBuilder() .setClientId(CLIENT_ID.toString()) .setVersion(ClientVersion.CURRENT_VERSION) .setUserInfo(getUserInfo()) .setDeleteKeyRequest(deleteKeyRequest) .setCmdType(OzoneManagerProtocolProtos.Type.DeleteKey) .build();
omRequest = OzoneManagerProtocolProtos.OMRequest.newBuilder() .setClientId(CLIENT_ID.toString()) .setVersion(ClientVersion.CURRENT_VERSION) .setUserInfo(getUserInfo()) .setDeleteKeysRequest(deleteKeysRequest) .setCmdType(OzoneManagerProtocolProtos.Type.DeleteKeys) .build();
The goal of this task is to
- create a new method that returns a new OMRequest.Builder 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:
private OMRequest.Builder createOMRequest(Type cmdType) { return OMRequest.newBuilder() .setCmdType(cmdType) .setVersion(ClientVersion.CURRENT_VERSION) .setClientId(clientID); }
Attachments
Issue Links
- links to