Search in sources :

Example 1 with HttpClientConfig

use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.

the class AmbariClusterService method getAmbariClient.

private AmbariClient getAmbariClient(Stack stack) {
    if (stack.getAmbariIp() == null) {
        throw new NotFoundException(String.format("Ambari server is not available for the stack.[id: %s]", stack.getId()));
    }
    HttpClientConfig httpClientConfig = tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getAmbariIp());
    AmbariClient ambariClient = ambariClientProvider.getAmbariClient(httpClientConfig, stack.getGatewayPort(), stack.getCluster());
    return ambariClient;
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Example 2 with HttpClientConfig

use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.

the class AmbariDecommissioner method verifyNodeCount.

public void verifyNodeCount(@Nonnull Stack stack, @Nonnull Cluster cluster, @Nonnull String hostName) {
    requireNonNull(stack);
    requireNonNull(cluster);
    requireNonNull(hostName);
    HttpClientConfig clientConfig = tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), cluster.getAmbariIp());
    AmbariClient ambariClient = ambariClientProvider.getAmbariClient(clientConfig, stack.getGatewayPort(), cluster);
    String ambariName = cluster.getBlueprint().getAmbariName();
    HostGroup hostGroup = hostGroupService.getByClusterAndHostName(cluster, hostName);
    int replication = getReplicationFactor(ambariClient.getBlueprintMap(ambariName), hostGroup, ambariClient);
    int hostSize = 1;
    int reservedInstances = hostGroup.getHostMetadata().size() - hostSize;
    verifyNodeCount(replication, hostSize, hostSize, reservedInstances);
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Example 3 with HttpClientConfig

use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.

the class AmbariDecommissioner method deleteHostFromAmbari.

public boolean deleteHostFromAmbari(Stack stack, HostMetadata data) {
    HttpClientConfig clientConfig = tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), stack.getCluster().getAmbariIp());
    AmbariClient ambariClient = ambariClientProvider.getAmbariClient(clientConfig, stack.getGatewayPort(), stack.getCluster());
    Map<String, Map<String, String>> runningComponents = ambariClient.getHostComponentsStates();
    return deleteHostFromAmbari(data, runningComponents, ambariClient);
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) Map(java.util.Map) HashMap(java.util.HashMap) Collections.singletonMap(java.util.Collections.singletonMap) AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Example 4 with HttpClientConfig

use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.

the class AmbariDecommissioner method collectHostsToRemove.

public Map<String, HostMetadata> collectHostsToRemove(Stack stack, String hostGroupName, Collection<String> hostNames) throws CloudbreakException {
    Map<String, HostMetadata> hostsToRemove = collectHostMetadata(stack.getCluster(), hostGroupName, hostNames);
    if (hostsToRemove.size() != hostNames.size()) {
        throw new CloudbreakException("Not all the hosts found in the given host group.");
    }
    Cluster cluster = stack.getCluster();
    HttpClientConfig clientConfig = tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), cluster.getAmbariIp());
    AmbariClient ambariClient = ambariClientProvider.getAmbariClient(clientConfig, stack.getGatewayPort(), cluster);
    List<String> runningHosts = ambariClient.getClusterHosts();
    Sets.newHashSet(hostsToRemove.keySet()).forEach(hostName -> {
        if (!runningHosts.contains(hostName)) {
            hostsToRemove.remove(hostName);
        }
    });
    return hostsToRemove;
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata) AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Example 5 with HttpClientConfig

use of com.sequenceiq.cloudbreak.client.HttpClientConfig in project cloudbreak by hortonworks.

the class HostFilterService method filterHostsForDecommission.

public List<HostMetadata> filterHostsForDecommission(Cluster cluster, Set<HostMetadata> hosts, String hostGroup) {
    List<HostMetadata> filteredList = new ArrayList<>(hosts);
    LOGGER.info("Ambari service config, hostGroup: {}, originalList: {}", hostGroup, filteredList);
    HttpClientConfig clientConfig = tlsSecurityService.buildTLSClientConfigForPrimaryGateway(cluster.getStack().getId(), cluster.getAmbariIp());
    AmbariClient ambariClient = ambariClientProvider.getAmbariClient(clientConfig, cluster.getStack().getGatewayPort(), cluster);
    Map<String, String> config = configurationService.getConfiguration(ambariClient, hostGroup);
    LOGGER.info("Ambari service config, hostGroup: {}, config: {}", hostGroup, config);
    for (HostFilter hostFilter : hostFilters) {
        try {
            filteredList = hostFilter.filter(cluster.getId(), config, filteredList);
            LOGGER.info("Filtered with hostfilter: {}, filteredList: {}", hostFilter.getClass().getSimpleName(), filteredList);
        } catch (HostFilterException e) {
            LOGGER.warn("Filter didn't succeed, moving to next filter", e);
        }
    }
    LOGGER.info("Returned filtered hosts: {}", filteredList);
    return filteredList;
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) ArrayList(java.util.ArrayList) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata) AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Aggregations

HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)19 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)16 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)11 Stack (com.sequenceiq.cloudbreak.domain.Stack)10 Test (org.junit.Test)9 HashMap (java.util.HashMap)6 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)5 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)4 List (java.util.List)4 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)2 Collections.singletonMap (java.util.Collections.singletonMap)2 OrchestratorType (com.sequenceiq.cloudbreak.common.model.OrchestratorType)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 Container (com.sequenceiq.cloudbreak.domain.Container)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)1 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)1