Search in sources :

Example 46 with NotFoundException

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;
}
Also used : CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)

Example 47 with NotFoundException

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;
}
Also used : ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException)

Example 48 with NotFoundException

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;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException)

Example 49 with NotFoundException

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;
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) IOException(java.io.IOException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) CrnParseException(com.sequenceiq.cloudbreak.auth.crn.CrnParseException)

Example 50 with NotFoundException

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());
}
Also used : SdxDatabaseBackupStatusResponse(com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)73 Test (org.junit.jupiter.api.Test)33 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)9 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)8 Map (java.util.Map)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)6 List (java.util.List)6 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)5 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)5 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)5 Optional (java.util.Optional)5 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)4 Set (java.util.Set)4 CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3