use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method saveSharedRangerService.
private void saveSharedRangerService(Stack stack, Map<String, SaltPillarProperties> servicePillar) {
Long datalakeId = stack.getDatalakeId();
if (datalakeId != null) {
Stack dataLakeStack = stackRepository.findOne(datalakeId);
Cluster dataLakeCluster = dataLakeStack.getCluster();
Set<String> groupNames = blueprintProcessorFactory.get(dataLakeCluster.getBlueprint().getBlueprintText()).getHostGroupsWithComponent("RANGER_ADMIN");
List<HostGroup> groups = dataLakeCluster.getHostGroups().stream().filter(hg -> groupNames.contains(hg.getName())).collect(Collectors.toList());
Set<String> hostNames = new HashSet<>();
groups.forEach(hg -> hostNames.addAll(hg.getHostMetadata().stream().map(HostMetadata::getHostName).collect(Collectors.toList())));
Map<String, Object> rangerMap = new HashMap<>();
rangerMap.put("servers", hostNames);
rangerMap.put("port", "6080");
servicePillar.put("datalake-services", new SaltPillarProperties("/datalake/init.sls", singletonMap("datalake-services", singletonMap("ranger", rangerMap))));
}
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class DependecyDeletionService method deleteDependencies.
public void deleteDependencies(Stack stack) {
deleteNetwork(stack.getNetwork());
deleteCredential(stack.getCredential());
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
deleteSecurityGroup(instanceGroup.getSecurityGroup());
deleteTemplate(instanceGroup.getTemplate());
}
if (stack.getCluster() != null) {
Cluster cluster = stack.getCluster();
deleteBlueprint(cluster.getBlueprint());
Set<HostGroup> hostGroupsInCluster = hostGroupRepository.findHostGroupsInCluster(cluster.getId());
for (HostGroup hostGroup : hostGroupsInCluster) {
hostGroup.getRecipes().forEach(this::deleteRecipe);
}
}
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class AmbariClusterService method hostGroupCounter.
private void hostGroupCounter(Long clusterId, Map<String, Integer> hostGroupCounter) {
LOGGER.info("Counted hostgroups: {}", hostGroupCounter);
Set<HostGroup> hostGroups = hostGroupService.getByCluster(clusterId);
for (HostGroup hostGroup : hostGroups) {
Integer hgCounter = hostGroupCounter.getOrDefault(hostGroup.getName(), 0);
if (!hgCounter.equals(hostGroup.getConstraint().getHostCount())) {
hostGroup.getConstraint().setHostCount(hgCounter);
constraintRepository.save(hostGroup.getConstraint());
LOGGER.info("Updated HostCount for hostgroup: {}, counter: {}", hostGroup.getName(), hgCounter);
}
}
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class AmbariClusterService method failureReport.
@Override
public void failureReport(Long stackId, List<String> failedNodes) {
Stack stack = stackService.get(stackId);
Cluster cluster = stack.getCluster();
Map<String, List<String>> autoRecoveryNodesMap = new HashMap<>();
Map<String, HostMetadata> autoRecoveryHostMetadata = new HashMap<>();
Map<String, HostMetadata> failedHostMetadata = new HashMap<>();
for (String failedNode : failedNodes) {
HostMetadata hostMetadata = hostMetadataRepository.findHostInClusterByName(cluster.getId(), failedNode);
if (hostMetadata == null) {
throw new BadRequestException("No metadata information for the node: " + failedNode);
}
HostGroup hostGroup = hostMetadata.getHostGroup();
if (hostGroup.getRecoveryMode() == RecoveryMode.AUTO) {
validateRepair(stack, hostMetadata);
}
String hostGroupName = hostGroup.getName();
if (hostGroup.getRecoveryMode() == RecoveryMode.AUTO) {
List<String> nodeList = autoRecoveryNodesMap.get(hostGroupName);
if (nodeList == null) {
validateComponentsCategory(stack, hostGroupName);
nodeList = new ArrayList<>();
autoRecoveryNodesMap.put(hostGroupName, nodeList);
}
nodeList.add(failedNode);
autoRecoveryHostMetadata.put(failedNode, hostMetadata);
} else if (hostGroup.getRecoveryMode() == RecoveryMode.MANUAL) {
failedHostMetadata.put(failedNode, hostMetadata);
}
}
if (!autoRecoveryNodesMap.isEmpty()) {
flowManager.triggerClusterRepairFlow(stackId, autoRecoveryNodesMap, false);
String recoveryMessage = cloudbreakMessagesService.getMessage(Msg.AMBARI_CLUSTER_AUTORECOVERY_REQUESTED.code(), Collections.singletonList(autoRecoveryNodesMap));
updateChangedHosts(cluster, autoRecoveryHostMetadata, HostMetadataState.HEALTHY, HostMetadataState.WAITING_FOR_REPAIR, recoveryMessage);
}
if (!failedHostMetadata.isEmpty()) {
String recoveryMessage = cloudbreakMessagesService.getMessage(Msg.AMBARI_CLUSTER_FAILED_NODES_REPORTED.code(), Collections.singletonList(failedHostMetadata.keySet()));
updateChangedHosts(cluster, failedHostMetadata, HostMetadataState.HEALTHY, HostMetadataState.UNHEALTHY, recoveryMessage);
}
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class AmbariClusterService method repairCluster.
@Override
public void repairCluster(Long stackId, List<String> repairedHostGroups, boolean removeOnly) {
Stack stack = stackService.get(stackId);
Cluster cluster = stack.getCluster();
Set<HostGroup> hostGroups = hostGroupService.getByCluster(cluster.getId());
Map<String, List<String>> failedNodeMap = new HashMap<>();
for (HostGroup hg : hostGroups) {
List<String> failedNodes = new ArrayList<>();
if (repairedHostGroups.contains(hg.getName()) && hg.getRecoveryMode() == RecoveryMode.MANUAL) {
for (HostMetadata hmd : hg.getHostMetadata()) {
if (hmd.getHostMetadataState() == HostMetadataState.UNHEALTHY) {
validateRepair(stack, hmd);
if (!failedNodeMap.containsKey(hg.getName())) {
failedNodeMap.put(hg.getName(), failedNodes);
}
failedNodes.add(hmd.getHostName());
}
}
}
}
if (!failedNodeMap.isEmpty()) {
flowManager.triggerClusterRepairFlow(stackId, failedNodeMap, removeOnly);
String recoveryMessage = cloudbreakMessagesService.getMessage(Msg.AMBARI_CLUSTER_MANUALRECOVERY_REQUESTED.code(), Collections.singletonList(repairedHostGroups));
LOGGER.info(recoveryMessage);
eventService.fireCloudbreakEvent(stack.getId(), "RECOVERY", recoveryMessage);
}
}
Aggregations