@Test public void planTest() throws URISyntaxException, IOException, ParsingException { Planner planner = new Planner(); String aam = new Scanner(new File(Resources.getResource("aam_atos_case_study10Dec.yml").toURI())).useDelimiter("\\Z").next(); String offerings = new Scanner(new File(Resources.getResource("offer_all.yaml").toURI())).useDelimiter("\\Z").next(); String[] plans = planner.plan(aam, offerings); String expectedADP = new Scanner(new File(Resources.getResource("adp_atos_case_study10Dec.yml").toURI())).useDelimiter("\\Z").next(); Yaml expectedADPYml = new Yaml(); Map<String, Map<String, Object>> expectedADPYaml = (Map<String, Map<String, Object>>) expectedADPYml.load(expectedADP); Map<String, Object> expectedADPNodeTemplates = (Map<String, Object>) expectedADPYaml.get("topology_template").get("node_templates"); Assert.assertNotNull(plans); Assert.assertTrue(plans.length>=1); for (String plan : plans) { Yaml yml = new Yaml(); Map<String, Map<String, Object>> adpYaml = (Map<String, Map<String, Object>>) yml.load(plan); Map<String, Object> planNodeTemplates = (Map<String, Object>) adpYaml.get("topology_template").get("node_templates"); ArrayList<LinkedHashMap> wwwRequirements = ((Map<String, ArrayList<LinkedHashMap>>) planNodeTemplates.get("www")).get("requirements"); ArrayList<LinkedHashMap> expectedWwwRequirements = ((Map<String, ArrayList<LinkedHashMap>>) expectedADPNodeTemplates.get("www")).get("requirements"); for (int i = 0; i < wwwRequirements.size(); i++) { LinkedHashMap requirement = wwwRequirements.get(i); LinkedHashMap expectedRequirement = expectedWwwRequirements.get(i); Assert.assertEquals(requirement.get("host"), expectedRequirement.get("host")); } ArrayList<LinkedHashMap> webservicesRequirements = ((Map<String, ArrayList<LinkedHashMap>>) planNodeTemplates.get("webservices")).get("requirements"); ArrayList<LinkedHashMap> expectedWebservicesRequirements = ((Map<String, ArrayList<LinkedHashMap>>) expectedADPNodeTemplates.get("webservices")).get("requirements"); for (int i = 0; i < webservicesRequirements.size(); i++) { LinkedHashMap requirement = webservicesRequirements.get(i); LinkedHashMap expectedRequirement = expectedWebservicesRequirements.get(i); Assert.assertEquals(requirement.get("host"), expectedRequirement.get("host")); } ArrayList<LinkedHashMap> db1Requirements = ((Map<String, ArrayList<LinkedHashMap>>) planNodeTemplates.get("db1")).get("requirements"); ArrayList<LinkedHashMap> expectedDb1Requirements = ((Map<String, ArrayList<LinkedHashMap>>) expectedADPNodeTemplates.get("db1")).get("requirements"); for (int i = 0; i < db1Requirements.size(); i++) { LinkedHashMap requirement = db1Requirements.get(i); LinkedHashMap expectedRequirement = expectedDb1Requirements.get(i); Assert.assertEquals(requirement.get("host"), expectedRequirement.get("host")); } } }
public String[] plan(String aam, String uniqueOfferingsTosca) throws ParsingException, IOException { log.info("Planning for aam: \n" + aam); log.info("Getting Offeing Step: Start"); Map<String, Pair<NodeTemplate, String>> offerings = parseOfferings(uniqueOfferingsTosca); log.info("Getting Offeing Step: Complete"); log.info("\nNot deployable offering have been filtered!"); log.info("\nDeployable offerings have location: " + deployableProviders); log.info("Got " + offerings.size() + " offerings from discoverer:"); log.info("Matchmaking Step: Start"); Matchmaker mm = new Matchmaker(); Map<String, HashSet<String>> matchingOfferings = mm.match(ToscaSerializer.fromTOSCA(aam), offerings); log.info("Matchmaking Step: Complete"); String mmOutput = ""; try { mmOutput = generateMMOutput2(matchingOfferings, offerings); }catch(JsonProcessingException e){ log.error("Error preparing matchmaker output for optimization", e); } for(String s:matchingOfferings.keySet()){ log.info("Module " + s + "has matching offerings: " + matchingOfferings.get(s)); } log.info("Optimization Step: Start"); log.info("Calling optimizer with suitable offerings: \n" + mmOutput); Optimizer optimizer = new Optimizer(); String[] outputPlans = optimizer.optimize(aam, mmOutput); log.info("Optimzer result: " + Arrays.asList(outputPlans)); log.info("Optimization Step: Complete"); return outputPlans; }
Planner { public String[] plan(String aam, String uniqueOfferingsTosca) throws ParsingException, IOException { log.info("Planning for aam: \n" + aam); log.info("Getting Offeing Step: Start"); Map<String, Pair<NodeTemplate, String>> offerings = parseOfferings(uniqueOfferingsTosca); log.info("Getting Offeing Step: Complete"); log.info("\nNot deployable offering have been filtered!"); log.info("\nDeployable offerings have location: " + deployableProviders); log.info("Got " + offerings.size() + " offerings from discoverer:"); log.info("Matchmaking Step: Start"); Matchmaker mm = new Matchmaker(); Map<String, HashSet<String>> matchingOfferings = mm.match(ToscaSerializer.fromTOSCA(aam), offerings); log.info("Matchmaking Step: Complete"); String mmOutput = ""; try { mmOutput = generateMMOutput2(matchingOfferings, offerings); }catch(JsonProcessingException e){ log.error("Error preparing matchmaker output for optimization", e); } for(String s:matchingOfferings.keySet()){ log.info("Module " + s + "has matching offerings: " + matchingOfferings.get(s)); } log.info("Optimization Step: Start"); log.info("Calling optimizer with suitable offerings: \n" + mmOutput); Optimizer optimizer = new Optimizer(); String[] outputPlans = optimizer.optimize(aam, mmOutput); log.info("Optimzer result: " + Arrays.asList(outputPlans)); log.info("Optimization Step: Complete"); return outputPlans; } }
Planner { public String[] plan(String aam, String uniqueOfferingsTosca) throws ParsingException, IOException { log.info("Planning for aam: \n" + aam); log.info("Getting Offeing Step: Start"); Map<String, Pair<NodeTemplate, String>> offerings = parseOfferings(uniqueOfferingsTosca); log.info("Getting Offeing Step: Complete"); log.info("\nNot deployable offering have been filtered!"); log.info("\nDeployable offerings have location: " + deployableProviders); log.info("Got " + offerings.size() + " offerings from discoverer:"); log.info("Matchmaking Step: Start"); Matchmaker mm = new Matchmaker(); Map<String, HashSet<String>> matchingOfferings = mm.match(ToscaSerializer.fromTOSCA(aam), offerings); log.info("Matchmaking Step: Complete"); String mmOutput = ""; try { mmOutput = generateMMOutput2(matchingOfferings, offerings); }catch(JsonProcessingException e){ log.error("Error preparing matchmaker output for optimization", e); } for(String s:matchingOfferings.keySet()){ log.info("Module " + s + "has matching offerings: " + matchingOfferings.get(s)); } log.info("Optimization Step: Start"); log.info("Calling optimizer with suitable offerings: \n" + mmOutput); Optimizer optimizer = new Optimizer(); String[] outputPlans = optimizer.optimize(aam, mmOutput); log.info("Optimzer result: " + Arrays.asList(outputPlans)); log.info("Optimization Step: Complete"); return outputPlans; } Planner();  Planner(String discovererURL);  Planner(String discovererURL, List<String> deployableProviders); }
Planner { public String[] plan(String aam, String uniqueOfferingsTosca) throws ParsingException, IOException { log.info("Planning for aam: \n" + aam); log.info("Getting Offeing Step: Start"); Map<String, Pair<NodeTemplate, String>> offerings = parseOfferings(uniqueOfferingsTosca); log.info("Getting Offeing Step: Complete"); log.info("\nNot deployable offering have been filtered!"); log.info("\nDeployable offerings have location: " + deployableProviders); log.info("Got " + offerings.size() + " offerings from discoverer:"); log.info("Matchmaking Step: Start"); Matchmaker mm = new Matchmaker(); Map<String, HashSet<String>> matchingOfferings = mm.match(ToscaSerializer.fromTOSCA(aam), offerings); log.info("Matchmaking Step: Complete"); String mmOutput = ""; try { mmOutput = generateMMOutput2(matchingOfferings, offerings); }catch(JsonProcessingException e){ log.error("Error preparing matchmaker output for optimization", e); } for(String s:matchingOfferings.keySet()){ log.info("Module " + s + "has matching offerings: " + matchingOfferings.get(s)); } log.info("Optimization Step: Start"); log.info("Calling optimizer with suitable offerings: \n" + mmOutput); Optimizer optimizer = new Optimizer(); String[] outputPlans = optimizer.optimize(aam, mmOutput); log.info("Optimzer result: " + Arrays.asList(outputPlans)); log.info("Optimization Step: Complete"); return outputPlans; } Planner();  Planner(String discovererURL);  Planner(String discovererURL, List<String> deployableProviders); String[] fetchAndPlan(String aam); String[] plan(String aam, String uniqueOfferingsTosca); String[] fetchAndRePlan(String aam, List<String> modulesToFilter); String[] rePlan(String aam, String uniqueOfferingsTosca, List<String> modulesToFilter); }
Planner { public String[] plan(String aam, String uniqueOfferingsTosca) throws ParsingException, IOException { log.info("Planning for aam: \n" + aam); log.info("Getting Offeing Step: Start"); Map<String, Pair<NodeTemplate, String>> offerings = parseOfferings(uniqueOfferingsTosca); log.info("Getting Offeing Step: Complete"); log.info("\nNot deployable offering have been filtered!"); log.info("\nDeployable offerings have location: " + deployableProviders); log.info("Got " + offerings.size() + " offerings from discoverer:"); log.info("Matchmaking Step: Start"); Matchmaker mm = new Matchmaker(); Map<String, HashSet<String>> matchingOfferings = mm.match(ToscaSerializer.fromTOSCA(aam), offerings); log.info("Matchmaking Step: Complete"); String mmOutput = ""; try { mmOutput = generateMMOutput2(matchingOfferings, offerings); }catch(JsonProcessingException e){ log.error("Error preparing matchmaker output for optimization", e); } for(String s:matchingOfferings.keySet()){ log.info("Module " + s + "has matching offerings: " + matchingOfferings.get(s)); } log.info("Optimization Step: Start"); log.info("Calling optimizer with suitable offerings: \n" + mmOutput); Optimizer optimizer = new Optimizer(); String[] outputPlans = optimizer.optimize(aam, mmOutput); log.info("Optimzer result: " + Arrays.asList(outputPlans)); log.info("Optimization Step: Complete"); return outputPlans; } Planner();  Planner(String discovererURL);  Planner(String discovererURL, List<String> deployableProviders); String[] fetchAndPlan(String aam); String[] plan(String aam, String uniqueOfferingsTosca); String[] fetchAndRePlan(String aam, List<String> modulesToFilter); String[] rePlan(String aam, String uniqueOfferingsTosca, List<String> modulesToFilter);  }