Search in sources :

Example 6 with DownscaleEvent

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method startingDownscaleAction.

@Bean(name = "STARTING_DOWNSCALE_STATE")
public Action<?, ?> startingDownscaleAction() {
    return new AbstractDownscaleAction<>(DownscaleEvent.class) {

        @Override
        protected void doExecute(StackContext context, DownscaleEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            List<String> instanceIds = payload.getInstanceIds();
            setInstanceIds(variables, instanceIds);
            String operationId = payload.getOperationId();
            setOperationId(variables, operationId);
            List<String> fqdns = getInstanceMetadataFromStack(stack, instanceIds).stream().map(InstanceMetaData::getDiscoveryFQDN).filter(Objects::nonNull).collect(Collectors.toList());
            setDownscaleHosts(variables, fqdns);
            setRepair(variables, payload.isRepair());
            setChainedAction(variables, payload.isChained());
            setFinalChain(variables, payload.isFinalChain());
            setInstanceCountByGroup(variables, payload.getInstanceCountByGroup());
            LOGGER.info("Starting downscale {}", payload);
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Starting downscale");
            sendEvent(context, STARTING_DOWNSCALE_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
        }
    };
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) DownscaleEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Aggregations

DownscaleEvent (com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent)6 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)4 UpscaleEvent (com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent)4 ChangePrimaryGatewayEvent (com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayEvent)3 ArrayList (java.util.ArrayList)3 FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)1 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)1 DownscaleResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.DownscaleResponse)1 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)1 Operation (com.sequenceiq.freeipa.entity.Operation)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 SaltUpdateTriggerEvent (com.sequenceiq.freeipa.flow.freeipa.salt.update.SaltUpdateTriggerEvent)1 UpgradeEvent (com.sequenceiq.freeipa.flow.freeipa.upgrade.UpgradeEvent)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)1 ImageChangeEvent (com.sequenceiq.freeipa.flow.stack.image.change.event.ImageChangeEvent)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1