use of com.sequenceiq.cloudbreak.orchestrator.model.ContainerInfo in project cloudbreak by hortonworks.
the class ClusterContainerRunner method convert.
private List<Container> convert(Iterable<ContainerInfo> containerInfo, Cluster cluster) {
List<Container> containers = new ArrayList<>();
for (ContainerInfo source : containerInfo) {
Container container = conversionService.convert(source, Container.class);
container.setCluster(cluster);
containers.add(container);
}
return containers;
}
use of com.sequenceiq.cloudbreak.orchestrator.model.ContainerInfo 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;
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.ContainerInfo in project cloudbreak by hortonworks.
the class ApplicationDetailHandler method getContainerInfo.
public ContainerInfo getContainerInfo(ContainerConfig config, OrchestrationCredential cred, ContainerConstraint constraint, int componentNumber) throws CloudbreakOrchestratorFailedException {
String applicationName = applicationUtils.getApplicationName(constraint, componentNumber);
// Build the ApplicationDetailRequest
ApplicationDetailRequest applicationDetailRequest = new ApplicationDetailRequest();
applicationDetailRequest.setName(applicationName);
try {
// Validate that the app exists
YarnClient yarnHttpClient = new YarnHttpClient(cred.getApiEndpoint());
ResponseContext appDetailResponseContext = yarnHttpClient.getApplicationDetail(applicationDetailRequest);
if (appDetailResponseContext.getResponseError() != null) {
ApplicationErrorResponse applicationErrorResponse = appDetailResponseContext.getResponseError();
throw new CloudbreakOrchestratorFailedException(String.format("ERROR: HTTP Return: %d Error: %s.", appDetailResponseContext.getStatusCode(), applicationErrorResponse.getDiagnostics()));
}
// Return the details
String componentHostName = applicationUtils.getComponentHostName(constraint, cred, componentNumber);
String image = String.format("%s:%s", config.getName(), config.getVersion());
return new ContainerInfo(applicationName, applicationName, componentHostName, image);
} catch (MalformedURLException e) {
String msg = String.format("ERROR: URL is malformed: %s", cred.getApiEndpoint());
throw new CloudbreakOrchestratorFailedException(msg, e);
}
}
Aggregations