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