use of com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript in project cloudbreak by hortonworks.
the class AbstractFileSystemConfigurator method getScripts.
@Override
public List<RecipeScript> getScripts(Credential credential, T fsConfig) {
List<RecipeScript> scripts = new ArrayList<>();
try {
for (FileSystemScriptConfig fsScriptConfig : getScriptConfigs(credential, fsConfig)) {
String script = FileReaderUtils.readFileFromClasspath(fsScriptConfig.getScriptLocation());
for (Entry<String, String> entry : fsScriptConfig.getProperties().entrySet()) {
script = script.replaceAll("\\$" + entry.getKey(), entry.getValue());
}
scripts.add(new RecipeScript(script, fsScriptConfig.getExecutionType(), fsScriptConfig.getRecipeType()));
}
} catch (IOException e) {
throw new FileSystemConfigException("Filesystem configuration scripts cannot be read.", e);
}
return scripts;
}
use of com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript in project cloudbreak by hortonworks.
the class RecipeBuilder method buildRecipes.
public List<Recipe> buildRecipes(String recipeName, Collection<RecipeScript> recipeScripts) {
List<Recipe> recipes = new ArrayList<>();
int index = 0;
for (RecipeScript script : recipeScripts) {
Recipe recipe = new Recipe();
if (recipeScripts.size() > 1) {
recipe.setName(recipeName + '-' + index);
} else {
recipe.setName(recipeName);
}
recipe.setContent(Base64.encodeBase64String(script.getScript().getBytes()));
recipe.setRecipeType(script.getRecipeType());
index++;
recipes.add(recipe);
}
return recipes;
}
use of com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript in project cloudbreak by hortonworks.
the class RecipeEngine method addFsRecipesToHostGroups.
private void addFsRecipesToHostGroups(Credential credential, Iterable<HostGroup> hostGroups, String blueprintText, FileSystem fs) throws IOException {
String scriptName = fs.getType().toLowerCase();
FileSystemConfigurator fsConfigurator = fileSystemConfigurators.get(FileSystemType.valueOf(fs.getType()));
FileSystemConfiguration fsConfiguration = getFileSystemConfiguration(fs);
List<RecipeScript> recipeScripts = fsConfigurator.getScripts(credential, fsConfiguration);
List<Recipe> fsRecipes = recipeBuilder.buildRecipes(scriptName, recipeScripts);
for (int i = 0; i < fsRecipes.size(); i++) {
RecipeScript recipeScript = recipeScripts.get(i);
Recipe recipe = fsRecipes.get(i);
for (HostGroup hostGroup : hostGroups) {
if (ExecutionType.ALL_NODES == recipeScript.getExecutionType()) {
hostGroup.addRecipe(recipe);
} else if (ExecutionType.ONE_NODE == recipeScript.getExecutionType() && isComponentPresent(blueprintText, "NAMENODE", hostGroup)) {
hostGroup.addRecipe(recipe);
break;
}
}
}
}
Aggregations