@Test public void buildGraphReturnTest() { when(nodeInfo.getNodeType()).thenReturn("test"); EtlFlow etlFlow = new EtlFlow(Arrays.asList(nodeInfo), Collections.emptyList()); try { GraphAppUtil.buildGraph(loader, etlFlow); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals(e.getMessage(), "Unknown type: nodeInfo"); } }
public static <R> void buildGraph(final NodeLoader<R> loader, EtlFlow flow) { final Graph.GraphBuilder<NodeOperator<R>, Void> graphBuilder = Graph.builder(); final List<NodeInfo> nodes = flow.getNodes(); final List<EdgeInfo> edges = flow.getEdges(); nodes.forEach(nodeInfo -> { final Map<String, Object> config = nodeInfo.getUserConfig(); String driverString = nodeInfo.getDriverClass(); String id = nodeInfo.getNodeId(); switch (nodeInfo.getNodeType()) { case "source": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSource(driverString, config))); break; case "transform": graphBuilder.addNode(id, new NodeOperator<>(loader.loadTransform(driverString, config))); break; case "sink": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSink(driverString, config))); break; default: throw new IllegalArgumentException("Unknown type: " + nodeInfo); } }); edges.forEach(edgeInfo -> graphBuilder.addEdge( edgeInfo.getInNodeId().split("-")[0], edgeInfo.getOutNodeId().split("-")[0] )); Graph<NodeOperator<R>, Void> graph = graphBuilder.create(); graph.printShow().forEach(System.out::println); NodeOperator.runGraph(graph); }
GraphAppUtil { public static <R> void buildGraph(final NodeLoader<R> loader, EtlFlow flow) { final Graph.GraphBuilder<NodeOperator<R>, Void> graphBuilder = Graph.builder(); final List<NodeInfo> nodes = flow.getNodes(); final List<EdgeInfo> edges = flow.getEdges(); nodes.forEach(nodeInfo -> { final Map<String, Object> config = nodeInfo.getUserConfig(); String driverString = nodeInfo.getDriverClass(); String id = nodeInfo.getNodeId(); switch (nodeInfo.getNodeType()) { case "source": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSource(driverString, config))); break; case "transform": graphBuilder.addNode(id, new NodeOperator<>(loader.loadTransform(driverString, config))); break; case "sink": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSink(driverString, config))); break; default: throw new IllegalArgumentException("Unknown type: " + nodeInfo); } }); edges.forEach(edgeInfo -> graphBuilder.addEdge( edgeInfo.getInNodeId().split("-")[0], edgeInfo.getOutNodeId().split("-")[0] )); Graph<NodeOperator<R>, Void> graph = graphBuilder.create(); graph.printShow().forEach(System.out::println); NodeOperator.runGraph(graph); } }
GraphAppUtil { public static <R> void buildGraph(final NodeLoader<R> loader, EtlFlow flow) { final Graph.GraphBuilder<NodeOperator<R>, Void> graphBuilder = Graph.builder(); final List<NodeInfo> nodes = flow.getNodes(); final List<EdgeInfo> edges = flow.getEdges(); nodes.forEach(nodeInfo -> { final Map<String, Object> config = nodeInfo.getUserConfig(); String driverString = nodeInfo.getDriverClass(); String id = nodeInfo.getNodeId(); switch (nodeInfo.getNodeType()) { case "source": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSource(driverString, config))); break; case "transform": graphBuilder.addNode(id, new NodeOperator<>(loader.loadTransform(driverString, config))); break; case "sink": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSink(driverString, config))); break; default: throw new IllegalArgumentException("Unknown type: " + nodeInfo); } }); edges.forEach(edgeInfo -> graphBuilder.addEdge( edgeInfo.getInNodeId().split("-")[0], edgeInfo.getOutNodeId().split("-")[0] )); Graph<NodeOperator<R>, Void> graph = graphBuilder.create(); graph.printShow().forEach(System.out::println); NodeOperator.runGraph(graph); } private  GraphAppUtil(); }
GraphAppUtil { public static <R> void buildGraph(final NodeLoader<R> loader, EtlFlow flow) { final Graph.GraphBuilder<NodeOperator<R>, Void> graphBuilder = Graph.builder(); final List<NodeInfo> nodes = flow.getNodes(); final List<EdgeInfo> edges = flow.getEdges(); nodes.forEach(nodeInfo -> { final Map<String, Object> config = nodeInfo.getUserConfig(); String driverString = nodeInfo.getDriverClass(); String id = nodeInfo.getNodeId(); switch (nodeInfo.getNodeType()) { case "source": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSource(driverString, config))); break; case "transform": graphBuilder.addNode(id, new NodeOperator<>(loader.loadTransform(driverString, config))); break; case "sink": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSink(driverString, config))); break; default: throw new IllegalArgumentException("Unknown type: " + nodeInfo); } }); edges.forEach(edgeInfo -> graphBuilder.addEdge( edgeInfo.getInNodeId().split("-")[0], edgeInfo.getOutNodeId().split("-")[0] )); Graph<NodeOperator<R>, Void> graph = graphBuilder.create(); graph.printShow().forEach(System.out::println); NodeOperator.runGraph(graph); } private  GraphAppUtil(); static void buildGraph(final NodeLoader<R> loader, EtlFlow flow); }
GraphAppUtil { public static <R> void buildGraph(final NodeLoader<R> loader, EtlFlow flow) { final Graph.GraphBuilder<NodeOperator<R>, Void> graphBuilder = Graph.builder(); final List<NodeInfo> nodes = flow.getNodes(); final List<EdgeInfo> edges = flow.getEdges(); nodes.forEach(nodeInfo -> { final Map<String, Object> config = nodeInfo.getUserConfig(); String driverString = nodeInfo.getDriverClass(); String id = nodeInfo.getNodeId(); switch (nodeInfo.getNodeType()) { case "source": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSource(driverString, config))); break; case "transform": graphBuilder.addNode(id, new NodeOperator<>(loader.loadTransform(driverString, config))); break; case "sink": graphBuilder.addNode(id, new NodeOperator<>(loader.loadSink(driverString, config))); break; default: throw new IllegalArgumentException("Unknown type: " + nodeInfo); } }); edges.forEach(edgeInfo -> graphBuilder.addEdge( edgeInfo.getInNodeId().split("-")[0], edgeInfo.getOutNodeId().split("-")[0] )); Graph<NodeOperator<R>, Void> graph = graphBuilder.create(); graph.printShow().forEach(System.out::println); NodeOperator.runGraph(graph); } private  GraphAppUtil(); static void buildGraph(final NodeLoader<R> loader, EtlFlow flow);  }