use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class MaintenanceModeValidationService method validateImageCatalog.
public List<Warning> validateImageCatalog(Stack stack) {
List<Warning> warnings = new ArrayList<>();
try {
Image image = componentConfigProviderService.getImage(stack.getId());
StatedImage statedImage = imageCatalogService.getImage(image.getImageCatalogUrl(), image.getImageCatalogName(), image.getImageId());
if (!image.getPackageVersions().isEmpty()) {
CheckResult checkResult = stackImageUpdateService.checkPackageVersions(stack, statedImage);
if (checkResult.getStatus().equals(EventStatus.FAILED)) {
warnings.add(new Warning(WarningType.IMAGE_INCOMPATIBILITY_WARNING, checkResult.getMessage()));
}
}
} catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) {
throw new CloudbreakServiceException("Image info could not be validated!", e);
}
return warnings;
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class MaintenanceModeValidationService method handleValidationSuccess.
public void handleValidationSuccess(Long stackId, List<Warning> warnings) {
LOGGER.debug("Maintenance mode validation flow has been finished successfully");
stackUpdater.updateStackStatus(stackId, DetailedStackStatus.MAINTENANCE_MODE_ENABLED, "Validation has been finished");
try {
if (!warnings.isEmpty()) {
String warningJson = new ObjectMapper().writeValueAsString(warnings);
LOGGER.warn(String.format("Found warnings: {%s}", warningJson));
flowMessageService.fireEventAndLog(stackId, AVAILABLE.name(), MAINTENANCE_MODE_VALIDATION_FINISHED_FOUND_WARNINGS, warningJson);
} else {
flowMessageService.fireEventAndLog(stackId, AVAILABLE.name(), MAINTENANCE_MODE_VALIDATION_FINISHED_NO_WARNINGS);
}
} catch (JsonProcessingException e) {
throw new CloudbreakServiceException("Validation result could not be serialized!", e);
}
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class CmSyncHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<CmSyncRequest> event) {
CmSyncRequest request = event.getData();
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
Set<Image> candidateImages = cmSyncImageCollectorService.collectImages(request.getFlowTriggerUserCrn(), stack, request.getCandidateImageUuids());
CmSyncOperationSummary cmSyncOperationSummary = cmSyncerService.syncFromCmToDb(stack, candidateImages);
CmSyncOperationStatus cmSyncOperationStatus = cmSyncOperationSummary.getSyncOperationStatus();
if (!cmSyncOperationStatus.hasSucceeded()) {
LOGGER.debug("Reading CM and active parcel versions from CM server encountered failures. Details: {}", cmSyncOperationStatus.getMessage());
Exception e = new CloudbreakServiceException(cmSyncOperationStatus.getMessage());
return new CmSyncResult(cmSyncOperationStatus.getMessage(), e, request);
}
return new CmSyncResult(request, cmSyncOperationStatus.getMessage());
} catch (Exception e) {
LOGGER.warn("Reading CM and active parcel versions from CM server resulted in error ", e);
String message = String.format("unexpected error: %s", e.getMessage());
return new CmSyncResult(message, new CloudbreakServiceException(message, e), request);
}
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class CmSyncHandler method defaultFailureEvent.
@Override
protected Selectable defaultFailureEvent(Long resourceId, Exception e, Event<CmSyncRequest> event) {
LOGGER.debug("Reading CM and active parcel versions from CM server encountered an unexpected error ", e);
String message = String.format("unexpected error: %s", e.getMessage());
return new CmSyncResult(message, new CloudbreakServiceException(message, e), event.getData());
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class DatalakeRecoveryBringupActions method datalakeRecoveryRestoreComponents.
@Bean(name = "RECOVERY_RESTORE_COMPONENTS_STATE")
public Action<?, ?> datalakeRecoveryRestoreComponents() {
return new AbstractDatalakeRecoveryBringupAction<>(ClusterRecoveryTriggerEvent.class) {
@Override
protected void doExecute(DatalakeRecoveryBringupContext context, ClusterRecoveryTriggerEvent payload, Map<Object, Object> variables) {
Long stackId = context.getStackId();
try {
Image image = componentConfigProviderService.getImage(stackId);
imageComponentUpdaterService.updateForUpgrade(image.getImageId(), stackId);
} catch (CloudbreakImageNotFoundException e) {
String message = "Image was not found for current stack, it is not possible to continue recovery. " + "Please open a Cloudera support ticket to fix this issue";
LOGGER.warn(message);
throw new CloudbreakServiceException(message);
}
sendEvent(context, RECOVERY_RESTORE_COMPONENTS_FINISHED_EVENT.event(), payload);
}
};
}
Aggregations