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