Search in sources :

Example 1 with ClusterUpgradeDiskSpaceValidationFinishedEvent

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

the class ClusterUpgradeValidationActions method clusterUpgradeCheckCloudProviderUpdate.

@Bean(name = "CLUSTER_UPGRADE_CLOUDPROVIDER_CHECK_UPDATE_STATE")
public Action<?, ?> clusterUpgradeCheckCloudProviderUpdate() {
    return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeDiskSpaceValidationFinishedEvent.class) {

        @Override
        protected void doExecute(StackContext context, ClusterUpgradeDiskSpaceValidationFinishedEvent payload, Map<Object, Object> variables) {
            Collection<Resource> resources = resourceService.getAllByStackId(context.getStack().getId());
            List<CloudResource> cloudResources = resources.stream().map(resource -> resourceToCloudResourceConverter.convert(resource)).collect(Collectors.toList());
            ClusterUpgradeUpdateCheckRequest clusterUpgradeUpdateCheckRequest = new ClusterUpgradeUpdateCheckRequest(payload.getResourceId(), context.getCloudStack(), context.getCloudCredential(), context.getCloudContext(), cloudResources);
            sendEvent(context, VALIDATE_CLOUDPROVIDER_UPDATE.selector(), clusterUpgradeUpdateCheckRequest);
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeDiskSpaceValidationFinishedEvent payload, Optional<StackContext> flowContext, Exception ex) {
            return new ClusterUpgradeValidationFailureEvent(payload.getResourceId(), ex);
        }
    };
}
Also used : StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Action(org.springframework.statemachine.action.Action) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Resource(com.sequenceiq.cloudbreak.domain.Resource) AVAILABLE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE) LoggerFactory(org.slf4j.LoggerFactory) ClusterUpgradeFreeIpaStatusValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationEvent) UpgradeImageInfoFactory(com.sequenceiq.cloudbreak.service.upgrade.UpgradeImageInfoFactory) ClusterUpgradeDiskSpaceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent) ClusterUpgradeDiskSpaceValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent) CloudbreakMessagesService(com.sequenceiq.cloudbreak.message.CloudbreakMessagesService) CloudbreakEventService(com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService) START_CLUSTER_UPGRADE_IMAGE_VALIDATION_EVENT(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationStateSelectors.START_CLUSTER_UPGRADE_IMAGE_VALIDATION_EVENT) Map(java.util.Map) ClusterUpgradeValidationTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationTriggerEvent) StackUpdater(com.sequenceiq.cloudbreak.service.StackUpdater) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) VALIDATE_DISK_SPACE_EVENT(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationHandlerSelectors.VALIDATE_DISK_SPACE_EVENT) ClusterUpgradeContext(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.ClusterUpgradeContext) UPDATE_FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_FAILED) PayloadConverter(com.sequenceiq.flow.core.PayloadConverter) VALIDATE_CLOUDPROVIDER_UPDATE(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationHandlerSelectors.VALIDATE_CLOUDPROVIDER_UPDATE) Collection(java.util.Collection) ClusterUpgradeExistingUpgradeCommandValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent) FlowParameters(com.sequenceiq.flow.core.FlowParameters) ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationFinishedEvent) Collectors(java.util.stream.Collectors) UpgradeImageInfo(com.sequenceiq.cloudbreak.service.upgrade.UpgradeImageInfo) Configuration(org.springframework.context.annotation.Configuration) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) ClusterUpgradeValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent) List(java.util.List) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent) ClusterUpgradeUpdateCheckFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeUpdateCheckFinishedEvent) Optional(java.util.Optional) Flow(com.sequenceiq.flow.core.Flow) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverter(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverter) AbstractAction(com.sequenceiq.flow.core.AbstractAction) Inject(javax.inject.Inject) ResourceToCloudResourceConverter(com.sequenceiq.cloudbreak.converter.spi.ResourceToCloudResourceConverter) ResourceService(com.sequenceiq.cloudbreak.service.resource.ResourceService) ClusterUpgradeUpdateCheckRequest(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeUpdateCheckRequest) ClusterUpgradeValidationStateSelectors(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationStateSelectors) UPDATE_IN_PROGRESS(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_IN_PROGRESS) StateContext(org.springframework.statemachine.StateContext) Logger(org.slf4j.Logger) StackImageService(com.sequenceiq.cloudbreak.service.stack.StackImageService) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) ClusterUpgradeServiceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeServiceValidationEvent) ClusterUpgradeValidationFinalizeEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinalizeEvent) ClusterUpgradeValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFinishedEvent) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) HANDLED_FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationStateSelectors.HANDLED_FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT) Bean(org.springframework.context.annotation.Bean) Collections(java.util.Collections) ClusterUpgradeFreeIpaStatusValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeFreeIpaStatusValidationFinishedEvent) Optional(java.util.Optional) Resource(com.sequenceiq.cloudbreak.domain.Resource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) ClusterUpgradeDiskSpaceValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ClusterUpgradeUpdateCheckRequest(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeUpdateCheckRequest) Map(java.util.Map) 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)

Example 2 with ClusterUpgradeDiskSpaceValidationFinishedEvent

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

the class ClusterUpgradeValidationActions method clusterUpgradeDiskSpaceValidation.

@Bean(name = "CLUSTER_UPGRADE_DISK_SPACE_VALIDATION_STATE")
public Action<?, ?> clusterUpgradeDiskSpaceValidation() {
    return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeDiskSpaceValidationEvent.class) {

        @Override
        protected void doExecute(StackContext context, ClusterUpgradeDiskSpaceValidationEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Starting disk space validation.");
            ClusterUpgradeDiskSpaceValidationEvent event = new ClusterUpgradeDiskSpaceValidationEvent(VALIDATE_DISK_SPACE_EVENT.name(), payload.getResourceId(), payload.getRequiredFreeSpace());
            sendEvent(context, event.selector(), event);
        }

        @Override
        protected Object getFailurePayload(ClusterUpgradeDiskSpaceValidationEvent payload, Optional<StackContext> flowContext, Exception ex) {
            return new ClusterUpgradeDiskSpaceValidationFinishedEvent(payload.getResourceId());
        }

        @Override
        protected void initPayloadConverterMap(List<PayloadConverter<ClusterUpgradeDiskSpaceValidationEvent>> payloadConverters) {
            payloadConverters.add(new ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverter());
        }
    };
}
Also used : ClusterUpgradeDiskSpaceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent) Optional(java.util.Optional) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) List(java.util.List) ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverter(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverter) ClusterUpgradeDiskSpaceValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent) 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 ClusterUpgradeDiskSpaceValidationFinishedEvent

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

the class ClusterUpgradeDiskSpaceValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeDiskSpaceValidationEvent> event) {
    LOGGER.debug("Accepting Cluster upgrade validation event.");
    ClusterUpgradeDiskSpaceValidationEvent request = event.getData();
    Long stackId = request.getResourceId();
    try {
        diskSpaceValidationService.validateFreeSpaceForUpgrade(getStack(stackId), request.getRequiredFreeSpace());
        return new ClusterUpgradeDiskSpaceValidationFinishedEvent(request.getResourceId());
    } catch (UpgradeValidationFailedException e) {
        LOGGER.warn("Cluster upgrade validation failed", e);
        return new ClusterUpgradeValidationFailureEvent(stackId, e);
    } catch (Exception e) {
        LOGGER.error("Cluster upgrade validation was unsuccessful due to an internal error", e);
        return new ClusterUpgradeDiskSpaceValidationFinishedEvent(request.getResourceId());
    }
}
Also used : ClusterUpgradeDiskSpaceValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent) ClusterUpgradeDiskSpaceValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)

Example 4 with ClusterUpgradeDiskSpaceValidationFinishedEvent

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

the class ClusterUpgradeDiskSpaceValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeValidationEvent> event) {
    LOGGER.debug("Accepting Cluster upgrade validation event.");
    ClusterUpgradeValidationEvent request = event.getData();
    Long stackId = request.getResourceId();
    try {
        StatedImage targetImage = imageService.getCurrentImage(stackId);
        diskSpaceValidationService.validateFreeSpaceForUpgrade(getStack(stackId), targetImage);
        return new ClusterUpgradeDiskSpaceValidationFinishedEvent(request.getResourceId());
    } catch (UpgradeValidationFailedException e) {
        LOGGER.warn("Cluster upgrade validation failed", e);
        return new ClusterUpgradeValidationFailureEvent(stackId, e);
    } catch (Exception e) {
        LOGGER.error("Cluster upgrade validation was unsuccessful due to an internal error", e);
        return new ClusterUpgradeDiskSpaceValidationFinishedEvent(request.getResourceId());
    }
}
Also used : ClusterUpgradeValidationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent) ClusterUpgradeDiskSpaceValidationFinishedEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException) ClusterUpgradeValidationFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)

Aggregations

ClusterUpgradeDiskSpaceValidationFinishedEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationFinishedEvent)4 ClusterUpgradeDiskSpaceValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeDiskSpaceValidationEvent)3 ClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationFailureEvent)3 UpgradeValidationFailedException (com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)2 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverter (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverter)2 ClusterUpgradeValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent)2 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)2 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 AVAILABLE (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE)1 UPDATE_FAILED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_FAILED)1 UPDATE_IN_PROGRESS (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_IN_PROGRESS)1 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 ResourceToCloudResourceConverter (com.sequenceiq.cloudbreak.converter.spi.ResourceToCloudResourceConverter)1 ClusterUpgradeContext (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.ClusterUpgradeContext)1 ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.config.ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent)1 ClusterUpgradeExistingUpgradeCommandValidationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeExistingUpgradeCommandValidationEvent)1