Uploaded image for project: 'Samza'
  1. Samza
  2. SAMZA-1160

Migrate MapConfig inherited Java classes to use composition over inheritance

    XMLWordPrintableJSON

    Details

    • Type: Task
    • Status: In Progress
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 0.15.0
    • Component/s: None
    • Labels:
      None

      Description

      In Samza code, we have a lot of classes with the name "*Config" which inherits from MapConfig but only intending to exposing the APIs for the specific configuration.

      For example, JavaStorageConfig, it currently extends MapConfig, but it only intends to manage/fetch storeNames and store related configs, but not other configs. With the inheritance, it does not have good encapsulation and it allows the object JavaStorageConfig to call any public API from MapConfig as well, for example, javaStorageConfig.get("yarn.resources.package.path"). With it, it mixes up the business logic for different types of Config.

      A proposal for addressing this is to do composition over inheritance, each type of Config, for example, JavaStorageConfig can have a member variable config which can leverage the interface of Config class (or the implementation of MapConfig) but not exposing the APIs of Config further down.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fredji Fred Ji
                Reporter:
                fredji Fred Ji
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: