Search in sources :

Example 1 with ClusterManagerUpgradeSuccess

use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterManagerUpgradeSuccess in project cloudbreak by hortonworks.

the class ClusterManagerUpgradeHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterManagerUpgradeRequest> event) {
    LOGGER.debug("Accepting Cluster Manager upgrade event..");
    ClusterManagerUpgradeRequest request = event.getData();
    Selectable result;
    try {
        clusterManagerUpgradeService.upgradeClusterManager(request.getResourceId(), request.isRuntimeServicesStartNeeded());
        result = new ClusterManagerUpgradeSuccess(request.getResourceId());
    } catch (Exception e) {
        LOGGER.info("Cluster Manager upgrade event failed", e);
        result = new ClusterUpgradeFailedEvent(request.getResourceId(), e, DetailedStackStatus.CLUSTER_MANAGER_UPGRADE_FAILED);
    }
    return result;
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterManagerUpgradeRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterManagerUpgradeRequest) ClusterUpgradeFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeFailedEvent) ClusterManagerUpgradeSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterManagerUpgradeSuccess)

Example 2 with ClusterManagerUpgradeSuccess

use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterManagerUpgradeSuccess in project cloudbreak by hortonworks.

the class ClusterUpgradeActions method upgradeCluster.

@Bean(name = "CLUSTER_UPGRADE_STATE")
public Action<?, ?> upgradeCluster() {
    return new AbstractClusterUpgradeAction<>(ClusterManagerUpgradeSuccess.class) {

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

        @Override
        protected void doExecute(ClusterUpgradeContext context, ClusterManagerUpgradeSuccess payload, Map<Object, Object> variables) {
            Image currentImage = getCurrentImage(variables).getImage();
            Image targetImage = getTargetImage(variables).getImage();
            boolean clusterRuntimeUpgradeNeeded = clusterUpgradeService.upgradeCluster(context.getStackId(), currentImage, targetImage);
            Selectable event;
            if (clusterRuntimeUpgradeNeeded) {
                event = new ClusterUpgradeRequest(context.getStackId(), isPatchUpgrade(currentImage, targetImage));
            } else {
                event = new ClusterUpgradeSuccess(context.getStackId());
            }
            sendEvent(context, event.selector(), event);
        }

        @Override
        protected Object getFailurePayload(ClusterManagerUpgradeSuccess payload, Optional<ClusterUpgradeContext> flowContext, Exception ex) {
            return ClusterUpgradeFailedEvent.from(payload, ex, DetailedStackStatus.CLUSTER_UPGRADE_FAILED);
        }
    };
}
Also used : Optional(java.util.Optional) StateContext(org.springframework.statemachine.StateContext) ClusterUpgradeRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeRequest) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) ClusterUpgradeSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeSuccess) FlowParameters(com.sequenceiq.flow.core.FlowParameters) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterManagerUpgradeSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterManagerUpgradeSuccess) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)2 ClusterManagerUpgradeSuccess (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterManagerUpgradeSuccess)2 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)1 ClusterManagerUpgradeRequest (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterManagerUpgradeRequest)1 ClusterUpgradeFailedEvent (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeFailedEvent)1 ClusterUpgradeRequest (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeRequest)1 ClusterUpgradeSuccess (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeSuccess)1 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)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