Search in sources :

Example 1 with StorageLocation

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

the class CloudStorageConverter method requestToFileSystem.

public FileSystem requestToFileSystem(CloudStorageBase cloudStorageRequest) {
    FileSystem fileSystem = new FileSystem();
    fileSystem.setName(nameGenerator.generateName(FILESYSTEM));
    FileSystemType fileSystemType = fileSystemResolver.determineFileSystemType(cloudStorageRequest);
    fileSystem.setType(fileSystemType);
    CloudStorage cloudStorage = new CloudStorage();
    String s3GuardDynamoTableName = getS3GuardDynamoTableName(cloudStorageRequest);
    cloudStorage.setS3GuardDynamoTableName(s3GuardDynamoTableName);
    List<StorageLocation> storageLocations = cloudStorageRequest.getLocations().stream().map(this::storageLocationRequestToStorageLocation).collect(Collectors.toList());
    cloudStorage.setLocations(storageLocations);
    if (cloudStorageRequest.getIdentities() != null) {
        List<CloudIdentity> cloudIdentities = cloudStorageRequest.getIdentities().stream().map(this::identityRequestToCloudIdentity).collect(Collectors.toList());
        cloudStorage.setCloudIdentities(cloudIdentities);
    }
    cloudStorage.setAccountMapping(accountMappingRequestToAccountMapping(cloudStorageRequest.getAccountMapping()));
    fileSystem.setCloudStorage(cloudStorage);
    return fileSystem;
}
Also used : CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) FileSystemType(com.sequenceiq.common.model.FileSystemType) CloudIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation)

Example 2 with StorageLocation

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

the class RemoteDataContextWorkaroundService method prepareFilesytem.

public FileSystem prepareFilesytem(Cluster requestedCluster, Stack datalakeStack) {
    prepareFilesystemIfNotPresentedButSdxHasIt(requestedCluster, datalakeStack);
    if (hasFilesystem(requestedCluster.getFileSystem())) {
        FileSystem fileSystem = requestedCluster.getFileSystem();
        if (hasLocations(fileSystem)) {
            CloudStorage cloudStorage = fileSystem.getCloudStorage();
            FileSystem dlFileSystem = datalakeStack.getCluster().getFileSystem();
            if (hasFilesystem(dlFileSystem)) {
                if (hasLocations(dlFileSystem)) {
                    List<StorageLocation> dlStorageLocations = dlFileSystem.getCloudStorage().getLocations();
                    List<StorageLocation> hiveRelatedStorageConfigs = getHiveRelatedStorageConfigs(dlStorageLocations);
                    if (sdxHasHiveStorageConfiguration(hiveRelatedStorageConfigs)) {
                        List<StorageLocation> storageLocations = getStorageLocationsWithoutHiveRelatedLocations(cloudStorage.getLocations());
                        storageLocations.addAll(hiveRelatedStorageConfigs);
                        cloudStorage.setLocations(storageLocations);
                        fileSystem.setCloudStorage(cloudStorage);
                    }
                }
            }
        }
    }
    return requestedCluster.getFileSystem();
}
Also used : CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation)

Example 3 with StorageLocation

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

the class RemoteDataContextWorkaroundServiceTest method testFileSystemWhenHiveInSdxAndDistroXShouldReturnWithSdxHiveConfigs.

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

Example 4 with StorageLocation

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

the class RemoteDataContextWorkaroundServiceTest method testFileSystemWhenHivePathNotPresentedInDistroXAndSdxDoesNotContainsItShouldReturnWithSdxConfigs.

@Test
public void testFileSystemWhenHivePathNotPresentedInDistroXAndSdxDoesNotContainsItShouldReturnWithSdxConfigs() throws IOException {
    when(nameGenerator.generateName(APIResourceType.FILESYSTEM)).thenReturn("appletree");
    FileSystem fileSystem = underTest.prepareFilesytem(mockRequestedCluster(mockRds(HIVE)), mockStack());
    List<StorageLocation> locations = fileSystem.getCloudStorage().getLocations();
    Assert.assertEquals(0, locations.size());
}
Also used : FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation) Test(org.junit.Test)

Example 5 with StorageLocation

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

the class ClouderaManagerStorageErrorMapperTest method setUp.

@BeforeEach
void setUp() {
    underTest = new ClouderaManagerStorageErrorMapper();
    exception = new CloudStorageConfigurationFailedException(EXCEPTION_MESSAGE);
    cluster = new Cluster();
    fileSystem = new FileSystem();
    cloudStorage = new CloudStorage();
    cloudIdentity = new CloudIdentity();
    cloudIdentity.setIdentityType(CloudIdentityType.ID_BROKER);
    cloudStorage.setCloudIdentities(List.of(cloudIdentity));
    accountMapping = new AccountMapping();
    accountMapping.setUserMappings(Map.ofEntries(entry("hive", "myDataAccessRole"), entry("solr", "myRangerAuditRole")));
    cloudStorage.setAccountMapping(accountMapping);
    StorageLocation locationRangerAudit = new StorageLocation();
    locationRangerAudit.setType(CloudStorageCdpService.RANGER_AUDIT);
    locationRangerAudit.setValue("myRangerAuditLocation");
    cloudStorage.setLocations(List.of(locationRangerAudit));
    fileSystem.setCloudStorage(cloudStorage);
    cluster.setFileSystem(fileSystem);
}
Also used : CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) CloudIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) AccountMapping(com.sequenceiq.cloudbreak.domain.cloudstorage.AccountMapping) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation) BeforeEach(org.junit.jupiter.api.BeforeEach)

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