Search in sources :

Example 1 with ClusterUpgradeExistingUpgradeCommandValidationEvent

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);
        }
    }
}
Also used : ClusterUpgradeExistingUpgradeCommandValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent) ClusterManagerCommand(com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 2 with ClusterUpgradeExistingUpgradeCommandValidationEvent

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;
}
Also used : ClusterUpgradeExistingUpgradeCommandValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 3 with ClusterUpgradeExistingUpgradeCommandValidationEvent

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);
        }
    };
}
Also used : ClusterUpgradeExistingUpgradeCommandValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent) Optional(java.util.Optional) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) ClusterUpgradeUpdateCheckFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeUpdateCheckFinishedEvent) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Map(java.util.Map) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent) ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent) Bean(org.springframework.context.annotation.Bean)

Aggregations

Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 ClusterUpgradeExistingUpgradeCommandValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent)3 ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)1 ClusterManagerCommand (com.sequenceiq.cloudbreak.cluster.model.ClusterManagerCommand)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1 ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent)1 ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent)1 ClusterUpgradeUpdateCheckFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeUpdateCheckFinishedEvent)1 ClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)1 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1