use of com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method addAmbariServices.
@Transactional
public Map<String, String> addAmbariServices(Long stackId, String hostGroupName, Integer scalingAdjustment) throws CloudbreakException {
Map<String, String> candidates;
try {
Stack stack = stackRepository.findOneWithLists(stackId);
Cluster cluster = stack.getCluster();
candidates = collectUpscaleCandidates(cluster.getId(), hostGroupName, scalingAdjustment);
Set<Node> allNodes = collectNodes(stack);
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
SaltConfig saltConfig = createSaltConfig(stack, cluster, gatewayConfigService.getPrimaryGatewayConfig(stack), gatewayConfigs);
hostOrchestrator.runService(gatewayConfigs, allNodes, saltConfig, clusterDeletionBasedModel(stack.getId(), cluster.getId()));
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException e) {
throw new CloudbreakException(e);
}
return candidates;
}
use of com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException 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.cloud.scheduler.CancellationException 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.cloud.scheduler.CancellationException 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