use of com.sequenceiq.cloudbreak.service.PollingResult in project cloudbreak by hortonworks.
the class AmbariDecommissioner method decommissionAmbariNodes.
private Collection<String> decommissionAmbariNodes(Stack stack, Map<String, HostMetadata> hostsToRemove, Map<String, Map<String, String>> runningComponents, AmbariClient ambariClient) throws CloudbreakException {
Collection<String> result = new HashSet<>();
PollingResult pollingResult = startServicesIfNeeded(stack, ambariClient, runningComponents);
if (isSuccess(pollingResult)) {
List<String> hostList = new ArrayList<>(hostsToRemove.keySet());
Map<String, Integer> decommissionRequests = decommissionComponents(ambariClient, hostList, runningComponents);
if (!decommissionRequests.isEmpty()) {
pollingResult = ambariOperationService.waitForOperations(stack, ambariClient, decommissionRequests, DECOMMISSION_AMBARI_PROGRESS_STATE).getLeft();
}
if (isSuccess(pollingResult)) {
pollingResult = waitForDataNodeDecommission(stack, ambariClient, hostList, runningComponents);
if (isSuccess(pollingResult)) {
pollingResult = waitForRegionServerDecommission(stack, ambariClient, hostList, runningComponents);
if (isSuccess(pollingResult)) {
pollingResult = stopHadoopComponents(stack, ambariClient, hostList, runningComponents);
if (isSuccess(pollingResult)) {
pollingResult = removeHostsFromOrchestrator(stack, ambariClient, hostList);
if (isSuccess(pollingResult) || isTimeout(pollingResult)) {
deleteHosts(hostList, runningComponents, ambariClient);
result.addAll(hostsToRemove.keySet());
}
}
}
}
}
}
return result;
}
use of com.sequenceiq.cloudbreak.service.PollingResult in project cloudbreak by hortonworks.
the class AmbariClusterModificationService method startCluster.
@Override
public int startCluster(Stack stack) throws CloudbreakException {
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
PollingResult ambariHealthCheckResult = ambariPollingServiceProvider.ambariHealthChecker(stack, ambariClient);
if (isExited(ambariHealthCheckResult)) {
throw new CancellationException("Cluster was terminated while waiting for Ambari to start.");
} else if (isTimeout(ambariHealthCheckResult)) {
throw new CloudbreakException("Ambari server was not restarted properly.");
}
LOGGER.info("Starting Ambari agents on the hosts.");
Set<HostMetadata> hostsInCluster = hostMetadataRepository.findHostsInCluster(stack.getCluster().getId());
PollingResult hostsJoinedResult = ambariPollingServiceProvider.ambariHostJoin(stack, ambariClient, hostsInCluster);
if (isExited(hostsJoinedResult)) {
throw new CancellationException("Cluster was terminated while starting Ambari agents.");
}
LOGGER.info("Start all Hadoop services");
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_SERVICES_STARTING.code()));
int requestId = ambariClient.startAllServices();
if (requestId == -1) {
LOGGER.error("Failed to start Hadoop services.");
throw new CloudbreakException("Failed to start Hadoop services.");
}
return requestId;
}
use of com.sequenceiq.cloudbreak.service.PollingResult in project cloudbreak by hortonworks.
the class AmbariClusterModificationService method stopCluster.
@Override
public void stopCluster(Stack stack) throws CloudbreakException {
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
try {
boolean stopped = true;
Collection<Map<String, String>> values = ambariClient.getHostComponentsStates().values();
for (Map<String, String> value : values) {
for (String state : value.values()) {
if (!"INSTALLED".equals(state)) {
stopped = false;
}
}
}
if (!stopped) {
LOGGER.info("Stop all Hadoop services");
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_SERVICES_STOPPING.code()));
int requestId = ambariClient.stopAllServices();
if (requestId != -1) {
LOGGER.info("Waiting for Hadoop services to stop on stack");
PollingResult servicesStopResult = ambariOperationService.waitForOperations(stack, ambariClient, singletonMap("stop services", requestId), STOP_AMBARI_PROGRESS_STATE).getLeft();
if (isExited(servicesStopResult)) {
throw new CancellationException("Cluster was terminated while waiting for Hadoop services to start");
} else if (isTimeout(servicesStopResult)) {
throw new CloudbreakException("Timeout while stopping Ambari services.");
}
} else {
LOGGER.warn("Failed to stop Hadoop services.");
throw new CloudbreakException("Failed to stop Hadoop services.");
}
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_SERVICES_STOPPED.code()));
}
} catch (AmbariConnectionException ignored) {
LOGGER.debug("Ambari not running on the gateway machine, no need to stop it.");
}
}
use of com.sequenceiq.cloudbreak.service.PollingResult in project cloudbreak by hortonworks.
the class AmbariClusterSecurityService method disableSecurity.
@Override
public void disableSecurity(Stack stack) {
try {
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
int opId = ambariClient.disableKerberos();
if (opId == -1) {
return;
}
Map<String, Integer> operationRequests = singletonMap("DISABLE_KERBEROS_REQUEST", opId);
Pair<PollingResult, Exception> pair = ambariOperationService.waitForOperations(stack, ambariClient, operationRequests, DISABLE_KERBEROS_STATE);
ambariClusterConnectorPollingResultChecker.checkPollingResult(pair.getLeft(), cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_DISABLE_KERBEROS_FAILED.code()));
} catch (CancellationException cancellationException) {
throw cancellationException;
} catch (Exception e) {
throw new AmbariOperationFailedException(e.getMessage(), e);
}
}
Aggregations