kfaraz commented on code in PR #19709:
URL: https://github.com/apache/druid/pull/19709#discussion_r3619383305


##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java:
##########
@@ -506,6 +507,28 @@ public TaskStatus call()
     }
   }
 
+  private String getJavaCommand()
+  {
+    return getJavaCommand(config.getJavaCommand(), new File("."));
+  }
+
+  /**
+   * Resolves the command used to launch the peon JVM. When the operator has 
not overridden
+   * {@code druid.indexer.runner.javaCommand} (i.e. it is still the default 
{@code "java"}), and the bundled
+   * {@link #RUN_JAVA_COMMAND} script is present in {@code workingDir}, prefer 
it so that {@code DRUID_JAVA_HOME} /
+   * {@code JAVA_HOME} are honored. Otherwise fall back to the configured 
command (the plain {@code java} on the
+   * PATH by default). The existence check against {@code workingDir} is 
reliable because peons inherit this
+   * process's working directory.
+   */
+  public static String getJavaCommand(String configuredJavaCommand, File 
workingDir)
+  {
+    if 
(ForkingTaskRunnerConfig.DEFAULT_JAVA_COMMAND.equals(configuredJavaCommand)

Review Comment:
   One thing we could do is not assign any default in the config object, and do 
the following in this method:
   
   - if user has specified a command (i.e. if config.getJavaCommand is not 
null), use that.
   - if `bin/run-java` exists, use that
   - use `java`
   
   This way, the entire fallback logic exists in one place.



##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java:
##########
@@ -506,6 +507,28 @@ public TaskStatus call()
     }
   }
 
+  private String getJavaCommand()
+  {
+    return getJavaCommand(config.getJavaCommand(), new File("."));
+  }
+
+  /**
+   * Resolves the command used to launch the peon JVM. When the operator has 
not overridden
+   * {@code druid.indexer.runner.javaCommand} (i.e. it is still the default 
{@code "java"}), and the bundled
+   * {@link #RUN_JAVA_COMMAND} script is present in {@code workingDir}, prefer 
it so that {@code DRUID_JAVA_HOME} /
+   * {@code JAVA_HOME} are honored. Otherwise fall back to the configured 
command (the plain {@code java} on the
+   * PATH by default). The existence check against {@code workingDir} is 
reliable because peons inherit this
+   * process's working directory.
+   */
+  public static String getJavaCommand(String configuredJavaCommand, File 
workingDir)
+  {
+    if 
(ForkingTaskRunnerConfig.DEFAULT_JAVA_COMMAND.equals(configuredJavaCommand)

Review Comment:
   How can we distinguish between the case where the user has actually 
specified `java` as the command vs the default?



##########
docs/configuration/index.md:
##########
@@ -1315,7 +1315,7 @@ Middle Managers pass their configurations down to their 
child peons. The Middle
 |--------|-----------|-------|
 |`druid.indexer.runner.allowedPrefixes`|Whitelist of prefixes for configs that 
can be passed down to child peons.|`com.metamx`, `druid`, `org.apache.druid`, 
`user.timezone`, `file.encoding`, `java.io.tmpdir`, `hadoop`|
 |`druid.indexer.runner.classpath`|Java classpath for the 
peon.|`System.getProperty("java.class.path")`|
-|`druid.indexer.runner.javaCommand`|Command required to execute java.|java|
+|`druid.indexer.runner.javaCommand`| Command required to execute java. When 
left at the *default*, Druid uses the bundled `bin/run-java` script if it is 
present in the working directory (it honors the `DRUID_JAVA_HOME`/`JAVA_HOME` 
environment variables), otherwise it falls back to `java` on the `PATH`.        
                                                                                
                                                                                
                                                              |java|

Review Comment:
   ```suggestion
   |`druid.indexer.runner.javaCommand`| Command required to execute java. If 
not specified, Druid uses the bundled `bin/run-java` script if it is present in 
the working directory (it honors the `DRUID_JAVA_HOME`/`JAVA_HOME` environment 
variables), otherwise it falls back to `java` on the `PATH`.                    
                                                                                
                                                                                
                                                  |java|
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to