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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations