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