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