use of com.sequenceiq.redbeams.domain.stack.DBStackStatus in project cloudbreak by hortonworks.
the class DBStackStatusUpdaterTest method testUpdateStatusSkippedWhenDeleteCompleted.
@Test
public void testUpdateStatusSkippedWhenDeleteCompleted() {
dbStack.setDBStackStatus(new DBStackStatus(dbStack, DetailedDBStackStatus.DELETE_COMPLETED, now));
underTest.updateStatus(1L, DetailedDBStackStatus.PROVISIONED, "because").get();
verify(dbStackService, never()).save(dbStack);
verify(redbeamsInMemoryStateStoreUpdaterService, never()).update(anyLong(), any());
}
use of com.sequenceiq.redbeams.domain.stack.DBStackStatus in project cloudbreak by hortonworks.
the class AllocateDatabaseServerV4RequestToDBStackConverter method convert.
public DBStack convert(AllocateDatabaseServerV4Request source, String ownerCrnString) {
Crn ownerCrn = Crn.safeFromString(ownerCrnString);
CrnUser user = crnUserDetailsService.loadUserByUsername(ownerCrnString);
DetailedEnvironmentResponse environment = environmentService.getByCrn(source.getEnvironmentCrn());
DBStack dbStack = new DBStack();
dbStack.setOwnerCrn(ownerCrn);
dbStack.setUserName(user.getEmail());
CloudPlatform cloudPlatform = updateCloudPlatformAndRelatedFields(source, dbStack, environment.getCloudPlatform());
dbStack.setName(source.getName() != null ? source.getName() : generateDatabaseServerStackName(environment.getName()));
dbStack.setEnvironmentId(source.getEnvironmentCrn());
setRegion(dbStack, environment);
if (source.getDatabaseServer() != null) {
dbStack.setDatabaseServer(buildDatabaseServer(source.getDatabaseServer(), cloudPlatform, ownerCrn, environment.getSecurityAccess()));
}
Map<String, Object> asMap = providerParameterCalculator.get(source).asMap();
if (asMap != null) {
Map<String, String> parameter = new HashMap<>();
asMap.forEach((key, value) -> parameter.put(key, value.toString()));
dbStack.setParameters(parameter);
}
dbStack.setNetwork(buildNetwork(source.getNetwork(), environment, cloudPlatform, dbStack));
Instant now = clock.getCurrentInstant();
dbStack.setDBStackStatus(new DBStackStatus(dbStack, DetailedDBStackStatus.PROVISION_REQUESTED, now.toEpochMilli()));
dbStack.setResourceCrn(crnService.createCrn(dbStack).toString());
dbStack.setTags(getTags(dbStack, source, environment));
dbStack.setSslConfig(getSslConfig(source, dbStack));
return dbStack;
}
use of com.sequenceiq.redbeams.domain.stack.DBStackStatus in project cloudbreak by hortonworks.
the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method initDBStackStatus.
private void initDBStackStatus(DBStack dbStack) {
DBStackStatus dbStackStatus = new DBStackStatus();
dbStackStatus.setStatus(Status.CREATE_IN_PROGRESS);
dbStackStatus.setStatusReason(STATUS_REASON);
dbStack.setDBStackStatus(dbStackStatus);
}
use of com.sequenceiq.redbeams.domain.stack.DBStackStatus in project cloudbreak by hortonworks.
the class DBStackStatusUpdater method updateStatus.
public Optional<DBStack> updateStatus(Long dbStackId, DetailedDBStackStatus detailedStatus, String statusReason) {
return dbStackService.findById(dbStackId).map(dbStack -> {
if (dbStack.getStatus() != Status.DELETE_COMPLETED) {
Status status = detailedStatus.getStatus();
DBStackStatus updatedStatus = new DBStackStatus(dbStack, status, statusReason, detailedStatus, clock.getCurrentTimeMillis());
// The next line is a workaround to get the @OneToOne @MapsId relationship between DBStack and DBStackStatus working
// see https://hibernate.atlassian.net/browse/HHH-12436
// It might be removable once Spring Boot bumps up to Hibernate 5.4
updatedStatus.setId(dbStackId);
dbStack.setDBStackStatus(updatedStatus);
dbStack = dbStackService.save(dbStack);
redbeamsInMemoryStateStoreUpdaterService.update(dbStackId, updatedStatus.getStatus());
}
return dbStack;
});
}
use of com.sequenceiq.redbeams.domain.stack.DBStackStatus in project cloudbreak by hortonworks.
the class DBStackStatusUpdaterTest method testUpdateStatus.
@Test
public void testUpdateStatus() {
dbStack.setDBStackStatus(new DBStackStatus(dbStack, DetailedDBStackStatus.CREATING_INFRASTRUCTURE, now));
DBStack savedStack = underTest.updateStatus(1L, DetailedDBStackStatus.PROVISIONED, "because").get();
verify(dbStackService).save(dbStack);
verify(redbeamsInMemoryStateStoreUpdaterService).update(1L, Status.AVAILABLE);
DBStackStatus dbStackStatus = savedStack.getDbStackStatus();
assertEquals(dbStack, dbStackStatus.getDBStack());
assertEquals(DetailedDBStackStatus.PROVISIONED.getStatus(), dbStackStatus.getStatus());
assertEquals("because", dbStackStatus.getStatusReason());
assertEquals(DetailedDBStackStatus.PROVISIONED, dbStackStatus.getDetailedDBStackStatus());
assertEquals(now, dbStackStatus.getCreated().longValue());
}
Aggregations