private URI getTemplateURI (ServiceNode sourceNode, ServiceNode targetNode, FlowSpec flowSpec, FlowEdge flowEdge) { URI firstTemplateURI = (edgeTemplateMap != null && edgeTemplateMap.containsKey(flowEdge.getEdgeIdentity())) ? edgeTemplateMap.get( flowEdge.getEdgeIdentity()).get(0) : jobSpecTemplateURIGenerator(flowSpec); return firstTemplateURI; }
/** * As the base implementation here, all templates will be considered for each edge. */ @Override protected void populateEdgeTemplateMap() { if (templateCatalog.isPresent()) { for (FlowEdge flowEdge : this.weightedGraph.edgeSet()) { edgeTemplateMap.put(flowEdge.getEdgeIdentity(), templateCatalog.get(). getAllTemplates(). stream().map(jobTemplate -> jobTemplate.getUri()).collect(Collectors.toList())); } } }
private void populateTemplateMap(WeightedMultigraph<ServiceNode, FlowEdge> weightedGraph, URI exempliedURI){ this.edgeTemplateMap.clear(); Set<FlowEdge> allEdges = weightedGraph.edgeSet(); for ( FlowEdge edge : allEdges ) { this.edgeTemplateMap.put(edge.getEdgeIdentity(), Arrays.asList(exempliedURI)) ; } }
private boolean edgeEqual(FlowEdge a, FlowEdge b){ return (a.getEdgeIdentity().equals(b.getEdgeIdentity()) && ((LoadBasedFlowEdgeImpl)a).getEdgeLoad() == ((LoadBasedFlowEdgeImpl)b).getEdgeLoad()); }
@Test (dependsOnMethods = "testWeightedGraphConstruction") public void testDijkstraPathFinding(){ FlowSpec flowSpec = initFlowSpec(); TopologySpec topologySpec_1 = initTopologySpec(TOPOLOGY_SPEC_STORE_DIR, TEST_SOURCE_NAME, TEST_HOP_NAME_A, TEST_HOP_NAME_B, TEST_SINK_NAME); TopologySpec topologySpec_2 = initTopologySpec(TOPOLOGY_SPEC_STORE_DIR_SECOND, TEST_SOURCE_NAME, TEST_HOP_NAME_B, TEST_HOP_NAME_C, TEST_SINK_NAME); this.compilerWithTemplateCalague.onAddSpec(topologySpec_1); this.compilerWithTemplateCalague.onAddSpec(topologySpec_2); // Get the edge -> Change the weight -> Materialized the edge change back to graph -> compile again -> Assertion this.compilerWithTemplateCalague.compileFlow(flowSpec); DirectedWeightedMultigraph<ServiceNode, FlowEdge> weightedGraph = compilerWithTemplateCalague.getWeightedGraph(); FlowEdge a2b= weightedGraph.getEdge(vertexHopA, vertexHopB); FlowEdge b2c = weightedGraph.getEdge(vertexHopB, vertexHopC); FlowEdge c2s = weightedGraph.getEdge(vertexHopC, vertexSink); weightedGraph.setEdgeWeight(a2b, 1.99); weightedGraph.setEdgeWeight(b2c, 0.1); weightedGraph.setEdgeWeight(c2s, 0.2); // Best route: Src - B(1) - C(0.1) - sink (0.2) this.compilerWithTemplateCalague.compileFlow(flowSpec); List<FlowEdge> edgeList = dijkstraBasedPathFindingHelper(vertexSource, vertexSink, weightedGraph); FlowEdge src2b = weightedGraph.getEdge(vertexSource, vertexHopB); FlowEdge b2C = weightedGraph.getEdge(vertexHopB, vertexHopC); FlowEdge c2sink = weightedGraph.getEdge(vertexHopC, vertexSink); Assert.assertEquals(edgeList.get(0).getEdgeIdentity(), src2b.getEdgeIdentity()); Assert.assertEquals(edgeList.get(1).getEdgeIdentity(), b2C.getEdgeIdentity()); Assert.assertEquals(edgeList.get(2).getEdgeIdentity(), c2sink.getEdgeIdentity()); this.compilerWithTemplateCalague.onDeleteSpec(topologySpec_1.getUri(), ""); this.compilerWithTemplateCalague.onDeleteSpec(topologySpec_2.getUri(), ""); }
private URI getTemplateURI (ServiceNode sourceNode, ServiceNode targetNode, FlowSpec flowSpec, FlowEdge flowEdge) { URI firstTemplateURI = (edgeTemplateMap != null && edgeTemplateMap.containsKey(flowEdge.getEdgeIdentity())) ? edgeTemplateMap.get( flowEdge.getEdgeIdentity()).get(0) : jobSpecTemplateURIGenerator(flowSpec); return firstTemplateURI; }
/** * As the base implementation here, all templates will be considered for each edge. */ @Override protected void populateEdgeTemplateMap() { if (templateCatalog.isPresent()) { for (FlowEdge flowEdge : this.weightedGraph.edgeSet()) { edgeTemplateMap.put(flowEdge.getEdgeIdentity(), templateCatalog.get(). getAllTemplates(). stream().map(jobTemplate -> jobTemplate.getUri()).collect(Collectors.toList())); } } }