Search in sources :

Example 51 with HostMetadata

use of com.sequenceiq.cloudbreak.domain.HostMetadata in project cloudbreak by hortonworks.

the class ClusterDownscaleService method updateMetadata.

public void updateMetadata(Long stackId, Collection<String> hostNames, String hostGroupName) {
    StackView stackView = stackService.getByIdView(stackId);
    ClusterView clusterView = stackView.getClusterView();
    hostNames.forEach(hn -> {
        HostGroup hostGroup = hostGroupService.getByClusterIdAndName(clusterView.getId(), hostGroupName);
        List<HostMetadata> hostMetaToRemove = hostGroup.getHostMetadata().stream().filter(md -> hostNames.contains(md.getHostName())).collect(Collectors.toList());
        hostGroup.getHostMetadata().removeAll(hostMetaToRemove);
        hostGroupService.save(hostGroup);
    });
    LOGGER.info("Start updating metadata");
    for (String hostName : hostNames) {
        stackService.updateMetaDataStatus(stackView.getId(), hostName, InstanceStatus.DECOMMISSIONED);
    }
    clusterService.updateClusterStatusByStackId(stackView.getId(), AVAILABLE);
    flowMessageService.fireEventAndLog(stackId, Msg.AMBARI_CLUSTER_SCALED_DOWN, AVAILABLE.name());
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) UPDATE_FAILED(com.sequenceiq.cloudbreak.api.model.Status.UPDATE_FAILED) LoggerFactory(org.slf4j.LoggerFactory) Msg(com.sequenceiq.cloudbreak.core.flow2.stack.Msg) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) CloudbreakMessagesService(com.sequenceiq.cloudbreak.service.messages.CloudbreakMessagesService) Inject(javax.inject.Inject) Status(com.sequenceiq.cloudbreak.api.model.Status) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata) Service(org.springframework.stereotype.Service) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Logger(org.slf4j.Logger) AVAILABLE(com.sequenceiq.cloudbreak.api.model.Status.AVAILABLE) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) Collection(java.util.Collection) Set(java.util.Set) FlowMessageService(com.sequenceiq.cloudbreak.core.flow2.stack.FlowMessageService) NotEnoughNodeException(com.sequenceiq.cloudbreak.service.cluster.NotEnoughNodeException) Collectors(java.util.stream.Collectors) StackUpdater(com.sequenceiq.cloudbreak.repository.StackUpdater) List(java.util.List) ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) CollectionUtils(org.springframework.util.CollectionUtils) InstanceStatus(com.sequenceiq.cloudbreak.api.model.InstanceStatus) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) CloudbreakEventService(com.sequenceiq.cloudbreak.service.events.CloudbreakEventService) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 52 with HostMetadata

use of com.sequenceiq.cloudbreak.domain.HostMetadata in project cloudbreak by hortonworks.

the class StackRepairService method groupInstancesByHostGroups.

private UnhealthyInstances groupInstancesByHostGroups(Stack stack, Iterable<String> unhealthyInstanceIds) {
    UnhealthyInstances unhealthyInstances = new UnhealthyInstances();
    for (String instanceId : unhealthyInstanceIds) {
        InstanceMetaData instanceMetaData = instanceMetaDataRepository.findByInstanceId(stack.getId(), instanceId);
        HostMetadata hostMetadata = hostMetadataRepository.findHostInClusterByName(stack.getCluster().getId(), instanceMetaData.getDiscoveryFQDN());
        String hostGroupName = hostMetadata.getHostGroup().getName();
        unhealthyInstances.addInstance(instanceId, hostGroupName);
    }
    return unhealthyInstances;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Aggregations

HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)52 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)20 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)17 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)16 HashSet (java.util.HashSet)16 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)15 Stack (com.sequenceiq.cloudbreak.domain.Stack)14 Test (org.junit.Test)13 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)12 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 List (java.util.List)10 Map (java.util.Map)10 Status (com.sequenceiq.cloudbreak.api.model.Status)8 Collections.singletonMap (java.util.Collections.singletonMap)8 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)7 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)7 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)6 LinkedHashMap (java.util.LinkedHashMap)5 Set (java.util.Set)5