@Test public void testCollectErrors() { ArrayListMultimap<String, String> nodesWithErrors = getNodesWithErrors(); CloudbreakOrchestratorFailedException exception = new CloudbreakOrchestratorFailedException(EXCEPTION_MESSAGE, nodesWithErrors); List<RecipeExecutionFailureCollector.RecipeFailure> recipeExecutionFailures = recipeExecutionFailureHandler.collectErrors(exception); assertEquals(3, recipeExecutionFailures.size()); long recipe1Failures = recipeExecutionFailures.stream() .filter(failure -> "failingRecipe1".equals(failure.getRecipeName())) .count(); assertEquals(2, recipe1Failures); long recipe2Failures = recipeExecutionFailures.stream() .filter(failure -> "failingRecipe2".equals(failure.getRecipeName())) .count(); assertEquals(1, recipe2Failures); long workerInstanceFailures = recipeExecutionFailures.stream() .filter(failure -> "host-10-0-0-4.openstacklocal".equals(failure.getHost())) .count(); assertEquals(2, workerInstanceFailures); long masterInstanceFailures = recipeExecutionFailures.stream() .filter(failure -> "host-10-0-0-3.openstacklocal".equals(failure.getHost())) .peek(failure -> assertEquals("failingRecipe1", failure.getRecipeName())) .count(); assertEquals(1, masterInstanceFailures); }
public List<RecipeFailure> collectErrors(CloudbreakOrchestratorException exception) { Multimap<String, String> nodesWithErrors = getNodesWithErrors(exception); if (nodesWithErrors.isEmpty()) { throw new CloudbreakServiceException("Failed to collect recipe execution failures. Cause exception contains no information.", exception); } List<RecipeFailure> failures = nodesWithErrors.asMap().entrySet().stream() .flatMap(e -> e.getValue().stream() .map(v -> new SimpleImmutableEntry<>(e.getKey(), v)) .map(failure -> new RecipeFailure(failure.getKey(), getRecipePhase(failure.getValue()), getFailedRecipeName(failure.getValue())))) .filter(failure -> !failure.getRecipeName().isEmpty() && !failure.getPhase().isEmpty()) .collect(Collectors.toList()); return failures; }
RecipeExecutionFailureCollector { public List<RecipeFailure> collectErrors(CloudbreakOrchestratorException exception) { Multimap<String, String> nodesWithErrors = getNodesWithErrors(exception); if (nodesWithErrors.isEmpty()) { throw new CloudbreakServiceException("Failed to collect recipe execution failures. Cause exception contains no information.", exception); } List<RecipeFailure> failures = nodesWithErrors.asMap().entrySet().stream() .flatMap(e -> e.getValue().stream() .map(v -> new SimpleImmutableEntry<>(e.getKey(), v)) .map(failure -> new RecipeFailure(failure.getKey(), getRecipePhase(failure.getValue()), getFailedRecipeName(failure.getValue())))) .filter(failure -> !failure.getRecipeName().isEmpty() && !failure.getPhase().isEmpty()) .collect(Collectors.toList()); return failures; } }
RecipeExecutionFailureCollector { public List<RecipeFailure> collectErrors(CloudbreakOrchestratorException exception) { Multimap<String, String> nodesWithErrors = getNodesWithErrors(exception); if (nodesWithErrors.isEmpty()) { throw new CloudbreakServiceException("Failed to collect recipe execution failures. Cause exception contains no information.", exception); } List<RecipeFailure> failures = nodesWithErrors.asMap().entrySet().stream() .flatMap(e -> e.getValue().stream() .map(v -> new SimpleImmutableEntry<>(e.getKey(), v)) .map(failure -> new RecipeFailure(failure.getKey(), getRecipePhase(failure.getValue()), getFailedRecipeName(failure.getValue())))) .filter(failure -> !failure.getRecipeName().isEmpty() && !failure.getPhase().isEmpty()) .collect(Collectors.toList()); return failures; }  }
RecipeExecutionFailureCollector { public List<RecipeFailure> collectErrors(CloudbreakOrchestratorException exception) { Multimap<String, String> nodesWithErrors = getNodesWithErrors(exception); if (nodesWithErrors.isEmpty()) { throw new CloudbreakServiceException("Failed to collect recipe execution failures. Cause exception contains no information.", exception); } List<RecipeFailure> failures = nodesWithErrors.asMap().entrySet().stream() .flatMap(e -> e.getValue().stream() .map(v -> new SimpleImmutableEntry<>(e.getKey(), v)) .map(failure -> new RecipeFailure(failure.getKey(), getRecipePhase(failure.getValue()), getFailedRecipeName(failure.getValue())))) .filter(failure -> !failure.getRecipeName().isEmpty() && !failure.getPhase().isEmpty()) .collect(Collectors.toList()); return failures; }  boolean canProcessExecutionFailure(CloudbreakOrchestratorException exception); List<RecipeFailure> collectErrors(CloudbreakOrchestratorException exception); Optional<InstanceMetaData> getInstanceMetadataByHost(Set<InstanceMetaData> instanceMetaData, String host); }
RecipeExecutionFailureCollector { public List<RecipeFailure> collectErrors(CloudbreakOrchestratorException exception) { Multimap<String, String> nodesWithErrors = getNodesWithErrors(exception); if (nodesWithErrors.isEmpty()) { throw new CloudbreakServiceException("Failed to collect recipe execution failures. Cause exception contains no information.", exception); } List<RecipeFailure> failures = nodesWithErrors.asMap().entrySet().stream() .flatMap(e -> e.getValue().stream() .map(v -> new SimpleImmutableEntry<>(e.getKey(), v)) .map(failure -> new RecipeFailure(failure.getKey(), getRecipePhase(failure.getValue()), getFailedRecipeName(failure.getValue())))) .filter(failure -> !failure.getRecipeName().isEmpty() && !failure.getPhase().isEmpty()) .collect(Collectors.toList()); return failures; }  boolean canProcessExecutionFailure(CloudbreakOrchestratorException exception); List<RecipeFailure> collectErrors(CloudbreakOrchestratorException exception); Optional<InstanceMetaData> getInstanceMetadataByHost(Set<InstanceMetaData> instanceMetaData, String host);  }