use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeValidationEventToClusterUpgradeDiskSpaceValidationEventConverterTest method testConvertShouldCreateAClusterUpgradeDiskSpaceValidationEvent.
@Test
public void testConvertShouldCreateAClusterUpgradeDiskSpaceValidationEvent() {
ClusterUpgradeValidationEvent sourceEvent = new ClusterUpgradeValidationEvent(VALIDATE_DISK_SPACE_EVENT.event(), RESOURCE_ID, "image-id");
ClusterUpgradeDiskSpaceValidationEvent actual = underTest.convert(sourceEvent);
assertEquals(RESOURCE_ID, actual.getResourceId());
assertEquals(1L, actual.getRequiredFreeSpace());
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeValidationActions method clusterUpgradeImageValidation.
@Bean(name = "CLUSTER_UPGRADE_IMAGE_VALIDATION_STATE")
public Action<?, ?> clusterUpgradeImageValidation() {
return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeValidationEvent.class) {
@Override
protected void doExecute(StackContext context, ClusterUpgradeValidationEvent payload, Map<Object, Object> variables) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
LOGGER.info("Starting cluster upgrade image validation.");
UpgradeImageInfo upgradeImageInfo = upgradeImageInfoFactory.create(payload.getImageId(), payload.getResourceId());
Image targetImage = stackImageService.getImageModelFromStatedImage(context.getStack(), upgradeImageInfo.getCurrentImage(), upgradeImageInfo.getTargetStatedImage());
variables.put(TARGET_IMAGE, targetImage);
CloudStack cloudStack = context.getCloudStack().replaceImage(targetImage);
ClusterUpgradeImageValidationEvent event = new ClusterUpgradeImageValidationEvent(payload.getResourceId(), payload.getImageId(), cloudStack, context.getCloudCredential(), context.getCloudContext(), upgradeImageInfo.getTargetStatedImage().getImage());
sendEvent(context, event.selector(), event);
}
@Override
protected Object getFailurePayload(ClusterUpgradeValidationEvent payload, Optional<StackContext> flowContext, Exception ex) {
return new ClusterUpgradeValidationFailureEvent(payload.getResourceId(), ex);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent 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);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationEvent 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