use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariOperationsStatusCheckerTask method checkStatus.
@Override
public boolean checkStatus(AmbariOperations t) {
Map<String, Integer> installRequests = t.getRequests();
boolean allFinished = true;
for (Entry<String, Integer> request : installRequests.entrySet()) {
AmbariClient ambariClient = t.getAmbariClient();
BigDecimal installProgress = Optional.ofNullable(ambariClient.getRequestProgress(request.getValue())).orElse(PENDING);
LOGGER.info("Ambari operation: '{}', Progress: {}", request.getKey(), installProgress);
notificationSender.send(getAmbariProgressNotification(installProgress.longValue(), t.getStack(), t.getAmbariOperationType()));
if (FAILED.compareTo(installProgress) == 0) {
boolean failed = true;
for (int i = 0; i < MAX_RETRY; i++) {
if (ambariClient.getRequestProgress(request.getValue()).compareTo(FAILED) != 0) {
failed = false;
break;
}
}
if (failed) {
notificationSender.send(getAmbariProgressNotification(Long.parseLong("100"), t.getStack(), t.getAmbariOperationType()));
throw new AmbariOperationFailedException(String.format("Ambari operation failed: [component: '%s', requestID: '%s']", request.getKey(), request.getValue()));
}
}
allFinished = allFinished && COMPLETED.compareTo(installProgress) == 0;
}
return allFinished;
}
use of com.sequenceiq.ambari.client.AmbariClient 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;
}
use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariStartupListenerTask method checkStatus.
@Override
public boolean checkStatus(AmbariStartupPollerObject aSPO) {
boolean ambariRunning = false;
LOGGER.info("Polling Ambari server's status [Ambari server address: '{}'].", aSPO.getAmbariAddress());
for (AmbariClient ambariClient : aSPO.getAmbariClients()) {
try {
String ambariHealth = ambariClient.healthCheck();
LOGGER.info("Ambari health check returned: {} [Ambari server address: '{}']", ambariHealth, aSPO.getAmbariAddress());
if ("RUNNING".equals(ambariHealth)) {
ambariRunning = true;
break;
}
} catch (Exception e) {
LOGGER.info("Ambari health check failed: {}", e.getMessage());
}
}
return ambariRunning;
}
use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariClusterModificationService method upscaleCluster.
@Override
public void upscaleCluster(Stack stack, HostGroup hostGroup, Collection<HostMetadata> hostMetadata) throws CloudbreakException {
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
List<String> upscaleHostNames = hostMetadata.stream().map(HostMetadata::getHostName).collect(Collectors.toList()).stream().filter(hostName -> !ambariClient.getClusterHosts().contains(hostName)).collect(Collectors.toList());
if (!upscaleHostNames.isEmpty()) {
recipeEngine.executePostAmbariStartRecipes(stack, Sets.newHashSet(hostGroup));
Pair<PollingResult, Exception> pollingResult = ambariOperationService.waitForOperations(stack, ambariClient, installServices(upscaleHostNames, stack, ambariClient, hostGroup.getName()), UPSCALE_AMBARI_PROGRESS_STATE);
String message = pollingResult.getRight() == null ? cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_UPSCALE_FAILED.code()) : pollingResult.getRight().getMessage();
ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResult.getLeft(), message);
}
}
use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariClusterSecurityService method prepareSecurity.
@Override
public void prepareSecurity(Stack stack) {
try {
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
Map<String, Integer> operationRequests = new HashMap<>();
Stream.of("ZOOKEEPER", "HDFS", "YARN", "MAPREDUCE2", "KERBEROS").forEach(s -> {
int opId = s.equals("ZOOKEEPER") ? ambariClient.startService(s) : ambariClient.stopService(s);
if (opId != -1) {
operationRequests.put(s + "_SERVICE_STATE", opId);
}
});
if (operationRequests.isEmpty()) {
return;
}
Pair<PollingResult, Exception> pair = ambariOperationService.waitForOperations(stack, ambariClient, operationRequests, PREPARE_DEKERBERIZING);
ambariClusterConnectorPollingResultChecker.checkPollingResult(pair.getLeft(), cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_PREPARE_DEKERBERIZING_FAILED.code()));
} catch (CancellationException cancellationException) {
throw cancellationException;
} catch (Exception e) {
throw new AmbariOperationFailedException(e.getMessage(), e);
}
}
Aggregations