cameronlee314 commented on a change in pull request #1266: Adding internal 
autosizing related configs
URL: https://github.com/apache/samza/pull/1266#discussion_r374858822
 
 

 ##########
 File path: samza-core/src/main/java/org/apache/samza/config/JobConfig.java
 ##########
 @@ -310,6 +339,23 @@ public boolean getDiagnosticsEnabled() {
     return getBoolean(JOB_DIAGNOSTICS_ENABLED, false);
   }
 
+  public boolean getAutosizingEnabled() {
+    return getBoolean(JOB_AUTOSIZING_ENABLED, false);
+  }
+
+  public boolean isAutosizingConfig(String configParam) {
+    switch (configParam) {
+      case JOB_AUTOSIZING_CONTAINER_COUNT:
+      case JOB_AUTOSIZING_CONTAINER_MAX_CORES:
+      case JOB_AUTOSIZING_CONTAINER_MAX_HEAP_MB:
+      case JOB_AUTOSIZING_CONTAINER_MEMORY_MB:
+      case JOB_AUTOSIZING_CONTAINER_THREAD_POOL_SIZE:
 
 Review comment:
   If someone adds a new autosizing config, then it might not be obvious to 
remember to update this method, especially since it is a couple hundred lines 
away from the config key declaration.
   Here are a couple suggestions that might help:
   1. Create a new enum class in which each autosizing config is a value in the 
enum. Then, you could use `Enum.values()` to create a set of autosizing 
configs. This is nice, because someone only needs to add the enum value, and 
then the code automatically picks it up.
   2. Create a static `Set` of autosizing keys, and then declare that set as a 
static variable right next to where you declare the autosizing constants. There 
is still a chance of forgetting to update the set, but it's at least close in 
proximity to the declarations.
   3. Change the implementation of this method to check that the config key 
matches a prefix (e.g. `job.autosizing`). It's "convention"-y, but then no one 
will need to update this implementation as long as they follow the prefix 
pattern.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to