Search in sources :

Example 1 with ClusterUpgradeValidationFinishedEvent

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent in project cloudbreak by hortonworks.

the class ClusterUpgradeValidationActions method clusterUpgradeValidationFinished.

@Bean(name = "CLUSTER_UPGRADE_VALIDATION_FINISHED_STATE")
public Action<?, ?> clusterUpgradeValidationFinished() {
    return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeValidationFinishedEvent.class) {

        @Override
        protected void doExecute(StackContext context, ClusterUpgradeValidationFinishedEvent payload, Map<Object, Object> variables) {
            Long resourceId = payload.getResourceId();
            Exception exception = payload.getException();
            if (exception == null) {
                LOGGER.info("Cluster upgrade validation finished successfully");
                cloudbreakEventService.fireCloudbreakEvent(resourceId, AVAILABLE.name(), ResourceEvent.CLUSTER_UPGRADE_VALIDATION_FINISHED);
            } else {
                LOGGER.info("Cluster upgrade validation finished due to an error", exception);
                cloudbreakEventService.fireCloudbreakEvent(resourceId, AVAILABLE.name(), ResourceEvent.CLUSTER_UPGRADE_VALIDATION_SKIPPED, Collections.singletonList(exception.getMessage()));
            }
            ClusterUpgradeValidationFinalizeEvent event = new ClusterUpgradeValidationFinalizeEvent(payload.getResourceId());
            sendEvent(context, event);
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeValidationFinishedEvent payload, Optional<StackContext> flowContext, Exception ex) {
            return new ClusterUpgradeValidationFinishedEvent(payload.getResourceId(), ex);
        }
    };
}
Also used : Optional(java.util.Optional) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) ClusterUpgradeValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent) ClusterUpgradeValidationFinalizeEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinalizeEvent) Map(java.util.Map) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Bean(org.springframework.context.annotation.Bean)

Example 2 with ClusterUpgradeValidationFinishedEvent

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent in project cloudbreak by hortonworks.

the class ClusterUpgradeValidationActions method clusterUpgradeServiceValidation.

@Bean(name = "CLUSTER_UPGRADE_SERVICE_VALIDATION_STATE")
public Action<?, ?> clusterUpgradeServiceValidation() {
    return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeFreeIpaStatusValidationFinishedEvent.class) {

        @Override
        protected void doExecute(StackContext context, ClusterUpgradeFreeIpaStatusValidationFinishedEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Starting to validate services.");
            boolean lockComponents = (Boolean) variables.get(LOCK_COMPONENTS);
            ClusterUpgradeServiceValidationEvent event = new ClusterUpgradeServiceValidationEvent(payload.getResourceId(), lockComponents);
            sendEvent(context, event.selector(), event);
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeFreeIpaStatusValidationFinishedEvent payload, Optional<StackContext> flowContext, Exception ex) {
            return new ClusterUpgradeValidationFinishedEvent(payload.getResourceId(), ex);
        }
    };
}
Also used : Optional(java.util.Optional) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) ClusterUpgradeValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent) ClusterUpgradeFreeIpaStatusValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationFinishedEvent) ClusterUpgradeServiceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeServiceValidationEvent) Map(java.util.Map) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Bean(org.springframework.context.annotation.Bean)

Example 3 with ClusterUpgradeValidationFinishedEvent

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent in project cloudbreak by hortonworks.

the class ClusterUpgradeValidationActions method initClusterUpgradeValidation.

@Bean(name = "CLUSTER_UPGRADE_VALIDATION_INIT_STATE")
public Action<?, ?> initClusterUpgradeValidation() {
    return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeValidationTriggerEvent.class) {

        @Override
        protected void doExecute(StackContext context, ClusterUpgradeValidationTriggerEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Starting cluster upgrade validation flow. Target image: {}", payload.getImageId());
            cloudbreakEventService.fireCloudbreakEvent(payload.getResourceId(), UPDATE_IN_PROGRESS.name(), ResourceEvent.CLUSTER_UPGRADE_VALIDATION_STARTED);
            variables.put(LOCK_COMPONENTS, payload.isLockComponents());
            ClusterUpgradeValidationEvent event = new ClusterUpgradeValidationEvent(START_CLUSTER_UPGRADE_IMAGE_VALIDATION_EVENT.name(), payload.getResourceId(), payload.getImageId());
            sendEvent(context, event.selector(), event);
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeValidationTriggerEvent payload, Optional<StackContext> flowContext, Exception ex) {
            return new ClusterUpgradeValidationFinishedEvent(payload.getResourceId(), ex);
        }
    };
}
Also used : ClusterUpgradeValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent) Optional(java.util.Optional) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) ClusterUpgradeValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent) Map(java.util.Map) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) ClusterUpgradeValidationTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationTriggerEvent) Bean(org.springframework.context.annotation.Bean)

Example 4 with ClusterUpgradeValidationFinishedEvent

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent in project cloudbreak by hortonworks.

the class ClusterUpgradeServiceValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeServiceValidationEvent> event) {
    LOGGER.debug("Accepting Cluster upgrade service validation event.");
    ClusterUpgradeServiceValidationEvent request = event.getData();
    Long stackId = request.getResourceId();
    try {
        Stack stack = getStack(stackId);
        serviceUpgradeValidators.forEach(validator -> validator.validate(new ServiceUpgradeValidationRequest(stack, request.isLockComponents())));
        return new ClusterUpgradeValidationFinishedEvent(stackId);
    } catch (UpgradeValidationFailedException e) {
        LOGGER.warn("Cluster upgrade service validation failed", e);
        return new ClusterUpgradeValidationFailureEvent(stackId, e);
    } catch (Exception e) {
        LOGGER.error("Cluster upgrade service validation was unsuccessful due to an internal error", e);
        return new ClusterUpgradeValidationFinishedEvent(stackId, e);
    }
}
Also used : ClusterUpgradeValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent) ClusterUpgradeServiceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeServiceValidationEvent) ServiceUpgradeValidationRequest(com.sequenceiq.cloudbreak.service.upgrade.validation.service.ServiceUpgradeValidationRequest) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)

Aggregations

ClusterUpgradeValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent)4 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)3 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)3 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)3 Map (java.util.Map)3 Optional (java.util.Optional)3 Bean (org.springframework.context.annotation.Bean)3 ClusterUpgradeServiceValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeServiceValidationEvent)2 UpgradeValidationFailedException (com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)1 ClusterUpgradeFreeIpaStatusValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationFinishedEvent)1 ClusterUpgradeValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent)1 ClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)1 ClusterUpgradeValidationFinalizeEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinalizeEvent)1 ClusterUpgradeValidationTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationTriggerEvent)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 ServiceUpgradeValidationRequest (com.sequenceiq.cloudbreak.service.upgrade.validation.service.ServiceUpgradeValidationRequest)1