use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.base.DatabaseType in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method decoratePillarWithJdbcConnectors.
private void decoratePillarWithJdbcConnectors(Cluster cluster, Map<String, SaltPillarProperties> servicePillar) {
Set<RdsConfigWithoutCluster> rdsConfigs = rdsConfigWithoutClusterService.findByClusterId(cluster.getId());
Map<String, Object> connectorJarUrlsByVendor = new HashMap<>();
rdsConfigs.stream().filter(rds -> isNotEmpty(rds.getConnectorJarUrl())).forEach(rdsConfig -> {
connectorJarUrlsByVendor.put("databaseType", rdsConfig.getDatabaseEngine().databaseType());
connectorJarUrlsByVendor.put("connectorJarUrl", rdsConfig.getConnectorJarUrl());
connectorJarUrlsByVendor.put("connectorJarName", rdsConfig.getDatabaseEngine().connectorJarName());
});
if (!connectorJarUrlsByVendor.isEmpty()) {
Map<String, Object> jdbcConnectors = singletonMap("jdbc_connectors", connectorJarUrlsByVendor);
servicePillar.put("jdbc-connectors", new SaltPillarProperties("/jdbc/connectors.sls", jdbcConnectors));
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.base.DatabaseType in project cloudbreak by hortonworks.
the class ClusterServicesRestartService method updateDatabaseConfiguration.
private void updateDatabaseConfiguration(Stack datalakeStack, Stack dataHubStack, String service, DatabaseType databaseType) {
Cluster cluster = clusterService.getById(datalakeStack.getCluster().getId());
Optional<RDSConfig> rdsConfig = postgresConfigService.createRdsConfigIfNeeded(datalakeStack, cluster, databaseType).stream().filter(config -> config.getType().toLowerCase().equals(databaseType.toString().toLowerCase())).findFirst();
try {
if (rdsConfig.isPresent()) {
LOGGER.info("Refreshing the database configuration.");
apiConnectors.getConnector(dataHubStack).updateServiceConfig(service, getRdsConfigMap(rdsConfig.get()));
} else {
LOGGER.error("Could not find RDS configuration for Hive");
}
} catch (CloudbreakException e) {
LOGGER.info("Exception while updating the Data-Hub configuration", e);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.base.DatabaseType in project cloudbreak by hortonworks.
the class ClusterService method withEmbeddedClusterManagerDB.
public boolean withEmbeddedClusterManagerDB(Cluster cluster) {
DatabaseType databaseType = DatabaseType.CLOUDERA_MANAGER;
RDSConfig rdsConfig = rdsConfigService.findByClusterIdAndType(cluster.getId(), databaseType);
return (rdsConfig == null || ResourceStatus.DEFAULT == rdsConfig.getStatus()) && cluster.getDatabaseServerCrn() == null;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.base.DatabaseType in project cloudbreak by hortonworks.
the class RdsConfigValidatorTest method requestWithDatabases.
private ClusterV4Request requestWithDatabases(DatabaseType... databaseTypes) {
List<RDSConfig> rdsConfigs = Arrays.stream(databaseTypes).map(TestUtil::rdsConfig).collect(toList());
rdsConfigs.forEach(each -> when(rdsConfigService.getByNameForWorkspace(each.getName(), workspace)).thenReturn(each));
ClusterV4Request request = new ClusterV4Request();
request.setDatabases(rdsConfigs.stream().map(RDSConfig::getName).collect(toSet()));
return request;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.base.DatabaseType in project cloudbreak by hortonworks.
the class DatabaseServerConfigServiceTest method testCreateDatabaseOnServer.
@Test
public void testCreateDatabaseOnServer() {
when(repository.findByResourceCrn(SERVER_CRN)).thenReturn(Optional.of(server));
when(databaseConfigService.register(any(DatabaseConfig.class), eq(false))).thenAnswer((Answer<DatabaseConfig>) invocation -> {
return invocation.getArgument(0, DatabaseConfig.class);
});
when(userGeneratorService.generateUserName()).thenReturn(USERNAME);
when(passwordGeneratorService.generatePassword(any())).thenReturn(PASSWORD);
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setHost("myhost");
server.setPort(5432);
server.setConnectionUserName("root");
server.setConnectionPassword("rootpassword");
String databaseName = "mydb";
String databaseType = "hive";
Optional<String> databaseDescription = Optional.of("mine not yours");
String result = underTest.createDatabaseOnServer(SERVER_CRN.toString(), databaseName, databaseType, databaseDescription);
assertEquals("created", result);
verify(driverFunctions).execWithDatabaseDriver(eq(server), any());
ArgumentCaptor<DatabaseConfig> captor = ArgumentCaptor.forClass(DatabaseConfig.class);
verify(databaseConfigService).register(captor.capture(), eq(false));
DatabaseConfig db = captor.getValue();
assertEquals(databaseName, db.getName());
assertEquals(databaseType, db.getType());
assertEquals(databaseDescription.get(), db.getDescription());
String databaseUserName = db.getConnectionUserName().getRaw();
assertEquals(USERNAME, databaseUserName);
assertNotEquals(server.getConnectionUserName(), databaseUserName);
assertEquals(PASSWORD, db.getConnectionPassword().getRaw());
}
Aggregations