use of com.sequenceiq.cloudbreak.service.externaldatabase.model.DatabaseServerParameter in project cloudbreak by hortonworks.
the class ExternalDatabaseService method getDatabaseServerStackRequest.
private DatabaseServerV4StackRequest getDatabaseServerStackRequest(CloudPlatform cloudPlatform, DatabaseAvailabilityType externalDatabase) {
DatabaseStackConfig databaseStackConfig = dbConfigs.get(cloudPlatform);
if (databaseStackConfig == null) {
throw new BadRequestException("Database config for cloud platform " + cloudPlatform + " not found");
}
DatabaseServerV4StackRequest request = new DatabaseServerV4StackRequest();
request.setInstanceType(databaseStackConfig.getInstanceType());
request.setDatabaseVendor(databaseStackConfig.getVendor());
request.setStorageSize(databaseStackConfig.getVolumeSize());
DatabaseServerParameter serverParameter = DatabaseServerParameter.builder().withHighlyAvailable(DatabaseAvailabilityType.HA == externalDatabase).build();
parameterDecoratorMap.get(cloudPlatform).setParameters(request, serverParameter);
return request;
}
use of com.sequenceiq.cloudbreak.service.externaldatabase.model.DatabaseServerParameter in project cloudbreak by hortonworks.
the class ExternalDatabaseService method getDatabaseServerStackRequest.
private DatabaseServerV4StackRequest getDatabaseServerStackRequest(CloudPlatform cloudPlatform, DatabaseAvailabilityType externalDatabase, String databaseEngineVersion) {
DatabaseStackConfig databaseStackConfig = dbConfigs.get(cloudPlatform);
if (databaseStackConfig == null) {
throw new BadRequestException("Database config for cloud platform " + cloudPlatform + " not found");
}
DatabaseServerV4StackRequest request = new DatabaseServerV4StackRequest();
request.setInstanceType(databaseStackConfig.getInstanceType());
request.setDatabaseVendor(databaseStackConfig.getVendor());
request.setStorageSize(databaseStackConfig.getVolumeSize());
DatabaseServerParameter serverParameter = DatabaseServerParameter.builder().withHighlyAvailable(DatabaseAvailabilityType.HA == externalDatabase).withEngineVersion(databaseEngineVersion).build();
parameterDecoratorMap.get(cloudPlatform).setParameters(request, serverParameter);
return request;
}
use of com.sequenceiq.cloudbreak.service.externaldatabase.model.DatabaseServerParameter in project cloudbreak by hortonworks.
the class AwsDatabaseServerParameterDecoratorTest method setParameters.
@ParameterizedTest
@ValueSource(booleans = { false, true })
void setParameters(boolean needsHA) {
DatabaseServerParameter serverParameter = DatabaseServerParameter.builder().withHighlyAvailable(needsHA).build();
DatabaseServerV4StackRequest request = new DatabaseServerV4StackRequest();
underTest.setParameters(request, serverParameter);
assertThat(request.getAws().getMultiAZ()).isEqualTo(Boolean.toString(needsHA));
}
use of com.sequenceiq.cloudbreak.service.externaldatabase.model.DatabaseServerParameter in project cloudbreak by hortonworks.
the class ExternalDatabaseServiceTest method provisionDatabaseWhenStackIsNullOnCluster.
@Test
void provisionDatabaseWhenStackIsNullOnCluster() throws JsonProcessingException {
DatabaseServerStatusV4Response createResponse = new DatabaseServerStatusV4Response();
createResponse.setResourceCrn(RDBMS_CRN);
Cluster cluster = spy(new Cluster());
cluster.setStack(null);
when(redbeamsClient.create(any())).thenReturn(createResponse);
when(databaseObtainerService.obtainAttemptResult(eq(cluster), eq(DatabaseOperation.CREATION), eq(RDBMS_CRN), eq(true))).thenReturn(AttemptResults.finishWith(new DatabaseServerV4Response()));
underTest.provisionDatabase(cluster, DatabaseAvailabilityType.NON_HA, environmentResponse);
verify(redbeamsClient, never()).getByClusterCrn(nullable(String.class), nullable(String.class));
ArgumentCaptor<DatabaseServerParameter> serverParameterCaptor = ArgumentCaptor.forClass(DatabaseServerParameter.class);
verify(redbeamsClient).create(any(AllocateDatabaseServerV4Request.class));
verify(cluster).setDatabaseServerCrn(RDBMS_CRN);
verify(dbServerParameterDecorator).setParameters(any(), serverParameterCaptor.capture());
verify(clusterRepository).save(cluster);
DatabaseServerParameter paramValue = serverParameterCaptor.getValue();
assertThat(paramValue.isHighlyAvailable()).isFalse();
}
use of com.sequenceiq.cloudbreak.service.externaldatabase.model.DatabaseServerParameter in project cloudbreak by hortonworks.
the class ExternalDatabaseServiceTest method provisionDatabase.
@ParameterizedTest
@EnumSource(DatabaseAvailabilityType.class)
void provisionDatabase(DatabaseAvailabilityType availabilty) throws JsonProcessingException {
Assumptions.assumeTrue(!availabilty.isEmbedded());
DatabaseServerStatusV4Response createResponse = new DatabaseServerStatusV4Response();
createResponse.setResourceCrn(RDBMS_CRN);
Cluster cluster = spy(new Cluster());
Stack stack = new Stack();
stack.setResourceCrn(CLUSTER_CRN);
cluster.setStack(stack);
when(redbeamsClient.getByClusterCrn(nullable(String.class), nullable(String.class))).thenReturn(null);
when(redbeamsClient.create(any())).thenReturn(createResponse);
when(databaseObtainerService.obtainAttemptResult(eq(cluster), eq(DatabaseOperation.CREATION), eq(RDBMS_CRN), eq(true))).thenReturn(AttemptResults.finishWith(new DatabaseServerV4Response()));
underTest.provisionDatabase(cluster, availabilty, environmentResponse);
ArgumentCaptor<DatabaseServerParameter> serverParameterCaptor = ArgumentCaptor.forClass(DatabaseServerParameter.class);
verify(redbeamsClient).getByClusterCrn(ENV_CRN, CLUSTER_CRN);
verify(redbeamsClient).create(any(AllocateDatabaseServerV4Request.class));
verify(cluster).setDatabaseServerCrn(RDBMS_CRN);
verify(dbServerParameterDecorator).setParameters(any(), serverParameterCaptor.capture());
verify(clusterRepository).save(cluster);
DatabaseServerParameter paramValue = serverParameterCaptor.getValue();
assertThat(paramValue.isHighlyAvailable()).isEqualTo(availabilty == DatabaseAvailabilityType.HA);
}
Aggregations