rohangarg commented on a change in pull request #12326:
URL: https://github.com/apache/druid/pull/12326#discussion_r833159834



##########
File path: 
indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java
##########
@@ -219,6 +220,23 @@ public TaskStatus call()
                           );
                         }
 
+                        // Override task specific javaOptsArray
+                        try {
+                          List<String> taskJavaOptsArray = 
jsonMapper.convertValue(
+                              
task.getContextValue(ForkingTaskRunnerConfig.JAVA_OPTS_ARRAY_PROPERTY),
+                              new TypeReference<List<String>>() {}
+                          );
+                          if (taskJavaOptsArray != null) {
+                            Iterables.addAll(command, taskJavaOptsArray);
+                          }
+                        }
+                        catch (Exception e) {
+                          throw new IllegalArgumentException(
+                              "javaOptsArray in context of task: " + 
task.getId() + " must be an array of strings.",

Review comment:
       should be `ForkingTaskRunnerConfig.JAVA_OPTS_ARRAY_PROPERTY` value 
instead of `javaOptsArray` - also no need to add the exception we got while 
parsing. 

##########
File path: 
indexing-service/src/test/java/org/apache/druid/indexing/overlord/ForkingTaskRunnerTest.java
##########
@@ -353,4 +353,77 @@ int waitForTaskProcessToComplete(Task task, ProcessHolder 
processHolder, File lo
     Assert.assertEquals(TaskState.FAILED, status.getStatusCode());
     Assert.assertEquals("task failure test", status.getErrorMsg());
   }
+
+  @Test
+  public void testJavaOptsAndJavaOptsArrayOverride() throws 
ExecutionException, InterruptedException
+  {
+    ObjectMapper mapper = new DefaultObjectMapper();
+    String javaOpts = "-Xmx1g -Xms1g";
+    List<String> javaOptsArray = ImmutableList.of("-Xmx10g", "-Xms10g");
+    Task task = NoopTask.create().withJavaOptsContext(javaOpts, javaOptsArray);

Review comment:
       suggestion(nit) : we can create this via `mapper.readValue(jsonString, 
NoopTask.class)` with jsonString containing the contructor params + context 
values as strings and string-arrays. that would emulate an user input more 
closely




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