Search in sources :

Example 1 with ClusterManagerUpgradeRequest

use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterManagerUpgradeRequest 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 ClusterManagerUpgradeRequest

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

the class ClusterUpgradeActions method upgradeClusterManager.

@Bean(name = "CLUSTER_MANAGER_UPGRADE_STATE")
public Action<?, ?> upgradeClusterManager() {
    return new AbstractClusterUpgradeAction<>(ClusterUpgradeInitSuccess.class) {

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

        @Override
        protected void doExecute(ClusterUpgradeContext context, ClusterUpgradeInitSuccess payload, Map<Object, Object> variables) {
            Image currentImage = getCurrentImage(variables).getImage();
            Image targetImage = getTargetImage(variables).getImage();
            clusterUpgradeService.upgradeClusterManager(context.getStackId());
            Selectable event = new ClusterManagerUpgradeRequest(context.getStackId(), !clusterUpgradeService.isClusterRuntimeUpgradeNeeded(currentImage, targetImage));
            sendEvent(context, event.selector(), event);
        }

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

Aggregations

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