use of org.apache.gobblin.service.modules.flow.LoadBasedFlowEdgeImpl in project incubator-gobblin by apache.
the class MultiHopsFlowToJobSpecCompilerTest method testServicePolicy.
@Test
public void testServicePolicy() {
// Initialize compiler with some blacklist properties
Properties properties = new Properties();
properties.setProperty(ServiceConfigKeys.TEMPLATE_CATALOGS_FULLY_QUALIFIED_PATH_KEY, TEST_TEMPLATE_CATALOG_URI);
String testPath = TEST_SOURCE_NAME + "," + TEST_HOP_NAME_A + "," + TEST_HOP_NAME_B + "," + TEST_SINK_NAME;
properties.setProperty(ServiceConfigKeys.POLICY_BASED_DATA_MOVEMENT_PATH, testPath);
properties.setProperty(ServiceConfigKeys.POLICY_BASED_BLOCKED_NODES, "testHopA");
MultiHopsFlowToJobSpecCompiler compiler = new MultiHopsFlowToJobSpecCompiler(ConfigUtils.propertiesToConfig(properties));
FlowSpec flowSpec = initFlowSpec();
TopologySpec topologySpec = initTopologySpec(TOPOLOGY_SPEC_STORE_DIR, TEST_SOURCE_NAME, TEST_HOP_NAME_A, TEST_HOP_NAME_B, TEST_SINK_NAME);
compiler.onAddSpec(topologySpec);
// invocation of compileFlow trigger the weighedGraph construction
compiler.compileFlow(flowSpec);
compiler.servicePolicy.populateBlackListedEdges(compiler.getWeightedGraph());
Assert.assertEquals(compiler.servicePolicy.getBlacklistedEdges().size(), 2);
FlowEdge edgeSrc2A = new LoadBasedFlowEdgeImpl(vertexSource, vertexHopA, topologySpec.getSpecExecutor());
FlowEdge edgeA2B = new LoadBasedFlowEdgeImpl(vertexHopA, vertexHopB, topologySpec.getSpecExecutor());
Assert.assertTrue(compiler.servicePolicy.getBlacklistedEdges().contains(edgeSrc2A));
Assert.assertTrue(compiler.servicePolicy.getBlacklistedEdges().contains(edgeA2B));
}
use of org.apache.gobblin.service.modules.flow.LoadBasedFlowEdgeImpl in project incubator-gobblin by apache.
the class MultiHopsFlowToJobSpecCompilerTest method testWeightedGraphConstruction.
@Test
public void testWeightedGraphConstruction() {
FlowSpec flowSpec = initFlowSpec();
TopologySpec topologySpec = initTopologySpec(TOPOLOGY_SPEC_STORE_DIR, TEST_SOURCE_NAME, TEST_HOP_NAME_A, TEST_HOP_NAME_B, TEST_SINK_NAME);
this.compilerWithTemplateCalague.onAddSpec(topologySpec);
// invocation of compileFlow trigger the weighedGraph construction
this.compilerWithTemplateCalague.compileFlow(flowSpec);
DirectedWeightedMultigraph<ServiceNode, FlowEdge> weightedGraph = compilerWithTemplateCalague.getWeightedGraph();
Assert.assertTrue(weightedGraph.containsVertex(vertexSource));
Assert.assertTrue(weightedGraph.containsVertex(vertexHopA));
Assert.assertTrue(weightedGraph.containsVertex(vertexHopB));
Assert.assertTrue(weightedGraph.containsVertex(vertexSink));
FlowEdge edgeSrc2A = new LoadBasedFlowEdgeImpl(vertexSource, vertexHopA, topologySpec.getSpecExecutor());
FlowEdge edgeA2B = new LoadBasedFlowEdgeImpl(vertexHopA, vertexHopB, topologySpec.getSpecExecutor());
FlowEdge edgeB2Sink = new LoadBasedFlowEdgeImpl(vertexHopB, vertexSink, topologySpec.getSpecExecutor());
Assert.assertTrue(weightedGraph.containsEdge(edgeSrc2A));
Assert.assertTrue(weightedGraph.containsEdge(edgeA2B));
Assert.assertTrue(weightedGraph.containsEdge(edgeB2Sink));
Assert.assertTrue(edgeEqual(weightedGraph.getEdge(vertexSource, vertexHopA), edgeSrc2A));
Assert.assertTrue(edgeEqual(weightedGraph.getEdge(vertexHopA, vertexHopB), edgeA2B));
Assert.assertTrue(edgeEqual(weightedGraph.getEdge(vertexHopB, vertexSink), edgeB2Sink));
this.compilerWithTemplateCalague.onDeleteSpec(topologySpec.getUri(), "");
}
Aggregations