Search in sources :

Example 1 with UpscaleEvent

use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent in project cloudbreak by hortonworks.

the class FreeIpaScalingService method triggerUpscale.

private UpscaleResponse triggerUpscale(UpscaleRequest request, Stack stack, AvailabilityType originalAvailabilityType) {
    Operation operation = startScalingOperation(stack.getAccountId(), request.getEnvironmentCrn(), OperationType.UPSCALE);
    UpscaleEvent upscaleEvent = new UpscaleEvent(UpscaleFlowEvent.UPSCALE_EVENT.event(), stack.getId(), request.getTargetAvailabilityType().getInstanceCount(), false, false, false, operation.getOperationId());
    try {
        LOGGER.info("Trigger upscale flow with event: {}", upscaleEvent);
        FlowIdentifier flowIdentifier = flowManager.notify(UpscaleFlowEvent.UPSCALE_EVENT.event(), upscaleEvent);
        UpscaleResponse response = new UpscaleResponse();
        response.setOperationId(operation.getOperationId());
        response.setOriginalAvailabilityType(originalAvailabilityType);
        response.setTargetAvailabilityType(request.getTargetAvailabilityType());
        response.setFlowIdentifier(flowIdentifier);
        return response;
    } catch (Exception e) {
        String exception = handleFlowException(operation, e, stack);
        throw new BadRequestException(exception);
    }
}
Also used : UpscaleEvent(com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent) UpscaleResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.UpscaleResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Operation(com.sequenceiq.freeipa.entity.Operation) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException)

Example 2 with UpscaleEvent

use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent in project cloudbreak by hortonworks.

the class RepairFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(RepairEvent event) {
    Set<String> terminatedOrRemovedInstanceIdsSet = new HashSet<>(event.getRepairInstanceIds());
    terminatedOrRemovedInstanceIdsSet.addAll(event.getAdditionalTerminatedInstanceIds());
    ArrayList<String> terminatedOrRemovedInstanceIds = new ArrayList<>(terminatedOrRemovedInstanceIdsSet);
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new ChangePrimaryGatewayEvent(ChangePrimaryGatewayFlowEvent.CHANGE_PRIMARY_GATEWAY_EVENT.event(), event.getResourceId(), terminatedOrRemovedInstanceIds, Boolean.FALSE, event.getOperationId(), event.accepted()));
    flowEventChain.add(new DownscaleEvent(DownscaleFlowEvent.DOWNSCALE_EVENT.event(), event.getResourceId(), terminatedOrRemovedInstanceIds, event.getInstanceCountByGroup(), true, true, false, event.getOperationId()));
    flowEventChain.add(new UpscaleEvent(UpscaleFlowEvent.UPSCALE_EVENT.event(), event.getResourceId(), event.getInstanceCountByGroup(), true, true, false, event.getOperationId()));
    flowEventChain.add(new ChangePrimaryGatewayEvent(ChangePrimaryGatewayFlowEvent.CHANGE_PRIMARY_GATEWAY_EVENT.event(), event.getResourceId(), terminatedOrRemovedInstanceIds, true, event.getOperationId()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : DownscaleEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpscaleEvent(com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent) ArrayList(java.util.ArrayList) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) HashSet(java.util.HashSet) ChangePrimaryGatewayEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayEvent)

Example 3 with UpscaleEvent

use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent in project cloudbreak by hortonworks.

the class UpgradeFlowEventChainFactory method createScaleEventsForNonPgwInstances.

private List<Selectable> createScaleEventsForNonPgwInstances(UpgradeEvent event, int instanceCountForUpscale, int instanceCountForDownscale) {
    LOGGER.debug("Add scale events for non primary gateway instances. upscale count: [{}] downscale count: [{}]", instanceCountForUpscale, instanceCountForDownscale);
    List<Selectable> events = new ArrayList<>(event.getInstanceIds().size() * 2);
    for (String instanceId : event.getInstanceIds()) {
        LOGGER.debug("Add upscale and downscale event for [{}]", instanceId);
        events.add(new UpscaleEvent(UpscaleFlowEvent.UPSCALE_EVENT.event(), event.getResourceId(), instanceCountForUpscale, Boolean.FALSE, true, false, event.getOperationId()));
        events.add(new DownscaleEvent(DownscaleFlowEvent.DOWNSCALE_EVENT.event(), event.getResourceId(), Lists.newArrayList(instanceId), instanceCountForDownscale, false, true, false, event.getOperationId()));
    }
    return events;
}
Also used : DownscaleEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpscaleEvent(com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent) ArrayList(java.util.ArrayList)

Example 4 with UpscaleEvent

use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent in project cloudbreak by hortonworks.

the class UpgradeFlowEventChainFactory method createScaleEventsAndChangePgw.

private List<Selectable> createScaleEventsAndChangePgw(UpgradeEvent event, int instanceCountForUpscale, int instanceCountForDownscale) {
    LOGGER.debug("Add events for primary gateway with id: [{}]", event.getPrimareGwInstanceId());
    List<Selectable> events = new ArrayList<>(PRIMARY_GW_EVENT_COUNT);
    events.add(new UpscaleEvent(UpscaleFlowEvent.UPSCALE_EVENT.event(), event.getResourceId(), instanceCountForUpscale, Boolean.FALSE, true, false, event.getOperationId()));
    ArrayList<String> oldInstances = new ArrayList<>(event.getInstanceIds());
    oldInstances.add(event.getPrimareGwInstanceId());
    events.add(new ChangePrimaryGatewayEvent(ChangePrimaryGatewayFlowEvent.CHANGE_PRIMARY_GATEWAY_EVENT.event(), event.getResourceId(), oldInstances, Boolean.FALSE, event.getOperationId()));
    events.add(new DownscaleEvent(DownscaleFlowEvent.DOWNSCALE_EVENT.event(), event.getResourceId(), Lists.newArrayList(event.getPrimareGwInstanceId()), instanceCountForDownscale, false, true, false, event.getOperationId()));
    return events;
}
Also used : DownscaleEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpscaleEvent(com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent) ArrayList(java.util.ArrayList) ChangePrimaryGatewayEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayEvent)

Example 5 with UpscaleEvent

use of com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent in project cloudbreak by hortonworks.

the class FreeIpaUpscaleActions method startingAction.

@Bean(name = "UPSCALE_STARTING_STATE")
public Action<?, ?> startingAction() {
    return new AbstractUpscaleAction<>(UpscaleEvent.class) {

        @Override
        protected void doExecute(StackContext context, UpscaleEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            String operationId = payload.getOperationId();
            setOperationId(variables, operationId);
            setInstanceCountByGroup(variables, payload.getInstanceCountByGroup());
            setRepair(variables, payload.isRepair());
            setChainedAction(variables, payload.isChained());
            setFinalChain(variables, payload.isFinalChain());
            LOGGER.info("Starting upscale {}", payload);
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Starting upscale");
            sendEvent(context, UPSCALE_STARTING_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) UpscaleEvent(com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Bean(org.springframework.context.annotation.Bean)

Aggregations

UpscaleEvent (com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent)6 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)4 DownscaleEvent (com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent)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 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 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 UpscaleResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.UpscaleResponse)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