42 lines
No EOL
1.5 KiB
Java
42 lines
No EOL
1.5 KiB
Java
package com.databuild.examples.basic_graph;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
import java.io.File;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
|
|
/**
|
|
* Configure class for generating a random number.
|
|
* This class creates a job configuration for generating a random number based on the partition ref.
|
|
*/
|
|
public class GenerateConfigure {
|
|
public static void main(String[] args) {
|
|
if (args.length < 1) {
|
|
System.err.println("Error: Partition ref is required");
|
|
System.exit(1);
|
|
}
|
|
|
|
// Process each partition ref from input arguments
|
|
Arrays.stream(args).forEach(partitionRef -> {
|
|
// Create and populate JobConfig object
|
|
JobConfig config = new JobConfig();
|
|
config.outputs = Collections.singletonList(partitionRef);
|
|
config.args = Arrays.asList(partitionRef);
|
|
// inputs and env are already initialized as empty collections in the constructor
|
|
|
|
try {
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
// Convert config to JsonNode and serialize
|
|
JsonNode configNode = mapper.valueToTree(config);
|
|
String jsonConfig = mapper.writeValueAsString(configNode);
|
|
System.out.println(jsonConfig);
|
|
} catch (Exception e) {
|
|
System.err.println("Error: Failed to validate or serialize config: " + e.getMessage());
|
|
System.exit(1);
|
|
}
|
|
});
|
|
}
|
|
} |