use of com.sequenceiq.cloudbreak.polling.PollingResult.SUCCESS in project cloudbreak by hortonworks.
the class RemoveHostsHandler method removeHostsFromOrchestrator.
private PollingResult removeHostsFromOrchestrator(Stack stack, List<String> hostNames, HostOrchestrator hostOrchestrator, List<GatewayConfig> allGatewayConfigs) throws CloudbreakException {
LOGGER.debug("Remove hosts from orchestrator: {}", hostNames);
try {
Map<String, String> removeNodePrivateIPsByFQDN = new HashMap<>();
stack.getNotTerminatedInstanceMetaDataSet().stream().filter(instanceMetaData -> instanceMetaData.getDiscoveryFQDN() != null).filter(instanceMetaData -> hostNames.stream().anyMatch(hn -> hn.equals(instanceMetaData.getDiscoveryFQDN()))).forEach(instanceMetaData -> removeNodePrivateIPsByFQDN.put(instanceMetaData.getDiscoveryFQDN(), instanceMetaData.getPrivateIp()));
Set<Node> remainingNodes = stackUtil.collectNodes(stack).stream().filter(node -> !removeNodePrivateIPsByFQDN.containsValue(node.getPrivateIp())).collect(Collectors.toSet());
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId());
hostOrchestrator.tearDown(stack, allGatewayConfigs, removeNodePrivateIPsByFQDN, remainingNodes, exitCriteriaModel);
} catch (CloudbreakOrchestratorException e) {
LOGGER.error("Failed to delete orchestrator components while decommissioning: ", e);
throw new CloudbreakException("Removing selected nodes from master node failed, " + "please check if selected nodes are still reachable from master node using terminal and " + "nodes are in sync between CM, CDP and provider side or you can remove selected nodes forcefully.");
}
return SUCCESS;
}
use of com.sequenceiq.cloudbreak.polling.PollingResult.SUCCESS in project cloudbreak by hortonworks.
the class RemoveHostsHandler method removeHostsFromOrchestrator.
private PollingResult removeHostsFromOrchestrator(Stack stack, List<String> hostNames) throws CloudbreakException {
LOGGER.debug("Remove hosts from orchestrator: [{}]", hostNames);
try {
Map<String, String> removeNodePrivateIPsByFQDN = stack.getAllInstanceMetaDataList().stream().filter(instanceMetaData -> Objects.nonNull(instanceMetaData.getDiscoveryFQDN())).filter(instanceMetaData -> hostNames.stream().anyMatch(hn -> hn.equals(instanceMetaData.getDiscoveryFQDN()))).collect(Collectors.toMap(instanceMetaData -> instanceMetaData.getDiscoveryFQDN(), instanceMeataData -> instanceMeataData.getPrivateIp()));
Set<InstanceMetaData> remainingInstanceMetaDatas = stack.getNotDeletedInstanceMetaDataList().stream().filter(instanceMetaData -> !shouldRemove(instanceMetaData, removeNodePrivateIPsByFQDN)).collect(Collectors.toSet());
Set<InstanceMetaData> invalidInstanceMetadata = remainingInstanceMetaDatas.stream().filter(instanceMetaData -> Objects.isNull(instanceMetaData.getDiscoveryFQDN())).collect(Collectors.toSet());
Set<InstanceMetaData> validRemainingNodes = remainingInstanceMetaDatas.stream().filter(instanceMetaData -> Objects.nonNull(instanceMetaData.getDiscoveryFQDN())).collect(Collectors.toSet());
Set<Node> remainingNodes = validRemainingNodes.stream().map(im -> new Node(im.getPrivateIp(), im.getPublicIp(), im.getInstanceId(), im.getInstanceGroup().getTemplate().getInstanceType(), im.getDiscoveryFQDN(), im.getInstanceGroup().getGroupName())).collect(Collectors.toSet());
List<GatewayConfig> remainingGatewayConfigs = gatewayConfigService.getGatewayConfigs(stack, validRemainingNodes);
LOGGER.debug("Tearing down [{}]. The following were dropped because they did not contain a FQDN [{}]. The remaining nodes are [{}].", removeNodePrivateIPsByFQDN, invalidInstanceMetadata, remainingNodes);
hostOrchestrator.tearDown(stack, remainingGatewayConfigs, removeNodePrivateIPsByFQDN, remainingNodes, new StackBasedExitCriteriaModel(stack.getId()));
} catch (CloudbreakOrchestratorException e) {
LOGGER.info("Failed to delete orchestrator components while decommissioning: ", e);
throw new CloudbreakException("Failed to delete orchestrator components while decommissioning: ", e);
}
return SUCCESS;
}
Aggregations