private static boolean updateKaramelDependencies( Map<String, RunRecipeTask> allRecipeTasks, Dag dag, Map<String, Map<String, Task>> rlts) throws KaramelException { boolean newDepFound = false; for (RunRecipeTask task : allRecipeTasks.values()) { String tid = task.uniqueId(); KaramelizedCookbook kcb = CookbookCache.get(task.getCookbookId()); KaramelFileYamlDeps dependency = kcb.getKaramelFile().getDependency(task.getRecipeCanonicalName()); if (dependency != null) { for (String depRec : dependency.getLocal()) { String depId = RunRecipeTask.makeUniqueId(task.getMachineId(), depRec); newDepFound |= dag.addDependency(depId, tid); } for (String depRec : dependency.getGlobal()) { Map<String, Task> rlt2 = rlts.get(depRec); if (rlt2 != null) { for (Map.Entry<String, Task> entry : rlt2.entrySet()) { Task t7 = entry.getValue(); newDepFound |= dag.addDependency(t7.uniqueId(), tid); } } } } } return newDepFound; }
/* * Finds recipe task for machine if it has been already created otherwise makes a new one and adds it into the DAG */ private static RunRecipeTask makeRecipeTaskIfNotExist( String recipeName, MachineRuntime machine, ClusterStats clusterStats, JsonObject chefJson, TaskSubmitter submitter, String cookbookId, String cookbookName, Map<String, RunRecipeTask> allRecipeTasks, Dag dag) throws DagConstructionException { String recId = RunRecipeTask.makeUniqueId(machine.getId(), recipeName); RunRecipeTask runRecipeTask = allRecipeTasks.get(recId); if (!allRecipeTasks.containsKey(recId)) { ChefJsonGenerator.addRunListForRecipe(chefJson, recipeName); GsonBuilder builder = new GsonBuilder(); builder.disableHtmlEscaping(); Gson gson = builder.setPrettyPrinting().create(); String jsonString = gson.toJson(chefJson); runRecipeTask = new RunRecipeTask( machine, clusterStats, recipeName, jsonString, submitter, cookbookId, cookbookName); dag.addTask(runRecipeTask); } allRecipeTasks.put(recId, runRecipeTask); return runRecipeTask; }