Search in sources :

Example 11 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class SdxClusterConverter method sdxClusterToResponse.

public SdxClusterResponse sdxClusterToResponse(SdxCluster sdxCluster) {
    SdxClusterResponse sdxClusterResponse = new SdxClusterResponse();
    SdxStatusEntity actualStatusForSdx = measure(() -> sdxStatusService.getActualStatusForSdx(sdxCluster), LOGGER, "Fetching SDX status took {}ms from DB. Name: [{}]", sdxCluster.getClusterName());
    if (actualStatusForSdx != null && actualStatusForSdx.getStatus() != null) {
        sdxClusterResponse.setStatus(SdxClusterStatusResponse.valueOf(actualStatusForSdx.getStatus().name()));
        sdxClusterResponse.setStatusReason(actualStatusForSdx.getStatusReason());
    }
    sdxClusterResponse.setRuntime(sdxCluster.getRuntime());
    sdxClusterResponse.setName(sdxCluster.getClusterName());
    sdxClusterResponse.setCrn(sdxCluster.getCrn());
    sdxClusterResponse.setClusterShape(sdxCluster.getClusterShape());
    sdxClusterResponse.setEnvironmentName(sdxCluster.getEnvName());
    sdxClusterResponse.setEnvironmentCrn(sdxCluster.getEnvCrn());
    sdxClusterResponse.setStackCrn(sdxCluster.getStackCrn());
    sdxClusterResponse.setCreated(sdxCluster.getCreated());
    sdxClusterResponse.setCloudStorageBaseLocation(sdxCluster.getCloudStorageBaseLocation());
    sdxClusterResponse.setCloudStorageFileSystemType(sdxCluster.getCloudStorageFileSystemType());
    sdxClusterResponse.setDatabaseServerCrn(sdxCluster.getDatabaseCrn());
    sdxClusterResponse.setRangerRazEnabled(sdxCluster.isRangerRazEnabled());
    sdxClusterResponse.setTags(getTags(sdxCluster.getTags()));
    sdxClusterResponse.setCertExpirationState(sdxCluster.getCertExpirationState());
    sdxClusterResponse.setSdxClusterServiceVersion(sdxCluster.getSdxClusterServiceVersion());
    sdxClusterResponse.setDetached(sdxCluster.isDetached());
    sdxClusterResponse.setEnableMultiAz(sdxCluster.isEnableMultiAz());
    sdxClusterResponse.setDatabaseEngineVersion(sdxCluster.getDatabaseEngineVersion());
    return sdxClusterResponse;
}
Also used : SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse)

Example 12 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class DatalakeStructuredFlowEventFactory method createStructuredFlowEvent.

@Override
public CDPStructuredFlowEvent<SdxClusterDto> createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Exception exception) {
    SdxCluster sdxCluster = sdxService.getById(resourceId);
    CDPOperationDetails operationDetails = makeCdpOperationDetails(resourceId, sdxCluster);
    SdxClusterDto sdxClusterDto = sdxClusterDtoConverter.sdxClusterToDto(sdxCluster);
    SdxStatusEntity sdxStatus = sdxStatusRepository.findFirstByDatalakeIsOrderByIdDesc(sdxCluster);
    String status = sdxStatus.getStatus().name();
    String statusReason = sdxStatus.getStatusReason();
    CDPStructuredFlowEvent<SdxClusterDto> event = new CDPStructuredFlowEvent<>(operationDetails, flowDetails, sdxClusterDto, status, statusReason);
    if (exception != null) {
        event.setException(ExceptionUtils.getStackTrace(exception));
    }
    return event;
}
Also used : SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) CDPStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Example 13 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class DatabaseServiceTest method shouldSetDbConfigBasedOnClusterShape.

@ParameterizedTest(name = "{0}")
@MethodSource("sslEnforcementDataProvider")
public void shouldSetDbConfigBasedOnClusterShape(String testCaseName, boolean supportedPlatform, String runtime, Boolean entitled, boolean sslEnforcementAppliedExpected) {
    SdxCluster cluster = new SdxCluster();
    cluster.setClusterName("NAME");
    cluster.setClusterShape(SdxClusterShape.LIGHT_DUTY);
    cluster.setCrn(CLUSTER_CRN);
    cluster.setRuntime(runtime);
    DetailedEnvironmentResponse env = new DetailedEnvironmentResponse();
    env.setName("ENV");
    env.setCloudPlatform("aws");
    env.setCrn(ENV_CRN);
    DatabaseConfig databaseConfig = getDatabaseConfig();
    when(databaseServerV4Endpoint.createInternal(any(), any())).thenThrow(BadRequestException.class);
    DatabaseConfigKey dbConfigKey = new DatabaseConfigKey(CloudPlatform.AWS, SdxClusterShape.LIGHT_DUTY);
    when(dbConfigs.get(dbConfigKey)).thenReturn(databaseConfig);
    when(databaseParameterSetterMap.get(CloudPlatform.AWS)).thenReturn(getDatabaseParameterSetter());
    when(platformConfig.isExternalDatabaseSslEnforcementSupportedFor(CloudPlatform.AWS)).thenReturn(supportedPlatform);
    if (entitled != null) {
        when(entitlementService.databaseWireEncryptionEnabled(ACCOUNT_ID)).thenReturn(entitled);
    }
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    SdxStatusEntity status = new SdxStatusEntity();
    status.setStatus(DatalakeStatusEnum.REQUESTED);
    when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(status);
    assertThatCode(() -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.create(cluster, env))).isInstanceOf(BadRequestException.class);
    verify(databaseServerV4Endpoint).createInternal(allocateDatabaseServerV4RequestCaptor.capture(), anyString());
    AllocateDatabaseServerV4Request dbRequest = allocateDatabaseServerV4RequestCaptor.getValue();
    assertThat(dbRequest).isNotNull();
    DatabaseServerV4StackRequest databaseServer = dbRequest.getDatabaseServer();
    assertThat(databaseServer).isNotNull();
    assertThat(databaseServer.getInstanceType()).isEqualTo("instanceType");
    assertThat(databaseServer.getDatabaseVendor()).isEqualTo("vendor");
    assertThat(databaseServer.getStorageSize()).isEqualTo(100L);
    assertThat(dbRequest.getClusterCrn()).isEqualTo(CLUSTER_CRN);
    assertThat(databaseServer.getAws()).isNotNull();
    SslConfigV4Request sslConfig = dbRequest.getSslConfig();
    if (sslEnforcementAppliedExpected) {
        assertThat(sslConfig).isNotNull();
        assertThat(sslConfig.getSslMode()).isEqualTo(SslMode.ENABLED);
    } else {
        assertThat(sslConfig).isNull();
    }
    verifyNoInteractions(sdxClusterRepository);
    verifyNoInteractions(notificationService);
}
Also used : DatabaseServerV4StackRequest(com.sequenceiq.redbeams.api.endpoint.v4.stacks.DatabaseServerV4StackRequest) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) AllocateDatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SslConfigV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 14 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class DatabaseServiceTest method shouldThrowExceptionBecauseSDXIsTerminated.

@Test
public void shouldThrowExceptionBecauseSDXIsTerminated() {
    SdxCluster cluster = new SdxCluster();
    cluster.setClusterName("NAME");
    cluster.setClusterShape(SdxClusterShape.LIGHT_DUTY);
    cluster.setCrn(CLUSTER_CRN);
    DetailedEnvironmentResponse env = new DetailedEnvironmentResponse();
    env.setName("ENV");
    env.setCloudPlatform("aws");
    SdxStatusEntity status = new SdxStatusEntity();
    status.setStatus(DatalakeStatusEnum.DELETE_REQUESTED);
    when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(status);
    assertThrows(CloudbreakServiceException.class, () -> {
        ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.create(cluster, env));
    });
}
Also used : SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class RangerCloudIdentityServiceTest method testSetAzureCloudIdentityMappingSuccessSync.

@Test
public void testSetAzureCloudIdentityMappingSuccessSync() throws ApiException {
    ApiCommand apiCommand = mock(ApiCommand.class);
    when(apiCommand.getId()).thenReturn(BigDecimal.ONE);
    when(apiCommand.getSuccess()).thenReturn(true);
    SdxStatusEntity sdxStatus = mockSdxStatus(DatalakeStatusEnum.RUNNING);
    when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(sdxStatus);
    testSetAzureCloudIdentityMapping(Optional.of(apiCommand), RangerCloudIdentitySyncState.SUCCESS);
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) Test(org.junit.jupiter.api.Test)

Aggregations

SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)23 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)9 Test (org.junit.jupiter.api.Test)9 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)3 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)3 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)2 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)2 CDPStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent)2 DatalakeStatusEnum (com.sequenceiq.datalake.entity.DatalakeStatusEnum)2 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)2 SdxRecoverableResponse (com.sequenceiq.sdx.api.model.SdxRecoverableResponse)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)1 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)1 FlowLog (com.sequenceiq.flow.domain.FlowLog)1 AllocateDatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request)1 SslConfigV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request)1