Search in sources :

Example 6 with StorageLocation

use of com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation in project cloudbreak by hortonworks.

the class CloudStorageConverter method storageLocationRequestToStorageLocation.

private StorageLocation storageLocationRequestToStorageLocation(StorageLocationBase storageLocationRequest) {
    StorageLocation storageLocation = new StorageLocation();
    try {
        storageLocation.setType(storageLocationRequest.getType());
    } catch (IllegalArgumentException e) {
        throw new BadRequestException(String.format("StorageLocation type '%s' is not supported. Supported types: [%s].", storageLocationRequest.getType(), CloudStorageCdpService.typeListing()), e);
    }
    storageLocation.setValue(storageLocationRequest.getValue());
    return storageLocation;
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation)

Example 7 with StorageLocation

use of com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation in project cloudbreak by hortonworks.

the class CloudStorageConverter method fileSystemToResponse.

public CloudStorageResponse fileSystemToResponse(FileSystem fileSystem) {
    CloudStorageResponse response = new CloudStorageResponse();
    CloudStorage cloudStorage = fileSystem.getCloudStorage();
    if (cloudStorage != null) {
        if (StringUtils.isNotEmpty(cloudStorage.getS3GuardDynamoTableName())) {
            AwsStorageParameters awsStorageParameters = new AwsStorageParameters();
            S3Guard s3Guard = new S3Guard();
            s3Guard.setDynamoTableName(cloudStorage.getS3GuardDynamoTableName());
            awsStorageParameters.setS3Guard(s3Guard);
            response.setAws(awsStorageParameters);
        }
        List<StorageIdentityBase> storageIdentities = cloudStorage.getCloudIdentities().stream().map(this::cloudIdentityToStorageIdentityBase).collect(Collectors.toList());
        response.setIdentities(storageIdentities);
        List<StorageLocationBase> storageLocations = cloudStorage.getLocations().stream().map(storageLocation -> {
            StorageLocationBase storageLocationBase = new StorageLocationBase();
            storageLocationBase.setType(storageLocation.getType());
            storageLocationBase.setValue(storageLocation.getValue());
            return storageLocationBase;
        }).collect(Collectors.toList());
        response.setLocations(storageLocations);
        response.setAccountMapping(accountMappingToAccountMappingRequest(cloudStorage.getAccountMapping()));
    }
    return response;
}
Also used : CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) AwsStorageParameters(com.sequenceiq.common.api.cloudstorage.AwsStorageParameters) EfsIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.EfsIdentity) AwsStorageParameters(com.sequenceiq.common.api.cloudstorage.AwsStorageParameters) AwsEfsParameters(com.sequenceiq.common.api.cloudstorage.AwsEfsParameters) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) HashMap(java.util.HashMap) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters) StringUtils(org.apache.commons.lang3.StringUtils) AccountMapping(com.sequenceiq.cloudbreak.domain.cloudstorage.AccountMapping) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) AccountMappingBase(com.sequenceiq.common.api.cloudstorage.AccountMappingBase) CloudS3View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View) CloudIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity) Map(java.util.Map) AdlsGen2Identity(com.sequenceiq.cloudbreak.domain.cloudstorage.AdlsGen2Identity) GcsIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.GcsIdentity) CloudEfsConfiguration(com.sequenceiq.cloudbreak.cloud.model.filesystem.efs.CloudEfsConfiguration) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) CloudStorageBase(com.sequenceiq.common.api.cloudstorage.CloudStorageBase) CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) NullUtil(com.sequenceiq.cloudbreak.util.NullUtil) CloudStorageResponse(com.sequenceiq.common.api.cloudstorage.CloudStorageResponse) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) Collectors(java.util.stream.Collectors) Json(com.sequenceiq.cloudbreak.common.json.Json) S3Identity(com.sequenceiq.cloudbreak.domain.cloudstorage.S3Identity) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation) List(java.util.List) Component(org.springframework.stereotype.Component) WasbIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.WasbIdentity) WasbCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.WasbCloudStorageV1Parameters) MissingResourceNameGenerator(com.sequenceiq.cloudbreak.common.converter.MissingResourceNameGenerator) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) FileSystemType(com.sequenceiq.common.model.FileSystemType) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) Optional(java.util.Optional) FileSystemResolver(com.sequenceiq.cloudbreak.service.filesystem.FileSystemResolver) S3Guard(com.sequenceiq.common.api.cloudstorage.S3Guard) FILESYSTEM(com.sequenceiq.cloudbreak.common.type.APIResourceType.FILESYSTEM) CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) CloudStorageResponse(com.sequenceiq.common.api.cloudstorage.CloudStorageResponse) S3Guard(com.sequenceiq.common.api.cloudstorage.S3Guard) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase)

Example 8 with StorageLocation

use of com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation in project cloudbreak by hortonworks.

the class CloudFileSystemViewProviderTest method getCloudStorage.

private CloudStorage getCloudStorage(List<CloudIdentity> cloudIdentities) {
    List<StorageLocation> storageLocations = new ArrayList<>();
    StorageLocation storageLocation1 = new StorageLocation();
    storageLocation1.setType(SERVICE_1);
    storageLocation1.setValue(PATH_1);
    storageLocations.add(storageLocation1);
    StorageLocation storageLocation2 = new StorageLocation();
    storageLocation2.setType(SERVICE_2);
    storageLocation2.setValue(PATH_2);
    storageLocations.add(storageLocation2);
    StorageLocation storageLocation3 = new StorageLocation();
    storageLocation3.setType(SERVICE_3);
    storageLocation3.setValue(PATH_3);
    storageLocations.add(storageLocation3);
    StorageLocation storageLocation4 = new StorageLocation();
    storageLocation4.setType(SERVICE_4);
    storageLocation4.setValue(PATH_4);
    storageLocations.add(storageLocation4);
    CloudStorage cloudStorage = new CloudStorage();
    cloudStorage.setCloudIdentities(cloudIdentities);
    cloudStorage.setLocations(storageLocations);
    return cloudStorage;
}
Also used : CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) ArrayList(java.util.ArrayList) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation)

Example 9 with StorageLocation

use of com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation in project cloudbreak by hortonworks.

the class RemoteDataContextWorkaroundServiceTest method testFileSystemWhenHivePathPresentedInDistroXButSdxDoesNotContainsItShouldReturnWithDistroXConfigs.

@Test
public void testFileSystemWhenHivePathPresentedInDistroXButSdxDoesNotContainsItShouldReturnWithDistroXConfigs() throws IOException {
    FileSystem fileSystem = underTest.prepareFilesytem(mockRequestedCluster(mockStorageLocation(3), mockStorageLocation(4)), mockStack());
    List<StorageLocation> locations = fileSystem.getCloudStorage().getLocations();
    Assert.assertEquals(2, locations.size());
    Assert.assertTrue(hasPropretyWithIndex(locations, 3));
    Assert.assertTrue(hasPropretyWithIndex(locations, 4));
}
Also used : FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation) Test(org.junit.Test)

Example 10 with StorageLocation

use of com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation in project cloudbreak by hortonworks.

the class RemoteDataContextWorkaroundServiceTest method mockStorageLocation.

private StorageLocation mockStorageLocation(int index) {
    StorageLocation storageLocation = new StorageLocation();
    storageLocation.setType(CloudStorageCdpService.HIVE_METASTORE_EXTERNAL_WAREHOUSE);
    storageLocation.setValue("hive" + index);
    return storageLocation;
}
Also used : StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation)

Aggregations

StorageLocation (com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation)11 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)8 CloudStorage (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage)5 Test (org.junit.Test)4 CloudIdentity (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity)3 SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)2 AccountMapping (com.sequenceiq.cloudbreak.domain.cloudstorage.AccountMapping)2 ArrayList (java.util.ArrayList)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 CloudFileSystemView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView)1 CloudS3View (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View)1 CloudEfsConfiguration (com.sequenceiq.cloudbreak.cloud.model.filesystem.efs.CloudEfsConfiguration)1 CloudStorageConfigurationFailedException (com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException)1 MissingResourceNameGenerator (com.sequenceiq.cloudbreak.common.converter.MissingResourceNameGenerator)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 JsonUtil (com.sequenceiq.cloudbreak.common.json.JsonUtil)1 FILESYSTEM (com.sequenceiq.cloudbreak.common.type.APIResourceType.FILESYSTEM)1 AdlsGen2Identity (com.sequenceiq.cloudbreak.domain.cloudstorage.AdlsGen2Identity)1 EfsIdentity (com.sequenceiq.cloudbreak.domain.cloudstorage.EfsIdentity)1