use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ContainerConfigService method create.
private Component create(Stack stack, DockerContainer dc) throws CloudbreakException {
try {
ContainerConfig config;
ContainerOrchestrator orchestrator = containerOrchestratorResolver.get(stack.getOrchestrator().getType());
Map<String, String> customContainerConfig = getCustomContainerConfig(stack);
Optional<String> customContainerName = Optional.ofNullable(customContainerConfig.get(dc.name()));
Optional<String> customQueue = getCustomQueue(stack);
switch(dc) {
case AMBARI_SERVER:
config = new Builder(orchestrator.ambariServerContainer(customContainerName), customQueue).build();
break;
case AMBARI_AGENT:
config = new Builder(orchestrator.ambariClientContainer(customContainerName), customQueue).build();
break;
case AMBARI_DB:
config = new Builder(orchestrator.ambariDbContainer(customContainerName), customQueue).build();
break;
default:
throw new CloudbreakServiceException(String.format("No configuration exist for %s", dc));
}
Component component = new Component(ComponentType.CONTAINER, dc.name(), new Json(config), stack);
return componentConfigProviderService.store(component);
} catch (IllegalArgumentException ignored) {
throw new CloudbreakServiceException(String.format("Failed to parse component ContainerConfig for stack: %d, container: %s", stack.getId(), dc.getName()));
}
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ContainerConfigService method get.
public ContainerConfig get(Stack stack, DockerContainer dc) {
try {
Component component = componentConfigProviderService.getComponent(stack.getId(), ComponentType.CONTAINER, dc.name());
if (component == null) {
component = create(stack, dc);
LOGGER.debug("Container component definition created: {}", component);
} else {
LOGGER.debug("Container component definition found in database: {}", component);
}
return component.getAttributes().get(ContainerConfig.class);
} catch (CloudbreakException | IOException ignored) {
throw new CloudbreakServiceException(String.format("Failed to parse component ContainerConfig for stack: %d, container: %s", stack.getId(), dc.getName()));
}
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ClouderaManagerClusterCreationSetupService method determineCdhRepoConfig.
private Set<ClouderaManagerProduct> determineCdhRepoConfig(Cluster cluster, List<Component> stackCdhRepoConfig, String osType, String blueprintCdhVersion, String imageCatalogName) throws CloudbreakImageCatalogException {
if (Objects.isNull(stackCdhRepoConfig) || stackCdhRepoConfig.isEmpty()) {
DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(cluster, blueprintCdhVersion, osType, imageCatalogName);
Map<String, String> stack = defaultCDHInfo.getRepo().getStack();
Set<ClouderaManagerProduct> cdhProduct = Set.of(new ClouderaManagerProduct().withVersion(defaultCDHInfo.getVersion()).withName(stack.get("repoid").split("-")[0]).withParcel(stack.get(osType)));
LOGGER.debug("Determined CDH product: {}", cdhProduct);
return cdhProduct;
} else {
Set<ClouderaManagerProduct> products = stackCdhRepoConfig.stream().map(Component::getAttributes).map(json -> json.getSilent(ClouderaManagerProduct.class)).collect(Collectors.toSet());
return filterParcelsIfNecessary(cluster, products);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ComponentConfigProviderService method getImage.
public Image getImage(Long stackId) throws CloudbreakImageNotFoundException {
try {
Component component = getComponent(stackId, ComponentType.IMAGE, ComponentType.IMAGE.name());
if (component == null) {
throw new CloudbreakImageNotFoundException(String.format("Image not found: stackId: %d, componentType: %s, name: %s", stackId, ComponentType.IMAGE.name(), ComponentType.IMAGE.name()));
}
LOGGER.debug("Image found! stackId: {}, component: {}", stackId, component);
return component.getAttributes().get(Image.class);
} catch (IOException e) {
throw new CloudbreakServiceException("Failed to read image", e);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ComponentConfigProviderService method store.
public Component store(Component component) {
LOGGER.debug("Component is going to be saved: {}", component);
Component ret = componentRepository.save(component);
LOGGER.debug("Component saved: stackId: {}, component: {}", ret.getStack().getId(), ret);
return ret;
}
Aggregations