use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltConnector method members.
public Map<String, String> members(List<String> privateIps) throws CloudbreakOrchestratorFailedException {
Map<String, List<String>> clients = singletonMap("clients", privateIps);
Response response = saltTarget.path(BOOT_HOSTNAME_ENDPOINT.getContextPath()).request().header(SIGN_HEADER, PkiUtil.generateSignature(signatureKey, toJson(clients).getBytes())).post(Entity.json(clients));
GenericResponses responses = JaxRSUtil.response(response, GenericResponses.class);
List<GenericResponse> failedResponses = responses.getResponses().stream().filter(genericResponse -> !ACCEPTED_STATUSES.contains(genericResponse.getStatusCode())).collect(Collectors.toList());
if (!failedResponses.isEmpty()) {
failedResponseErrorLog(failedResponses);
String failedNodeAddresses = failedResponses.stream().map(GenericResponse::getAddress).collect(Collectors.joining(","));
throw new CloudbreakOrchestratorFailedException("Hostname resolution failed for nodes: " + failedNodeAddresses);
}
return responses.getResponses().stream().collect(Collectors.toMap(GenericResponse::getAddress, GenericResponse::getStatus));
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method postAmbariStartRecipes.
public void postAmbariStartRecipes(Stack stack) throws CloudbreakException {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
try {
hostOrchestrator.postAmbariStartRecipes(gatewayConfig, collectNodes(stack), clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
} catch (CloudbreakOrchestratorFailedException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method uploadRecipes.
public void uploadRecipes(Stack stack, Collection<HostGroup> hostGroups) throws CloudbreakException {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
Map<String, List<RecipeModel>> recipeMap = hostGroups.stream().filter(hg -> !hg.getRecipes().isEmpty()).collect(Collectors.toMap(HostGroup::getName, h -> convert(h.getRecipes())));
List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
recipesEvent(stack.getId(), stack.getStatus(), recipeMap);
try {
hostOrchestrator.uploadRecipes(allGatewayConfigs, recipeMap, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
} catch (CloudbreakOrchestratorFailedException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltJobIdTrackerTest method callWithInProgressAndJobIsRunning.
@Test
public void callWithInProgressAndJobIsRunning() throws Exception {
String jobId = "1";
SaltConnector saltConnector = Mockito.mock(SaltConnector.class);
SaltJobRunner saltJobRunner = Mockito.mock(BaseSaltJobRunner.class);
when(saltJobRunner.getJid()).thenReturn(JobId.jobId(jobId));
when(saltJobRunner.getJobState()).thenCallRealMethod();
doCallRealMethod().when(saltJobRunner).setJobState(any());
when(saltJobRunner.submit(any(SaltConnector.class))).thenReturn(jobId);
saltJobRunner.setJobState(JobState.IN_PROGRESS);
Set<String> targets = new HashSet<>();
targets.add("10.0.0.1");
targets.add("10.0.0.2");
targets.add("10.0.0.3");
when(saltJobRunner.getTarget()).thenReturn(targets);
PowerMockito.mockStatic(SaltStates.class);
PowerMockito.when(SaltStates.jobIsRunning(any(), any())).thenReturn(true);
SaltJobIdTracker saltJobIdTracker = new SaltJobIdTracker(saltConnector, saltJobRunner);
try {
saltJobIdTracker.call();
} catch (CloudbreakOrchestratorFailedException e) {
assertThat(e.getMessage(), both(containsString("jobId='" + jobId + '\'')).and(containsString("is running")));
}
PowerMockito.verifyStatic();
SaltStates.jobIsRunning(any(), eq(jobId));
checkTargets(targets, targetCaptor.getAllValues());
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltJobIdTrackerTest method callWithNotStarted.
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
@Test
public void callWithNotStarted() throws Exception {
String jobId = "1";
SaltConnector saltConnector = Mockito.mock(SaltConnector.class);
SaltJobRunner saltJobRunner = Mockito.mock(SaltJobRunner.class);
PowerMockito.mockStatic(SaltStates.class);
PowerMockito.when(SaltStates.jobIsRunning(any(), any())).thenReturn(true);
Set<String> targets = new HashSet<>();
targets.add("10.0.0.1");
targets.add("10.0.0.2");
targets.add("10.0.0.3");
when(saltJobRunner.getTarget()).thenReturn(targets);
when(saltJobRunner.getJid()).thenReturn(JobId.jobId(jobId));
when(saltJobRunner.getJobState()).thenReturn(JobState.NOT_STARTED, JobState.IN_PROGRESS);
when(saltJobRunner.submit(any(SaltConnector.class))).thenReturn(jobId);
SaltJobIdTracker saltJobIdTracker = new SaltJobIdTracker(saltConnector, saltJobRunner);
try {
saltJobIdTracker.call();
fail("should throw exception");
} catch (CloudbreakOrchestratorFailedException e) {
assertThat(e.getMessage(), both(containsString("jobId='" + jobId + '\'')).and(containsString("is running")));
}
PowerMockito.verifyStatic();
SaltStates.jobIsRunning(any(), eq(jobId));
checkTargets(targets, targetCaptor.getAllValues());
verify(saltJobRunner, times(2)).getJobState();
}
Aggregations