use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class ClusterToClusterResponseConverter method convert.
protected <R extends ClusterResponse> R convert(Cluster source, Class<R> clazz) throws IllegalAccessException, InstantiationException {
R clusterResponse = clazz.newInstance();
clusterResponse.setId(source.getId());
clusterResponse.setName(source.getName());
clusterResponse.setStatus(source.getStatus());
clusterResponse.setStatusReason(source.getStatusReason());
if (source.getBlueprint() != null) {
clusterResponse.setBlueprintId(source.getBlueprint().getId());
}
long uptime = stackUtil.getUptimeForCluster(source, source.isAvailable());
int minutes = (int) ((uptime / (MILLIS_PER_SECOND * SECONDS_PER_MINUTE)) % SECONDS_PER_MINUTE);
int hours = (int) (uptime / (MILLIS_PER_SECOND * SECONDS_PER_MINUTE * SECONDS_PER_MINUTE));
clusterResponse.setUptime(uptime);
clusterResponse.setHoursUp(hours);
clusterResponse.setMinutesUp(minutes);
Set<RDSConfig> rdsConfigs = source.getRdsConfigs();
convertRdsIds(clusterResponse, rdsConfigs);
if (source.getLdapConfig() != null) {
clusterResponse.setLdapConfigId(source.getLdapConfig().getId());
}
if (source.getAttributes() != null) {
clusterResponse.setAttributes(source.getAttributes().getMap());
}
String ambariIp = stackUtil.extractAmbariIp(source.getStack());
clusterResponse.setAmbariServerIp(ambariIp);
clusterResponse.setUserName(source.getUserName());
clusterResponse.setExecutorType(source.getExecutorType());
clusterResponse.setDescription(source.getDescription() == null ? "" : source.getDescription());
clusterResponse.setExtendedBlueprintText(source.getExtendedBlueprintText() == null ? source.getBlueprint().getBlueprintText() : source.getExtendedBlueprintText());
clusterResponse.setHostGroups(convertHostGroupsToJson(source.getHostGroups()));
clusterResponse.setAmbariServerUrl(getAmbariServerUrl(source, ambariIp));
clusterResponse.setServiceEndPoints(prepareServiceEndpointsMap(source, ambariIp));
clusterResponse.setBlueprintInputs(convertBlueprintInputs(source.getBlueprintInputs()));
clusterResponse.setConfigStrategy(source.getConfigStrategy());
setExtendedBlueprintText(source, clusterResponse);
clusterResponse.setLdapConfig(getConversionService().convert(source.getLdapConfig(), LdapConfigResponse.class));
convertRdsConfigs(source, clusterResponse);
clusterResponse.setBlueprint(getConversionService().convert(source.getBlueprint(), BlueprintResponse.class));
convertKnox(source, clusterResponse);
convertCustomQueue(source, clusterResponse);
if (source.getBlueprintCustomProperties() != null) {
clusterResponse.setBlueprintCustomProperties(jsonHelper.createJsonFromString(source.getBlueprintCustomProperties()));
}
convertContainerConfig(source, clusterResponse);
convertComponentConfig(clusterResponse, source);
clusterResponse.setCreationFinished(source.getCreationFinished());
KerberosConfig kerberosConfig = source.getKerberosConfig();
if (source.isSecure() && kerberosConfig != null) {
clusterResponse.setSecure(source.isSecure());
clusterResponse.setKerberosResponse(getConversionService().convert(source.getKerberosConfig(), KerberosResponse.class));
}
decorateResponseWithProxyConfig(source, clusterResponse);
return clusterResponse;
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class RDSConfigRequestToRDSConfigConverter method convert.
@Override
public RDSConfig convert(RDSConfigRequest source) {
RDSConfig rdsConfig = new RDSConfig();
if (Strings.isNullOrEmpty(source.getName())) {
rdsConfig.setName(missingResourceNameGenerator.generateName(APIResourceType.RDS_CONFIG));
} else {
rdsConfig.setName(source.getName());
}
rdsConfig.setConnectionURL(source.getConnectionURL());
Optional<DatabaseVendor> databaseVendor = DatabaseVendor.getVendorByJdbcUrl(source.getConnectionURL());
if (databaseVendor.isPresent()) {
rdsConfig.setDatabaseEngine(databaseVendor.get().name());
rdsConfig.setConnectionDriver(databaseVendor.get().connectionDriver());
} else {
throw new BadRequestException("Not a valid DatabaseVendor which was provided in the jdbc url.");
}
rdsConfig.setConnectionUserName(source.getConnectionUserName());
rdsConfig.setConnectionPassword(source.getConnectionPassword());
rdsConfig.setCreationDate(new Date().getTime());
rdsConfig.setStatus(ResourceStatus.USER_MANAGED);
rdsConfig.setType(source.getType());
return rdsConfig;
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class ClusterDecorator method prepareRds.
private void prepareRds(Cluster subject, IdentityUser user, ClusterRequest request, Stack stack) {
subject.setRdsConfigs(new HashSet<>());
if (request.getRdsConfigIds() != null) {
for (Long rdsConfigId : request.getRdsConfigIds()) {
RDSConfig rdsConfig = rdsConfigService.get(rdsConfigId);
subject.getRdsConfigs().add(rdsConfig);
}
}
if (request.getRdsConfigJsons() != null) {
for (RDSConfigRequest requestRdsConfig : request.getRdsConfigJsons()) {
RDSConfig rdsConfig = conversionService.convert(requestRdsConfig, RDSConfig.class);
rdsConfig.setPublicInAccount(stack.isPublicInAccount());
rdsConfig = rdsConfigService.createIfNotExists(user, rdsConfig);
subject.getRdsConfigs().add(rdsConfig);
}
}
Optional.of(request.getRdsConfigNames()).ifPresent(confs -> confs.forEach(confName -> subject.getRdsConfigs().add(rdsConfigService.getPublicRdsConfig(confName, user))));
if (request.getAmbariDatabaseDetails() != null) {
RDSConfig rdsConfig = ambariDatabaseMapper.mapAmbariDatabaseDetailsJsonToRdsConfig(request.getAmbariDatabaseDetails(), subject, stack, stack.isPublicInAccount());
subject.getRdsConfigs().add(rdsConfigService.createIfNotExists(user, rdsConfig));
}
ambariConfigurationService.createDefaultRdsConfigIfNeeded(stack, subject).ifPresent(rdsConfig -> subject.getRdsConfigs().add(rdsConfig));
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class ClusterTerminationService method finalizeClusterTermination.
public void finalizeClusterTermination(Long clusterId) {
Cluster cluster = clusterRepository.findById(clusterId);
Set<RDSConfig> rdsConfigs = cluster.getRdsConfigs();
Long stackId = cluster.getStack().getId();
String terminatedName = cluster.getName() + DELIMITER + new Date().getTime();
cluster.setName(terminatedName);
FileSystem fs = cluster.getFileSystem();
if (fs != null) {
deleteFileSystemResources(stackId, fs);
}
cluster.setBlueprint(null);
cluster.setStack(null);
cluster.setLdapConfig(null);
cluster.setRdsConfigs(new HashSet<>());
cluster.setProxyConfig(null);
cluster.setStatus(DELETE_COMPLETED);
deleteClusterHostGroupsWithItsMetadata(cluster);
rdsConfigService.deleteDefaultRdsConfigs(rdsConfigs);
componentConfigProvider.deleteComponentsForStack(stackId);
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class TestUtil method cluster.
public static Cluster cluster(Blueprint blueprint, Stack stack, Long id, KerberosConfig kerberosConfig) {
Cluster cluster = new Cluster();
cluster.setAmbariIp("50.51.52.100");
cluster.setStack(stack);
cluster.setId(id);
cluster.setName("dummyCluster");
cluster.setAmbariIp("10.0.0.1");
cluster.setBlueprint(blueprint);
cluster.setUpSince(new Date().getTime());
cluster.setStatus(AVAILABLE);
cluster.setStatusReason("statusReason");
cluster.setUserName("admin");
cluster.setPassword("admin");
Gateway gateway = new Gateway();
gateway.setEnableGateway(true);
gateway.setTopologyName("cb");
cluster.setGateway(gateway);
cluster.setExecutorType(ExecutorType.DEFAULT);
RDSConfig rdsConfig = new RDSConfig();
Set<RDSConfig> rdsConfigs = new HashSet<>();
rdsConfigs.add(rdsConfig);
cluster.setRdsConfigs(rdsConfigs);
cluster.setLdapConfig(ldapConfig());
cluster.setHostGroups(hostGroups(cluster));
Map<String, String> inputs = new HashMap<>();
inputs.put("S3_BUCKET", "testbucket");
try {
cluster.setBlueprintInputs(new Json(inputs));
} catch (JsonProcessingException ignored) {
cluster.setBlueprintInputs(null);
}
Map<String, String> map = new HashMap<>();
try {
cluster.setAttributes(new Json(map));
} catch (JsonProcessingException ignored) {
cluster.setAttributes(null);
}
if (kerberosConfig != null) {
cluster.setSecure(true);
cluster.setKerberosConfig(kerberosConfig);
}
return cluster;
}
Aggregations