use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityService method checkForUpgrades.
private UpgradeV4Response checkForUpgrades(Stack stack, boolean lockComponents, InternalUpgradeSettings internalUpgradeSettings) {
String accountId = Crn.safeFromString(stack.getResourceCrn()).getAccountId();
UpgradeV4Response upgradeOptions = new UpgradeV4Response();
try {
LOGGER.info(String.format("Retrieving images for upgrading stack %s", stack.getName()));
com.sequenceiq.cloudbreak.cloud.model.Image currentImage = getImage(stack);
CloudbreakImageCatalogV3 imageCatalog = getImagesFromCatalog(stack.getWorkspace(), currentImage.getImageCatalogName(), currentImage.getImageCatalogUrl());
Image image = getCurrentImageFromCatalog(currentImage.getImageId(), imageCatalog);
ImageFilterParams imageFilterParams = createImageFilterParams(image, lockComponents, stack, internalUpgradeSettings);
ImageFilterResult imageFilterResult = filterImages(accountId, imageCatalog, imageFilterParams);
LOGGER.info(String.format("%d possible image found for stack upgrade.", imageFilterResult.getImages().size()));
upgradeOptions = createResponse(image, imageFilterResult, stack.getCloudPlatform(), stack.getRegion(), currentImage.getImageCatalogName());
} catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException | NotFoundException e) {
LOGGER.warn("Failed to get images", e);
upgradeOptions.setReason(String.format("Failed to retrieve image due to %s", e.getMessage()));
}
return upgradeOptions;
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class UpgradeOptionsResponseFactory method getImageName.
private String getImageName(Image image, String cloudPlatform, String region) {
String imageName;
try {
ImageCatalogPlatform platformString = platformStringTransformer.getPlatformStringForImageCatalogByRegion(cloudPlatform, region);
imageName = imageService.determineImageName(cloudPlatform, platformString, region, image);
} catch (CloudbreakImageNotFoundException e) {
throw new NotFoundException(String.format("Image (%s) name not found", image.getUuid()), e);
}
return imageName;
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class UpdateNodeCountValidator method validateInstanceForDownscale.
public InstanceMetaData validateInstanceForDownscale(String instanceId, Stack stack) {
InstanceMetaData metaData = instanceMetaDataService.findByStackIdAndInstanceId(stack.getId(), instanceId).orElseThrow(() -> new NotFoundException(format("Metadata for instance %s has not found.", instanceId)));
downscaleValidatorService.checkInstanceIsTheClusterManagerServerOrNot(metaData.getPublicIp(), metaData.getInstanceMetadataType());
downscaleValidatorService.checkClusterInValidStatus(stack);
return metaData;
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class SdxService method getPayloadContext.
@Override
public PayloadContext getPayloadContext(Long resourceId) {
try {
SdxCluster sdxCluster = getById(resourceId);
DetailedEnvironmentResponse envResp = environmentClientService.getByCrn(sdxCluster.getEnvCrn());
return PayloadContext.create(sdxCluster.getCrn(), envResp.getCloudPlatform());
} catch (NotFoundException ignored) {
// skip
} catch (Exception e) {
LOGGER.warn("Error happened during fetching payload context for datalake with environment response.", e);
}
return null;
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class SdxBackupControllerTest method testBackupDatabaseByName.
@Test
public void testBackupDatabaseByName() {
SdxCluster sdxCluster = getValidSdxCluster();
when(sdxService.getByNameInAccount(any(), anyString())).thenReturn(sdxCluster);
String backupId = UUID.randomUUID().toString();
when(sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId)).thenThrow(new NotFoundException("Status entry not found"));
sdxBackupController.backupDatabaseByName(sdxCluster.getClusterName(), backupId, "");
verify(sdxBackupRestoreService, times(1)).triggerDatabaseBackup(any(), any());
reset(sdxBackupRestoreService);
when(sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId)).thenReturn(new SdxDatabaseBackupStatusResponse(DatalakeDatabaseDrStatus.SUCCEEDED, null));
sdxBackupController.backupDatabaseByName(sdxCluster.getClusterName(), backupId, "");
verify(sdxBackupRestoreService, times(0)).triggerDatabaseBackup(any(), any());
}
Aggregations