Search in sources :

Example 1 with ClusterUpgradeInitSuccess

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

Example 2 with ClusterUpgradeInitSuccess

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

the class ClusterUpgradeInitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeInitRequest> event) {
    LOGGER.debug("Accepting Cluster Manager parcel deactivation event..");
    Stack stack = stackService.getByIdWithClusterInTransaction(event.getData().getResourceId());
    ClusterUpgradeInitRequest request = event.getData();
    Selectable result;
    try {
        Set<ClusterComponent> componentsByBlueprint = parcelService.getParcelComponentsByBlueprint(stack);
        parcelService.removeUnusedParcelComponents(stack, componentsByBlueprint);
        clusterApiConnectors.getConnector(stack).downloadAndDistributeParcels(componentsByBlueprint, request.isPatchUpgrade());
        result = new ClusterUpgradeInitSuccess(request.getResourceId());
    } catch (Exception e) {
        LOGGER.error("Cluster Manager parcel deactivation failed", e);
        result = new ClusterUpgradeFailedEvent(request.getResourceId(), e, DetailedStackStatus.CLUSTER_UPGRADE_INIT_FAILED);
    }
    return result;
}
Also used : ClusterUpgradeInitRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeInitRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ClusterUpgradeInitSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeInitSuccess) ClusterUpgradeFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeFailedEvent) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

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