use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeExistingUpgradeCommandValidationEvent> event) {
LOGGER.debug("Accepting Cluster upgrade existing upgradeCDH command validation event.");
ClusterUpgradeExistingUpgradeCommandValidationEvent request = event.getData();
Image targetImage = request.getImage();
Long stackId = request.getResourceId();
Stack stack = getStack(stackId);
ClusterApi connector = clusterApiConnectors.getConnector(stack);
Optional<ClusterManagerCommand> optionalUpgradeCommand = connector.clusterStatusService().findCommand(stack, ClusterCommandType.UPGRADE_CLUSTER);
if (optionalUpgradeCommand.isEmpty()) {
LOGGER.debug("There is no existing upgradeCDH command, validation passed successfully");
return new ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(stackId);
} else {
ClusterManagerCommand upgradeCommand = optionalUpgradeCommand.get();
if (upgradeCommand.getActive() || (!upgradeCommand.getSuccess() && upgradeCommand.getRetryable())) {
return validateIfExistingRuntimeMatchesTargetRuntime(stack, connector, targetImage);
} else {
LOGGER.debug("There is no retryable upgradeCDH command, validation passed successfully");
return new ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(stackId);
}
}
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method getHandlerEvent.
private HandlerEvent<ClusterUpgradeExistingUpgradeCommandValidationEvent> getHandlerEvent(String buildNumber) {
Image targetImage = mock(Image.class);
Map<String, String> packageVersions = new java.util.HashMap<>();
packageVersions.put(ImagePackageVersion.CDH_BUILD_NUMBER.getKey(), buildNumber);
packageVersions.put(ImagePackageVersion.STACK.getKey(), STACK_VERSION);
when(targetImage.getPackageVersions()).thenReturn(packageVersions);
ClusterUpgradeExistingUpgradeCommandValidationEvent clusterUpgradeImageValidationEvent = new ClusterUpgradeExistingUpgradeCommandValidationEvent(1L, targetImage);
HandlerEvent<ClusterUpgradeExistingUpgradeCommandValidationEvent> handlerEvent = mock(HandlerEvent.class);
when(handlerEvent.getData()).thenReturn(clusterUpgradeImageValidationEvent);
return handlerEvent;
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeValidationActions method clusterUpgradeExistingUpgradeCommandValidation.
@Bean(name = "CLUSTER_UPGRADE_EXISTING_UPGRADE_COMMAND_VALIDATION_STATE")
public Action<?, ?> clusterUpgradeExistingUpgradeCommandValidation() {
return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeUpdateCheckFinishedEvent.class) {
@Override
protected void doExecute(StackContext context, ClusterUpgradeUpdateCheckFinishedEvent payload, Map<Object, Object> variables) {
LOGGER.info("Starting the validation if an existing, retryable upgradeCDH command exists...");
Image targetImage = (Image) variables.get(TARGET_IMAGE);
ClusterUpgradeExistingUpgradeCommandValidationEvent event = new ClusterUpgradeExistingUpgradeCommandValidationEvent(payload.getResourceId(), targetImage);
sendEvent(context, event.selector(), event);
}
@Override
protected Object getFailurePayload(ClusterUpgradeUpdateCheckFinishedEvent payload, Optional<StackContext> flowContext, Exception ex) {
return new ClusterUpgradeValidationFailureEvent(payload.getResourceId(), ex);
}
};
}
Aggregations