use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class ClusterBuilderService method startCluster.
public void startCluster(Long stackId) throws CloudbreakException, ClusterClientInitException {
Stack stack = stackService.getByIdWithTransaction(stackId);
ClusterApi connector = clusterApiConnectors.getConnector(stack);
connector.waitForServer(stack, true);
boolean ldapConfigured = ldapConfigService.isLdapConfigExistsForEnvironment(stack.getEnvironmentCrn(), stack.getName());
connector.changeOriginalCredentialsAndCreateCloudbreakUser(ldapConfigured);
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class ClusterManagerUpscaleService method upscaleClusterManager.
public void upscaleClusterManager(Long stackId, Map<String, Integer> hostGroupWithAdjustment, boolean primaryGatewayChanged, boolean repair) throws ClusterClientInitException {
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
// we need to fetch the cluster with the details, to avoid the unnecessary DB querying later
Long clusterId = stack.getCluster().getId();
Cluster cluster = clusterService.findOneWithLists(clusterId).orElseThrow(NotFoundException.notFound("Cluster", clusterId));
LOGGER.debug("Adding new nodes for host group {}", hostGroupWithAdjustment);
NodeReachabilityResult nodeReachabilityResult = hostRunner.addClusterServices(stack, cluster, hostGroupWithAdjustment, repair);
if (primaryGatewayChanged) {
clusterServiceRunner.updateAmbariClientConfig(stack, cluster);
}
clusterService.updateInstancesToRunning(clusterId, nodeReachabilityResult.getReachableNodes());
clusterService.updateInstancesToZombie(stackId, nodeReachabilityResult.getUnreachableNodes());
ClusterApi connector = clusterApiConnectors.getConnector(stack);
ExtendedPollingResult result;
if (!repair && !primaryGatewayChanged && targetedUpscaleSupportService.targetedUpscaleOperationSupported(stack)) {
Set<String> reachableHosts = nodeReachabilityResult.getReachableHosts();
Set<InstanceMetaData> reachableInstances = stack.getNotDeletedAndNotZombieInstanceMetaDataSet().stream().filter(md -> reachableHosts.contains(md.getDiscoveryFQDN())).collect(Collectors.toSet());
result = connector.waitForHosts(reachableInstances);
} else {
result = connector.waitForHosts(stackService.getByIdWithListsInTransaction(stackId).getRunningInstanceMetaDataSet());
}
if (result != null && result.isTimeout()) {
LOGGER.info("Upscaling cluster manager were not successful for nodes: {}", result.getFailedInstanceIds());
instanceMetaDataService.updateInstanceStatus(result.getFailedInstanceIds(), InstanceStatus.ZOMBIE, "Upscaling cluster manager were not successful.");
}
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class ClusterUpscaleService method installServicesOnNewHosts.
public void installServicesOnNewHosts(Long stackId, Set<String> hostGroupNames, Boolean repair, Boolean restartServices, Map<String, Set<String>> hostGroupsWithHostNames) throws CloudbreakException {
Stack stack = stackService.getByIdWithClusterInTransaction(stackId);
LOGGER.debug("Start installing CM services");
removeUnusedParcelComponents(stack);
Set<HostGroup> hostGroupSetWithRecipes = hostGroupService.getByClusterWithRecipes(stack.getCluster().getId());
Set<HostGroup> hostGroupSetWithInstanceMetadas = hostGroupService.getByCluster(stack.getCluster().getId());
Map<HostGroup, Set<InstanceMetaData>> instanceMetaDatasByHostGroup = hostGroupSetWithInstanceMetadas.stream().filter(hostGroup -> hostGroupNames.contains(hostGroup.getName())).collect(Collectors.toMap(Function.identity(), hostGroup -> hostGroup.getInstanceGroup().getRunningInstanceMetaDataSet()));
recipeEngine.executePostAmbariStartRecipes(stack, hostGroupSetWithRecipes);
Set<InstanceMetaData> runningInstanceMetaDataSet = hostGroupSetWithInstanceMetadas.stream().flatMap(hostGroup -> hostGroup.getInstanceGroup().getRunningInstanceMetaDataSet().stream()).collect(Collectors.toSet());
ClusterApi connector = getClusterConnector(stack);
List<String> upscaledHosts = connector.upscaleCluster(instanceMetaDatasByHostGroup);
if (Boolean.TRUE.equals(repair)) {
recommissionHostsIfNeeded(connector, hostGroupsWithHostNames);
restartServicesIfNecessary(restartServices, stack, connector);
}
setInstanceStatus(runningInstanceMetaDataSet, upscaledHosts);
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class ClusterStartPollingHandler method accept.
@Override
public void accept(Event<ClusterStartPollingRequest> event) {
ClusterStartPollingRequest request = event.getData();
ClusterStartPollingResult result;
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
ClusterApi connector = clusterApiConnectors.getConnector(stack);
connector.waitForServices(request.getRequestId());
result = new ClusterStartPollingResult(request);
} catch (Exception e) {
result = new ClusterStartPollingResult(e.getMessage(), e, request);
}
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class DisableKerberosHandler method accept.
@Override
public void accept(Event<DisableKerberosRequest> event) {
DisableKerberosResult result;
try {
LOGGER.info("Received DisableKerberosRequest event: {}", event.getData());
ClusterApi clusterApi = clusterApiConnectors.getConnector(stackService.getByIdWithListsInTransaction(event.getData().getResourceId()));
clusterApi.clusterSecurityService().disableSecurity();
LOGGER.info("Finished disabling Security");
result = new DisableKerberosResult(event.getData());
} catch (Exception e) {
LOGGER.warn("An error has occured during disabling security", e);
result = new DisableKerberosResult(e.getMessage(), e, event.getData());
}
LOGGER.info("Sending out DisableKerberosResult: {}", result);
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
LOGGER.info("DisableKerberosResult has been sent");
}
Aggregations