Search in sources :

Example 1 with STACK_DOWNSCALE_SUCCESS

use of com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_DOWNSCALE_SUCCESS in project cloudbreak by hortonworks.

the class StackDownscaleService method finishStackDownscale.

public void finishStackDownscale(StackScalingFlowContext context, Collection<Long> privateIds) throws TransactionExecutionException {
    Stack stack = context.getStack();
    stackScalingService.updateInstancesToTerminated(privateIds, stack.getId());
    List<InstanceMetaData> instanceMetaDatas = stack.getInstanceGroups().stream().flatMap(instanceGroup -> instanceGroup.getInstanceMetaDataSet().stream()).filter(im -> privateIds.contains(im.getPrivateId())).collect(toList());
    if (context.isRepair()) {
        fillDiscoveryFQDNForRepair(stack, instanceMetaDatas);
    }
    cleanupDnsRecords(stack, instanceMetaDatas);
    List<String> deletedInstanceIds = instanceMetaDatas.stream().map(instanceMetaData -> instanceMetaData.getInstanceId() != null ? instanceMetaData.getInstanceId() : instanceMetaData.getPrivateId().toString()).collect(Collectors.toList());
    stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.DOWNSCALE_COMPLETED, String.format("Downscale of the cluster infrastructure finished successfully. Terminated node(s): %s", deletedInstanceIds));
    flowMessageService.fireEventAndLog(stack.getId(), AVAILABLE.name(), STACK_DOWNSCALE_SUCCESS, String.join(",", deletedInstanceIds));
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Resource(com.sequenceiq.cloudbreak.domain.Resource) AVAILABLE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE) STACK_DOWNSCALE_INSTANCES(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_DOWNSCALE_INSTANCES) LoggerFactory(org.slf4j.LoggerFactory) CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Inject(javax.inject.Inject) ResourceService(com.sequenceiq.cloudbreak.service.resource.ResourceService) UPDATE_IN_PROGRESS(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_IN_PROGRESS) Service(org.springframework.stereotype.Service) CloudbreakFlowMessageService(com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService) StackUpdater(com.sequenceiq.cloudbreak.service.StackUpdater) InstanceMetadataProcessor(com.sequenceiq.cloudbreak.service.freeipa.InstanceMetadataProcessor) UPDATE_FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_FAILED) Logger(org.slf4j.Logger) ResourceAttributeUtil(com.sequenceiq.cloudbreak.cluster.util.ResourceAttributeUtil) Collection(java.util.Collection) StackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent) StackFailureContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackFailureContext) Set(java.util.Set) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Collectors(java.util.stream.Collectors) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) STACK_DOWNSCALE_FAILED(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_DOWNSCALE_FAILED) StringUtils(com.amazonaws.util.StringUtils) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) STACK_DOWNSCALE_SUCCESS(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_DOWNSCALE_SUCCESS) Optional(java.util.Optional) FreeIpaCleanupService(com.sequenceiq.cloudbreak.service.freeipa.FreeIpaCleanupService) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) StackScalingService(com.sequenceiq.cloudbreak.service.stack.flow.StackScalingService) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

StringUtils (com.amazonaws.util.StringUtils)1 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 AVAILABLE (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE)1 UPDATE_FAILED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_FAILED)1 UPDATE_IN_PROGRESS (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_IN_PROGRESS)1 VolumeSetAttributes (com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes)1 ResourceAttributeUtil (com.sequenceiq.cloudbreak.cluster.util.ResourceAttributeUtil)1 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)1 StackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent)1 CloudbreakFlowMessageService (com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService)1 StackFailureContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackFailureContext)1 Resource (com.sequenceiq.cloudbreak.domain.Resource)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)1 STACK_DOWNSCALE_FAILED (com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_DOWNSCALE_FAILED)1 STACK_DOWNSCALE_INSTANCES (com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_DOWNSCALE_INSTANCES)1 STACK_DOWNSCALE_SUCCESS (com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_DOWNSCALE_SUCCESS)1 CloudbreakRuntimeException (com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException)1 StackUpdater (com.sequenceiq.cloudbreak.service.StackUpdater)1 FreeIpaCleanupService (com.sequenceiq.cloudbreak.service.freeipa.FreeIpaCleanupService)1