use of com.sequenceiq.flow.core.FlowParameters in project cloudbreak by hortonworks.
the class CertRenewalActions method certRenewFinishedAction.
@Bean(name = "CERT_RENEWAL_FINISHED_STATE")
public Action<?, ?> certRenewFinishedAction() {
return new AbstractSdxAction<>(SdxEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Cert renewal is finished");
certRenewalService.finalizeCertRenewal(payload.getResourceId());
SdxEvent event = new SdxEvent(SdxCertRenewalEvent.CERT_RENEWAL_FINALIZED_EVENT.event(), context);
sendEvent(context, event);
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRenewalFailedEvent(payload, ex.getMessage());
}
};
}
use of com.sequenceiq.flow.core.FlowParameters in project cloudbreak by hortonworks.
the class CertRotationActions method certRotationInProgressAction.
@Bean(name = "CERT_ROTATION_IN_PROGRESS_STATE")
public Action<?, ?> certRotationInProgressAction() {
return new AbstractSdxAction<>(SdxEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) {
LOGGER.info("Cert rotation is in progress. Start waiting to finish");
SdxCertRotationWaitEvent event = new SdxCertRotationWaitEvent(context);
sendEvent(context, event);
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRotationFailedEvent(payload, ex);
}
};
}
use of com.sequenceiq.flow.core.FlowParameters in project cloudbreak by hortonworks.
the class ClusterUpgradeValidationActions method clusterUpgradeValidationFailed.
@Bean(name = "CLUSTER_UPGRADE_VALIDATION_FAILED_STATE")
public Action<?, ?> clusterUpgradeValidationFailed() {
return new AbstractAction<ClusterUpgradeValidationState, ClusterUpgradeValidationStateSelectors, ClusterUpgradeContext, ClusterUpgradeValidationFailureEvent>(ClusterUpgradeValidationFailureEvent.class) {
@Inject
private CloudbreakMessagesService messagesService;
@Inject
private StackUpdater stackUpdater;
@Override
protected ClusterUpgradeContext createFlowContext(FlowParameters flowParameters, StateContext<ClusterUpgradeValidationState, ClusterUpgradeValidationStateSelectors> stateContext, ClusterUpgradeValidationFailureEvent payload) {
StackView stackView = stackService.getViewByIdWithoutAuth(payload.getResourceId());
MDCBuilder.buildMdcContext(stackView);
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return ClusterUpgradeContext.from(flowParameters, payload);
}
@Override
protected void doExecute(ClusterUpgradeContext context, ClusterUpgradeValidationFailureEvent payload, Map<Object, Object> variables) {
String errorMessage = payload.getException().getMessage();
Long resourceId = payload.getResourceId();
LOGGER.debug("Cluster upgrade validation failed with validation error: {}", errorMessage);
ResourceEvent validationFailedResourceEvent = ResourceEvent.CLUSTER_UPGRADE_VALIDATION_FAILED;
cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_FAILED.name(), validationFailedResourceEvent, List.of(errorMessage));
String reason = messagesService.getMessage(validationFailedResourceEvent.getMessage(), List.of(errorMessage));
stackUpdater.updateStackStatus(resourceId, DetailedStackStatus.AVAILABLE, reason);
sendEvent(context, HANDLED_FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(ClusterUpgradeValidationFailureEvent payload, Optional<ClusterUpgradeContext> flowContext, Exception ex) {
LOGGER.warn("No failure payload in case of CLUSTER_UPGRADE_VALIDATION_FAILED_STATE. This should not happen.", ex);
return null;
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<ClusterUpgradeValidationFailureEvent>> payloadConverters) {
payloadConverters.add(new ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent());
}
};
}
use of com.sequenceiq.flow.core.FlowParameters 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);
}
};
}
use of com.sequenceiq.flow.core.FlowParameters 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