use of com.sequenceiq.cloudbreak.orchestrator.container.DockerContainer.AMBARI_AGENT in project cloudbreak by hortonworks.
the class ClusterContainerRunner method addClusterContainers.
private Map<String, List<Container>> addClusterContainers(Stack stack, String cloudPlatform, String hostGroupName, Integer adjustment) throws CloudbreakException, CloudbreakOrchestratorException {
Orchestrator orchestrator = stack.getOrchestrator();
Map<String, Object> map = new HashMap<>(orchestrator.getAttributes().getMap());
OrchestrationCredential credential = new OrchestrationCredential(orchestrator.getApiEndpoint(), map);
ContainerOrchestrator containerOrchestrator = containerOrchestratorResolver.get(orchestrator.getType());
Map<String, List<ContainerInfo>> containers = new HashMap<>();
Cluster cluster = clusterService.retrieveClusterByStackId(stack.getId());
try {
Set<Container> existingContainers = containerService.findContainersInCluster(cluster.getId());
String ambariServerHost = existingContainers.stream().filter(input -> input.getImage().contains(AMBARI_SERVER.getName())).findFirst().get().getHost();
HostGroup hostGroup = hostGroupRepository.findHostGroupInClusterByName(cluster.getId(), hostGroupName);
String ambariAgentApp = existingContainers.stream().filter(input -> hostGroup.getHostNames().contains(input.getHost()) && input.getImage().contains(AMBARI_AGENT.getName())).findFirst().get().getName();
List<String> hostBlackList = getOtherHostgroupsAgentHostsFromContainer(existingContainers, hostGroupName);
ContainerConstraint ambariAgentConstraint = constraintFactory.getAmbariAgentConstraint(ambariServerHost, ambariAgentApp, cloudPlatform, hostGroup, adjustment, hostBlackList, cluster.getId().toString());
containers.put(hostGroup.getName(), containerOrchestrator.runContainer(containerConfigService.get(stack, AMBARI_AGENT), credential, ambariAgentConstraint, clusterDeletionBasedModel(stack.getId(), cluster.getId())));
return saveContainers(containers, cluster);
} catch (CloudbreakOrchestratorException ex) {
if (!containers.isEmpty()) {
saveContainers(containers, cluster);
}
checkCancellation(ex);
throw ex;
}
}
Aggregations