Search in sources :

Example 1 with ClusterUpgradeTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent in project cloudbreak by hortonworks.

the class UpgradeDatalakeFlowEventChainFactory method addUpgradeValidationToChain.

private void addUpgradeValidationToChain(ClusterUpgradeTriggerEvent event, Queue<Selectable> flowEventChain) {
    if (upgradeValidationEnabled) {
        Stack stack = stackService.getById(event.getResourceId());
        boolean lockComponents = lockedComponentService.isComponentsLocked(stack, event.getImageId());
        flowEventChain.add(new ClusterUpgradeValidationTriggerEvent(event.getResourceId(), event.accepted(), event.getImageId(), lockComponents));
    }
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ClusterUpgradeValidationTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationTriggerEvent)

Example 2 with ClusterUpgradeTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent in project cloudbreak by hortonworks.

the class ClusterUpgradeActions method initClusterUpgrade.

@Bean(name = "CLUSTER_UPGRADE_INIT_STATE")
public Action<?, ?> initClusterUpgrade() {
    return new AbstractClusterUpgradeAction<>(ClusterUpgradeTriggerEvent.class) {

        @Inject
        private ImageComponentUpdaterService imageComponentUpdaterService;

        @Inject
        private ClusterUpgradeTargetImageService clusterUpgradeTargetImageService;

        @Override
        protected void doExecute(ClusterUpgradeContext context, ClusterUpgradeTriggerEvent payload, Map<Object, Object> variables) {
            try {
                UpgradeImageInfo images = imageComponentUpdaterService.updateForUpgrade(payload.getImageId(), payload.getResourceId());
                variables.put(CURRENT_IMAGE, images.getCurrentStatedImage());
                variables.put(TARGET_IMAGE, images.getTargetStatedImage());
                clusterUpgradeTargetImageService.saveImage(context.getStackId(), images.getTargetStatedImage());
                clusterUpgradeService.initUpgradeCluster(context.getStackId(), getTargetImage(variables));
                Selectable event = new ClusterUpgradeInitRequest(context.getStackId(), isPatchUpgrade(images.getCurrentStatedImage().getImage(), images.getTargetStatedImage().getImage()));
                sendEvent(context, event.selector(), event);
            } catch (Exception e) {
                LOGGER.error("Error during updating cluster components with image id: [{}]", payload.getImageId(), e);
                ClusterUpgradeFailedEvent upgradeFailedEvent = new ClusterUpgradeFailedEvent(payload.getResourceId(), e, DetailedStackStatus.CLUSTER_MANAGER_UPGRADE_FAILED);
                sendEvent(context, upgradeFailedEvent);
            }
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeTriggerEvent payload, Optional<ClusterUpgradeContext> flowContext, Exception ex) {
            return ClusterUpgradeFailedEvent.from(payload, ex, DetailedStackStatus.CLUSTER_MANAGER_UPGRADE_FAILED);
        }

        @Override
        protected ClusterUpgradeContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, ClusterUpgradeTriggerEvent payload) {
            return ClusterUpgradeContext.from(flowParameters, payload);
        }
    };
}
Also used : Optional(java.util.Optional) ClusterUpgradeTargetImageService(com.sequenceiq.cloudbreak.service.image.ClusterUpgradeTargetImageService) StateContext(org.springframework.statemachine.StateContext) ClusterUpgradeFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeFailedEvent) ImageComponentUpdaterService(com.sequenceiq.cloudbreak.service.upgrade.ImageComponentUpdaterService) ClusterUpgradeInitRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeInitRequest) FlowParameters(com.sequenceiq.flow.core.FlowParameters) ClusterUpgradeTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeImageInfo(com.sequenceiq.cloudbreak.service.upgrade.UpgradeImageInfo) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 3 with ClusterUpgradeTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent in project cloudbreak by hortonworks.

the class UpgradeDistroxFlowEventChainFactoryTest method assertUpgradeEvent.

private void assertUpgradeEvent(FlowTriggerEventQueue flowChainQueue) {
    Selectable upgradeEvent = flowChainQueue.getQueue().remove();
    assertEquals(CLUSTER_UPGRADE_INIT_EVENT.event(), upgradeEvent.selector());
    assertEquals(STACK_ID, upgradeEvent.getResourceId());
    assertTrue(upgradeEvent instanceof ClusterUpgradeTriggerEvent);
    assertEquals(imageChangeDto.getImageId(), ((ClusterUpgradeTriggerEvent) upgradeEvent).getImageId());
}
Also used : ClusterUpgradeTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable)

Example 4 with ClusterUpgradeTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent in project cloudbreak by hortonworks.

the class UpgradeDatalakeFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(ClusterUpgradeTriggerEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    addUpgradeValidationToChain(event, flowEventChain);
    flowEventChain.add(new StackEvent(SaltUpdateEvent.SALT_UPDATE_EVENT.event(), event.getResourceId(), event.accepted()));
    flowEventChain.add(new ClusterUpgradeTriggerEvent(CLUSTER_UPGRADE_INIT_EVENT.event(), event.getResourceId(), event.accepted(), event.getImageId()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) ClusterUpgradeTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 5 with ClusterUpgradeTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent in project cloudbreak by hortonworks.

the class UpgradeDistroxFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(DistroXUpgradeTriggerEvent event) {
    LOGGER.debug("Creating flow trigger event queue for distrox upgrade with event {}", event);
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    createUpgradeValidationEvent(event).ifPresent(flowEventChain::add);
    flowEventChain.add(new StackEvent(SaltUpdateEvent.SALT_UPDATE_EVENT.event(), event.getResourceId(), event.accepted()));
    flowEventChain.add(new ClusterUpgradeTriggerEvent(CLUSTER_UPGRADE_INIT_EVENT.event(), event.getResourceId(), event.accepted(), event.getImageChangeDto().getImageId()));
    flowEventChain.add(new StackImageUpdateTriggerEvent(FlowChainTriggers.STACK_IMAGE_UPDATE_TRIGGER_EVENT, event.getImageChangeDto()));
    if (event.isReplaceVms()) {
        Map<String, List<String>> nodeMap = getReplaceableInstancesByHostgroup(event);
        flowEventChain.add(new ClusterRepairTriggerEvent(FlowChainTriggers.CLUSTER_REPAIR_TRIGGER_EVENT, event.getResourceId(), nodeMap, true, event.getTriggeredStackVariant()));
    }
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : ClusterRepairTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterRepairTriggerEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) ClusterUpgradeTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) StackImageUpdateTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent)

Aggregations

Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)4 ClusterUpgradeTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterUpgradeTriggerEvent)4 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)2 FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 ClusterUpgradeValidationTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationTriggerEvent)1 StackImageUpdateTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 ClusterUpgradeFailedEvent (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeFailedEvent)1 ClusterUpgradeInitRequest (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeInitRequest)1 ClusterRepairTriggerEvent (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterRepairTriggerEvent)1 ClusterUpgradeTargetImageService (com.sequenceiq.cloudbreak.service.image.ClusterUpgradeTargetImageService)1 ImageComponentUpdaterService (com.sequenceiq.cloudbreak.service.upgrade.ImageComponentUpdaterService)1 UpgradeImageInfo (com.sequenceiq.cloudbreak.service.upgrade.UpgradeImageInfo)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors.toList (java.util.stream.Collectors.toList)1 Bean (org.springframework.context.annotation.Bean)1