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