use of com.sequenceiq.ambari.client.AmbariClient 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.ambari.client.AmbariClient 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.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariClusterSecurityService method updateUserNamePassword.
@Override
public void updateUserNamePassword(Stack stack, String newPassword) throws CloudbreakException {
Cluster cluster = clusterService.getById(stack.getCluster().getId());
AmbariClient client = clientFactory.getAmbariClient(stack, cluster.getUserName(), cluster.getPassword());
changeAmbariPassword(cluster.getUserName(), cluster.getPassword(), newPassword, stack, client);
}
use of com.sequenceiq.ambari.client.AmbariClient in project cloudbreak by hortonworks.
the class AmbariClusterSecurityService method replaceUserNamePassword.
@Override
public void replaceUserNamePassword(Stack stack, String newUserName, String newPassword) throws CloudbreakException {
AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster().getUserName(), stack.getCluster().getPassword());
ambariClient = ambariUserHandler.createAmbariUser(newUserName, newPassword, stack, ambariClient);
ambariClient.deleteUser(stack.getCluster().getUserName());
}
use of com.sequenceiq.ambari.client.AmbariClient 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