Search in sources :

Example 1 with Builder

use of com.sequenceiq.cloudbreak.core.bootstrap.config.ContainerConfigBuilder.Builder 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 componentConfigProvider.store(component);
    } catch (IOException ignored) {
        throw new CloudbreakServiceException(String.format("Failed to parse component ContainerConfig for stack: %d, container: %s", stack.getId(), dc.getName()));
    }
}
Also used : ContainerConfig(com.sequenceiq.cloudbreak.orchestrator.model.ContainerConfig) ContainerOrchestrator(com.sequenceiq.cloudbreak.orchestrator.container.ContainerOrchestrator) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) Builder(com.sequenceiq.cloudbreak.core.bootstrap.config.ContainerConfigBuilder.Builder) Json(com.sequenceiq.cloudbreak.domain.json.Json) IOException(java.io.IOException) Component(com.sequenceiq.cloudbreak.domain.Component)

Aggregations

Builder (com.sequenceiq.cloudbreak.core.bootstrap.config.ContainerConfigBuilder.Builder)1 Component (com.sequenceiq.cloudbreak.domain.Component)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1 ContainerOrchestrator (com.sequenceiq.cloudbreak.orchestrator.container.ContainerOrchestrator)1 ContainerConfig (com.sequenceiq.cloudbreak.orchestrator.model.ContainerConfig)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)1 IOException (java.io.IOException)1