Search in sources :

Example 1 with StackImageService

use of com.sequenceiq.cloudbreak.service.stack.StackImageService in project cloudbreak by hortonworks.

the class ClusterUpgradeActions method clusterUpgradeFinished.

@Bean(name = "CLUSTER_UPGRADE_FINISHED_STATE")
public Action<?, ?> clusterUpgradeFinished() {
    return new AbstractClusterUpgradeAction<>(ClusterUpgradeSuccess.class) {

        @Inject
        private StackImageService stackImageService;

        @Override
        protected ClusterUpgradeContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, ClusterUpgradeSuccess payload) {
            return ClusterUpgradeContext.from(flowParameters, payload);
        }

        @Override
        protected void doExecute(ClusterUpgradeContext context, ClusterUpgradeSuccess payload, Map<Object, Object> variables) {
            StatedImage currentImage = getCurrentImage(variables);
            StatedImage targetImage = getTargetImage(variables);
            clusterUpgradeService.clusterUpgradeFinished(context.getStackId(), currentImage, targetImage);
            stackImageService.removeImageByComponentName(context.getStackId(), TARGET_IMAGE);
            sendEvent(context);
        }

        @Override
        protected Selectable createRequest(ClusterUpgradeContext context) {
            return new StackEvent(ClusterUpgradeEvent.CLUSTER_UPGRADE_FINALIZED_EVENT.event(), context.getStackId());
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeSuccess payload, Optional<ClusterUpgradeContext> flowContext, Exception ex) {
            return null;
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Optional(java.util.Optional) StateContext(org.springframework.statemachine.StateContext) StackImageService(com.sequenceiq.cloudbreak.service.stack.StackImageService) ClusterUpgradeSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeSuccess) Map(java.util.Map) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Bean(org.springframework.context.annotation.Bean)

Aggregations

StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 ClusterUpgradeSuccess (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeSuccess)1 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)1 StackImageService (com.sequenceiq.cloudbreak.service.stack.StackImageService)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1