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