@Test public void clusterLinksTest() throws IOException, KaramelException { Settings.CB_CLASSPATH_MODE = true; String ymlString = Resources.toString(Resources.getResource("se/kth/karamel/client/model/test-definitions/hopsworks.yml"), Charsets.UTF_8); JsonCluster definition = ClusterDefinitionService.yamlToJsonObject(ymlString); String links = UserClusterDataExtractor.clusterLinks(definition, null); String expected = "Visit <a target='_blank' href='http: + "href='http: Assert.assertEquals(expected, links.trim()); ClusterRuntime dummyRuntime = MockingUtil.dummyRuntime(definition); links = UserClusterDataExtractor.clusterLinks(definition, dummyRuntime); expected = "Click <a target='_blank' href='https: + "Visit <a target='_blank' href='http: + ""; }
public static String clusterLinks(JsonCluster cluster, ClusterRuntime clusterEntity) throws KaramelException { StringBuilder builder = new StringBuilder(); HashSet<String> cbids = new HashSet<>(); for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { String cbid = jc.getId(); cbids.add(cbid); cookbookCache.prepareParallel(cbids); } } for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { for (JsonRecipe rec : jc.getRecipes()) { String cbid = jc.getId(); KaramelizedCookbook cb = cookbookCache.get(cbid); MetadataRb metadataRb = cb.getMetadataRb(); List<Recipe> recipes = metadataRb.getRecipes(); for (Recipe recipe : recipes) { if (recipe.getCanonicalName().equalsIgnoreCase(rec.getCanonicalName())) { Set<String> links = recipe.getLinks(); for (String link : links) { if (link.contains(Settings.METADATA_INCOMMENT_HOST_KEY)) { if (clusterEntity != null) { GroupRuntime ge = findGroup(clusterEntity, jg.getName()); if (ge != null) { List<MachineRuntime> machines = ge.getMachines(); if (machines != null) { for (MachineRuntime me : ge.getMachines()) { String l = link.replaceAll(Settings.METADATA_INCOMMENT_HOST_KEY, me.getPublicIp()); builder.append(l).append("\n"); } } } } } else { builder.append(link).append("\n"); } } } } } } } return builder.toString(); }
UserClusterDataExtractor { public static String clusterLinks(JsonCluster cluster, ClusterRuntime clusterEntity) throws KaramelException { StringBuilder builder = new StringBuilder(); HashSet<String> cbids = new HashSet<>(); for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { String cbid = jc.getId(); cbids.add(cbid); cookbookCache.prepareParallel(cbids); } } for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { for (JsonRecipe rec : jc.getRecipes()) { String cbid = jc.getId(); KaramelizedCookbook cb = cookbookCache.get(cbid); MetadataRb metadataRb = cb.getMetadataRb(); List<Recipe> recipes = metadataRb.getRecipes(); for (Recipe recipe : recipes) { if (recipe.getCanonicalName().equalsIgnoreCase(rec.getCanonicalName())) { Set<String> links = recipe.getLinks(); for (String link : links) { if (link.contains(Settings.METADATA_INCOMMENT_HOST_KEY)) { if (clusterEntity != null) { GroupRuntime ge = findGroup(clusterEntity, jg.getName()); if (ge != null) { List<MachineRuntime> machines = ge.getMachines(); if (machines != null) { for (MachineRuntime me : ge.getMachines()) { String l = link.replaceAll(Settings.METADATA_INCOMMENT_HOST_KEY, me.getPublicIp()); builder.append(l).append("\n"); } } } } } else { builder.append(link).append("\n"); } } } } } } } return builder.toString(); } }
UserClusterDataExtractor { public static String clusterLinks(JsonCluster cluster, ClusterRuntime clusterEntity) throws KaramelException { StringBuilder builder = new StringBuilder(); HashSet<String> cbids = new HashSet<>(); for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { String cbid = jc.getId(); cbids.add(cbid); cookbookCache.prepareParallel(cbids); } } for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { for (JsonRecipe rec : jc.getRecipes()) { String cbid = jc.getId(); KaramelizedCookbook cb = cookbookCache.get(cbid); MetadataRb metadataRb = cb.getMetadataRb(); List<Recipe> recipes = metadataRb.getRecipes(); for (Recipe recipe : recipes) { if (recipe.getCanonicalName().equalsIgnoreCase(rec.getCanonicalName())) { Set<String> links = recipe.getLinks(); for (String link : links) { if (link.contains(Settings.METADATA_INCOMMENT_HOST_KEY)) { if (clusterEntity != null) { GroupRuntime ge = findGroup(clusterEntity, jg.getName()); if (ge != null) { List<MachineRuntime> machines = ge.getMachines(); if (machines != null) { for (MachineRuntime me : ge.getMachines()) { String l = link.replaceAll(Settings.METADATA_INCOMMENT_HOST_KEY, me.getPublicIp()); builder.append(l).append("\n"); } } } } } else { builder.append(link).append("\n"); } } } } } } } return builder.toString(); }  }
UserClusterDataExtractor { public static String clusterLinks(JsonCluster cluster, ClusterRuntime clusterEntity) throws KaramelException { StringBuilder builder = new StringBuilder(); HashSet<String> cbids = new HashSet<>(); for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { String cbid = jc.getId(); cbids.add(cbid); cookbookCache.prepareParallel(cbids); } } for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { for (JsonRecipe rec : jc.getRecipes()) { String cbid = jc.getId(); KaramelizedCookbook cb = cookbookCache.get(cbid); MetadataRb metadataRb = cb.getMetadataRb(); List<Recipe> recipes = metadataRb.getRecipes(); for (Recipe recipe : recipes) { if (recipe.getCanonicalName().equalsIgnoreCase(rec.getCanonicalName())) { Set<String> links = recipe.getLinks(); for (String link : links) { if (link.contains(Settings.METADATA_INCOMMENT_HOST_KEY)) { if (clusterEntity != null) { GroupRuntime ge = findGroup(clusterEntity, jg.getName()); if (ge != null) { List<MachineRuntime> machines = ge.getMachines(); if (machines != null) { for (MachineRuntime me : ge.getMachines()) { String l = link.replaceAll(Settings.METADATA_INCOMMENT_HOST_KEY, me.getPublicIp()); builder.append(l).append("\n"); } } } } } else { builder.append(link).append("\n"); } } } } } } } return builder.toString(); }  static String clusterLinks(JsonCluster cluster, ClusterRuntime clusterEntity); static int totalMachines(JsonCluster cluster); static JsonGroup findGroup(JsonCluster cluster, String groupName); static GroupRuntime findGroup(ClusterRuntime clusterEntity, String groupName); static Provider getGroupProvider(JsonCluster cluster, String groupName); static String makeVendorPath(String sshUser, List<KaramelizedCookbook> rootCookbooks); }
UserClusterDataExtractor { public static String clusterLinks(JsonCluster cluster, ClusterRuntime clusterEntity) throws KaramelException { StringBuilder builder = new StringBuilder(); HashSet<String> cbids = new HashSet<>(); for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { String cbid = jc.getId(); cbids.add(cbid); cookbookCache.prepareParallel(cbids); } } for (JsonGroup jg : cluster.getGroups()) { for (JsonCookbook jc : jg.getCookbooks()) { for (JsonRecipe rec : jc.getRecipes()) { String cbid = jc.getId(); KaramelizedCookbook cb = cookbookCache.get(cbid); MetadataRb metadataRb = cb.getMetadataRb(); List<Recipe> recipes = metadataRb.getRecipes(); for (Recipe recipe : recipes) { if (recipe.getCanonicalName().equalsIgnoreCase(rec.getCanonicalName())) { Set<String> links = recipe.getLinks(); for (String link : links) { if (link.contains(Settings.METADATA_INCOMMENT_HOST_KEY)) { if (clusterEntity != null) { GroupRuntime ge = findGroup(clusterEntity, jg.getName()); if (ge != null) { List<MachineRuntime> machines = ge.getMachines(); if (machines != null) { for (MachineRuntime me : ge.getMachines()) { String l = link.replaceAll(Settings.METADATA_INCOMMENT_HOST_KEY, me.getPublicIp()); builder.append(l).append("\n"); } } } } } else { builder.append(link).append("\n"); } } } } } } } return builder.toString(); }  static String clusterLinks(JsonCluster cluster, ClusterRuntime clusterEntity); static int totalMachines(JsonCluster cluster); static JsonGroup findGroup(JsonCluster cluster, String groupName); static GroupRuntime findGroup(ClusterRuntime clusterEntity, String groupName); static Provider getGroupProvider(JsonCluster cluster, String groupName); static String makeVendorPath(String sshUser, List<KaramelizedCookbook> rootCookbooks);  }