rmatharu commented on a change in pull request #1402:
URL: https://github.com/apache/samza/pull/1402#discussion_r458450559



##########
File path: samza-core/src/main/java/org/apache/samza/util/Util.java
##########
@@ -123,4 +131,85 @@ private static InetAddress doGetLocalHost() throws 
UnknownHostException, SocketE
     }
     return localHost;
   }
+
+  public static String getDeploymentType(Config config) {
+    JobConfig jobConfig = new JobConfig(config);
+    Optional<String> streamJobFactoryClass = 
jobConfig.getStreamJobFactoryClass();
+    if (streamJobFactoryClass.isPresent()) {
+      if (streamJobFactoryClass.get().equals(YARN_JOB_FACTORY_CLASS)) {
+        return DeploymentType.YARN.name();
+      } else {
+        return DeploymentType.STANDALONE.name();
+      }
+    }
+    return "NOT_DEFINED";
+  }
+
+  public static String getApiType(Config config) {
+    ApplicationConfig appConfig = new ApplicationConfig(config);
+    String appClass = appConfig.getAppClass();
+    if (appClass == null || appClass.isEmpty()) {
+      return ApiType.SAMZA_LOW_LEVEL.name();
+    }
+    if (appClass.equals(BEAM_RUNNER_CLASS)) {
+      return ApiType.SAMZA_BEAM.name();
+    }
+    if (appClass.equals(SQL_RUNNER_CLASS)) {
+      return ApiType.SAMZA_SQL.name();
+    }
+    if (appClass.getClass().isInstance(StreamApplication.class)) {
+      return ApiType.SAMZA_HIGH_LEVEL.name();
+    }
+    return ApiType.SAMZA_LOW_LEVEL.name();
+  }
+
+  public static int getContainerCount(Config config) {
+    JobConfig jobConfig = new JobConfig(config);
+    return jobConfig.getContainerCount();
+  }
+

Review comment:
       Why even have it as a util?
   Could the caller not cast the "config" object into JobConfig, TaskConfig and 
ClusterManagerConfig once and invoke the respective function, rather than do a 
cast in each separate util. 
   
   Same for getContainerMemoryMb, getNumCores, getThreadPoolSize, 
getSspGrouperFactory, getHostAffinityEnabled, getContainerRetryCount, 
getContainerRetryWindowMs, getMaxConcurrency. 
   Then none of these "util" methods need to be there.




----------------------------------------------------------------
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]


Reply via email to