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;
}
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;
}
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);
}
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));
});
}
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);
}
Aggregations