Search in sources :

Example 1 with FileSystemConfigurator

use of com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemConfigurator in project cloudbreak by hortonworks.

the class ClusterTerminationService method deleteFileSystemResources.

private void deleteFileSystemResources(Long stackId, FileSystem fileSystem) {
    try {
        FileSystemConfigurator fsConfigurator = fileSystemConfigurators.get(FileSystemType.valueOf(fileSystem.getType()));
        String json = writeValueAsString(fileSystem.getProperties());
        FileSystemConfiguration fsConfiguration = readValue(json, FileSystemType.valueOf(fileSystem.getType()).getClazz());
        fsConfiguration.addProperty(FileSystemConfiguration.STORAGE_CONTAINER, "cloudbreak" + stackId);
        fsConfigurator.deleteResources(fsConfiguration);
    } catch (IOException e) {
        throw new TerminationFailedException("File system resources could not be deleted: ", e);
    }
}
Also used : FileSystemConfigurator(com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemConfigurator) JsonUtil.writeValueAsString(com.sequenceiq.cloudbreak.util.JsonUtil.writeValueAsString) IOException(java.io.IOException) TerminationFailedException(com.sequenceiq.cloudbreak.service.stack.flow.TerminationFailedException) FileSystemConfiguration(com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration)

Example 2 with FileSystemConfigurator

use of com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemConfigurator 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;
            }
        }
    }
}
Also used : FileSystemConfigurator(com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemConfigurator) RecipeScript(com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript) Recipe(com.sequenceiq.cloudbreak.domain.Recipe) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) FileSystemConfiguration(com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration)

Aggregations

FileSystemConfiguration (com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration)2 FileSystemConfigurator (com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemConfigurator)2 RecipeScript (com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript)1 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)1 Recipe (com.sequenceiq.cloudbreak.domain.Recipe)1 TerminationFailedException (com.sequenceiq.cloudbreak.service.stack.flow.TerminationFailedException)1 JsonUtil.writeValueAsString (com.sequenceiq.cloudbreak.util.JsonUtil.writeValueAsString)1 IOException (java.io.IOException)1