bvolpato commented on code in PR #27841:
URL: https://github.com/apache/beam/pull/27841#discussion_r1287151799


##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnHarness.java:
##########
@@ -117,11 +123,29 @@ public static void main(Function<String, String> 
environmentVarGetter) throws Ex
         "Control location %s%n", 
environmentVarGetter.apply(CONTROL_API_SERVICE_DESCRIPTOR));
     System.out.format(
         "Status location %s%n", 
environmentVarGetter.apply(STATUS_API_SERVICE_DESCRIPTOR));
-    System.out.format("Pipeline options %s%n", 
environmentVarGetter.apply(PIPELINE_OPTIONS));
-
     String id = environmentVarGetter.apply(HARNESS_ID);
-    PipelineOptions options =
-        
PipelineOptionsTranslation.fromJson(environmentVarGetter.apply(PIPELINE_OPTIONS));
+
+    String pipelineOptionsJson = environmentVarGetter.apply(PIPELINE_OPTIONS);
+    // Try looking for a file first. If that exists it should override 
PIPELINE_OPTIONS to avoid
+    // maxing out the kernel's environment space
+    try {
+      String pipelineOptionsPath = 
environmentVarGetter.apply(PIPELINE_OPTIONS_FILE);
+      System.out.format("Pipeline Options File %s%n", pipelineOptionsPath);
+      if (pipelineOptionsPath != null) {
+        Path filePath = Paths.get(pipelineOptionsPath);
+        if (Files.exists(filePath)) {
+          System.out.format(
+              "Pipeline Options File %s exists. Overriding existing 
options.%n",
+              pipelineOptionsPath);
+          pipelineOptionsJson = new String(Files.readAllBytes(filePath), 
StandardCharsets.UTF_8);
+        }
+      }
+    } catch (Exception e) {
+      System.out.format("Problem loading pipeline options from file: %s%n", 
e.getMessage());
+    }
+
+    System.out.format("Pipeline options %s%n", pipelineOptionsJson);

Review Comment:
   Intentionally not using logger? 



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

Reply via email to