use of org.apache.hudi.integ.testsuite.dag.nodes.DagNode in project hudi by apache.
the class DagUtils method convertDagToYaml.
private static void convertDagToYaml(JsonNode yamlNode, List<DagNode> dagNodes) throws IOException {
for (DagNode dagNode : dagNodes) {
String name = dagNode.getConfig().getOtherConfigs().getOrDefault(DeltaConfig.Config.NODE_NAME, dagNode.getName()).toString();
((ObjectNode) yamlNode).put(name, convertDagNodeToJsonNode(dagNode));
if (dagNode.getChildNodes().size() > 0) {
convertDagToYaml(yamlNode, dagNode.getChildNodes());
}
}
}
use of org.apache.hudi.integ.testsuite.dag.nodes.DagNode in project hudi by apache.
the class DagUtils method convertYamlToDag.
/**
* Converts a YAML representation to {@link WorkflowDag}.
*/
public static WorkflowDag convertYamlToDag(String yaml) throws IOException {
int dagRounds = DEFAULT_DAG_ROUNDS;
int intermittentDelayMins = DEFAULT_INTERMITTENT_DELAY_MINS;
String dagName = DEFAULT_DAG_NAME;
Map<String, DagNode> allNodes = new HashMap<>();
final ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
final JsonNode jsonNode = yamlReader.readTree(yaml);
Iterator<Entry<String, JsonNode>> itr = jsonNode.fields();
while (itr.hasNext()) {
Entry<String, JsonNode> dagNode = itr.next();
String key = dagNode.getKey();
switch(key) {
case DAG_NAME:
dagName = dagNode.getValue().asText();
break;
case DAG_ROUNDS:
dagRounds = dagNode.getValue().asInt();
break;
case DAG_INTERMITTENT_DELAY_MINS:
intermittentDelayMins = dagNode.getValue().asInt();
break;
case DAG_CONTENT:
JsonNode dagContent = dagNode.getValue();
Iterator<Entry<String, JsonNode>> contentItr = dagContent.fields();
while (contentItr.hasNext()) {
Entry<String, JsonNode> dagContentNode = contentItr.next();
allNodes.put(dagContentNode.getKey(), convertJsonToDagNode(allNodes, dagContentNode.getKey(), dagContentNode.getValue()));
}
break;
default:
break;
}
}
return new WorkflowDag(dagName, dagRounds, intermittentDelayMins, findRootNodes(allNodes));
}
Aggregations