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));
}
}
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);
}
};
}
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());
}
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);
}
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);
}
Aggregations