Uploaded image for project: 'Apache Ozone'
  1. Apache Ozone
  2. HDDS-6796

Extract method for building OMRequest in TrashOzoneFileSystem

    XMLWordPrintableJSON

Details

    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

          Activity

            People

              wxiao Will Xiao
              sadanand_shenoy Sadanand Shenoy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: