Search in sources :

Example 36 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class DatabaseService method terminate.

public void terminate(SdxCluster sdxCluster, boolean forced) {
    LOGGER.info("Terminating databaseServer of SDX {}", sdxCluster.getClusterName());
    try {
        DatabaseServerV4Response resp = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> databaseServerV4Endpoint.deleteByCrn(sdxCluster.getDatabaseCrn(), forced));
        sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.EXTERNAL_DATABASE_DELETION_IN_PROGRESS, "External database deletion in progress", sdxCluster);
        waitAndGetDatabase(sdxCluster, resp.getCrn(), SdxDatabaseOperation.DELETION, false);
    } catch (NotFoundException notFoundException) {
        LOGGER.info("Database server is deleted on redbeams side {}", sdxCluster.getDatabaseCrn());
    }
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) NotFoundException(javax.ws.rs.NotFoundException)

Example 37 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class DatabaseService method getDatabaseServer.

public StackDatabaseServerResponse getDatabaseServer(String userCrn, String clusterCrn) {
    SdxCluster sdxCluster = sdxService.getByCrn(userCrn, clusterCrn);
    if (sdxCluster.getDatabaseCrn() == null) {
        throw com.sequenceiq.cloudbreak.common.exception.NotFoundException.notFound("Database for Data Lake with Data Lake crn:", clusterCrn).get();
    }
    DatabaseServerV4Response databaseServerV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> databaseServerV4Endpoint.getByCrn(sdxCluster.getDatabaseCrn()));
    return databaseServerConverter.convert(databaseServerV4Response);
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster)

Example 38 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class DatabaseServerConverterTest method testConvertResponse.

@Test
public void testConvertResponse() {
    DatabaseServerV4Response source = new DatabaseServerV4Response();
    source.setCrn("databaseCrn");
    source.setName("databaseName");
    source.setDescription("description");
    source.setEnvironmentCrn("envCrn");
    source.setHost("host");
    source.setPort(1234);
    source.setDatabaseVendor("vendor");
    source.setDatabaseVendorDisplayName("vendorName");
    source.setCreationDate(new Date().getTime());
    source.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
    source.setStatus(Status.AVAILABLE);
    source.setStatusReason("Everything is great");
    source.setClusterCrn("clusterCrn");
    SslConfigV4Response sourceSslConfig = new SslConfigV4Response();
    sourceSslConfig.setSslCertificates(Set.of("cert1", "cert2"));
    sourceSslConfig.setSslMode(SslMode.ENABLED);
    sourceSslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
    source.setSslConfig(sourceSslConfig);
    StackDatabaseServerResponse result = underTest.convert(source);
    assertEquals(source.getCrn(), result.getCrn());
    assertEquals(source.getName(), result.getName());
    assertEquals(source.getDescription(), result.getDescription());
    assertEquals(source.getEnvironmentCrn(), result.getEnvironmentCrn());
    assertEquals(source.getHost(), result.getHost());
    assertEquals(source.getPort(), result.getPort());
    assertEquals(source.getDatabaseVendor(), result.getDatabaseVendor());
    assertEquals(source.getDatabaseVendorDisplayName(), result.getDatabaseVendorDisplayName());
    assertEquals(source.getCreationDate(), result.getCreationDate());
    assertEquals(DatabaseServerResourceStatus.SERVICE_MANAGED, result.getResourceStatus());
    assertEquals(DatabaseServerStatus.AVAILABLE, result.getStatus());
    assertEquals(source.getStatusReason(), result.getStatusReason());
    assertEquals(source.getClusterCrn(), result.getClusterCrn());
    DatabaseServerSslConfig resultSslConfig = result.getSslConfig();
    assertThat(resultSslConfig.getSslMode()).isEqualTo(DatabaseServerSslMode.ENABLED);
    assertThat(resultSslConfig.getSslCertificateType()).isEqualTo(DatabaseServerSslCertificateType.CLOUD_PROVIDER_OWNED);
    assertThat(resultSslConfig.getSslCertificates()).isEqualTo(sourceSslConfig.getSslCertificates());
}
Also used : StackDatabaseServerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) Date(java.util.Date) DatabaseServerSslConfig(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 39 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class DatabaseServerConverterTest method testConvertResponse.

@Test
public void testConvertResponse() {
    DatabaseServerV4Response source = new DatabaseServerV4Response();
    source.setCrn("databaseCrn");
    source.setName("databaseName");
    source.setDescription("description");
    source.setEnvironmentCrn("envCrn");
    source.setHost("host");
    source.setPort(1234);
    source.setDatabaseVendor("vendor");
    source.setDatabaseVendorDisplayName("vendorName");
    source.setCreationDate(new Date().getTime());
    source.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
    source.setStatus(Status.AVAILABLE);
    source.setStatusReason("Everything is great");
    source.setClusterCrn("clusterCrn");
    SslConfigV4Response sourceSslConfig = new SslConfigV4Response();
    sourceSslConfig.setSslCertificates(Set.of("cert1", "cert2"));
    sourceSslConfig.setSslMode(SslMode.ENABLED);
    sourceSslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
    source.setSslConfig(sourceSslConfig);
    StackDatabaseServerResponse result = underTest.convert(source);
    assertThat(result.getCrn()).isEqualTo(source.getCrn());
    assertThat(result.getName()).isEqualTo(source.getName());
    assertThat(result.getDescription()).isEqualTo(source.getDescription());
    assertThat(result.getEnvironmentCrn()).isEqualTo(source.getEnvironmentCrn());
    assertThat(result.getHost()).isEqualTo(source.getHost());
    assertThat(result.getPort()).isEqualTo(source.getPort());
    assertThat(result.getDatabaseVendor()).isEqualTo(source.getDatabaseVendor());
    assertThat(result.getDatabaseVendorDisplayName()).isEqualTo(source.getDatabaseVendorDisplayName());
    assertThat(result.getCreationDate()).isEqualTo(source.getCreationDate());
    assertThat(result.getResourceStatus()).isEqualTo(DatabaseServerResourceStatus.SERVICE_MANAGED);
    assertThat(result.getStatus()).isEqualTo(DatabaseServerStatus.AVAILABLE);
    assertThat(result.getStatusReason()).isEqualTo(source.getStatusReason());
    assertThat(result.getClusterCrn()).isEqualTo(source.getClusterCrn());
    DatabaseServerSslConfig resultSslConfig = result.getSslConfig();
    assertThat(resultSslConfig.getSslMode()).isEqualTo(DatabaseServerSslMode.ENABLED);
    assertThat(resultSslConfig.getSslCertificateType()).isEqualTo(DatabaseServerSslCertificateType.CLOUD_PROVIDER_OWNED);
    assertThat(resultSslConfig.getSslCertificates()).isEqualTo(sourceSslConfig.getSslCertificates());
}
Also used : StackDatabaseServerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) Date(java.util.Date) DatabaseServerSslConfig(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 40 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class RedbeamsDbServerConfigurerTest method createDatabaseServerV4Response.

private DatabaseServerV4Response createDatabaseServerV4Response(String dbHost) {
    DatabaseServerV4Response resp = new DatabaseServerV4Response();
    resp.setPort(1234);
    resp.setHost(dbHost);
    resp.setDatabaseVendor("postgres");
    return resp;
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)

Aggregations

DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)54 Test (org.junit.jupiter.api.Test)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)16 SslConfigV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)12 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)9 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)7 Test (org.junit.Test)6 StackDatabaseServerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse)5 AllocateDatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request)5 DatabaseServerSslConfig (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig)4 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)4 DatabaseServerStatusV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerStatusV4Response)4 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)4 Date (java.util.Date)4 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)3 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)3 NotFoundException (javax.ws.rs.NotFoundException)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3