Search in sources :

Example 1 with DatabaseVendor

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor in project cloudbreak by hortonworks.

the class SupportedDatabaseProvider method getSupportedServiceEntry.

private static SupportedExternalDatabaseServiceEntry getSupportedServiceEntry(String name, DatabaseVendor... vendors) {
    SupportedExternalDatabaseServiceEntry entry = new SupportedExternalDatabaseServiceEntry();
    entry.setName(name.toUpperCase().replaceAll(" ", "_"));
    entry.setDisplayName(name);
    for (DatabaseVendor databaseVendor : vendors) {
        entry.getDatabases().add(new SupportedDatabaseEntry(databaseVendor.name(), databaseVendor.displayName(), databaseVendor.jdbcUrlDriverId(), databaseVendor.versions()));
    }
    return entry;
}
Also used : DatabaseVendor(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor)

Example 2 with DatabaseVendor

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor in project cloudbreak by hortonworks.

the class DatabaseVendorUtilTest method testValidUrls.

@Test
public void testValidUrls() {
    for (DatabaseVendor databaseVendor : TO_TEST) {
        String jdbcUrl = "jdbc:" + databaseVendor.jdbcUrlDriverId() + ":etc";
        Optional<DatabaseVendor> foundVendor = underTest.getVendorByJdbcUrl(jdbcUrl);
        assertFalse(foundVendor.isEmpty());
        assertEquals("Expected " + databaseVendor + " but got " + foundVendor.get(), databaseVendor, foundVendor.get());
    }
}
Also used : DatabaseVendor(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor) Test(org.junit.Test)

Example 3 with DatabaseVendor

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor in project cloudbreak by hortonworks.

the class DatabaseV4RequestToRDSConfigConverter method convert.

public RDSConfig convert(DatabaseV4Request source) {
    RDSConfig rdsConfig = new RDSConfig();
    if (Strings.isNullOrEmpty(source.getName())) {
        rdsConfig.setName(missingResourceNameGenerator.generateName(APIResourceType.RDS_CONFIG));
    } else {
        rdsConfig.setName(source.getName());
    }
    rdsConfig.setDescription(source.getDescription());
    rdsConfig.setConnectionURL(source.getConnectionURL());
    DatabaseVendor databaseVendor = DatabaseVendor.getVendorByJdbcUrl(source).get();
    rdsConfig.setDatabaseEngine(databaseVendor);
    rdsConfig.setConnectionDriver(databaseVendor.connectionDriver());
    rdsConfig.setConnectionUserName(source.getConnectionUserName());
    rdsConfig.setConnectionPassword(source.getConnectionPassword());
    rdsConfig.setCreationDate(new Date().getTime());
    rdsConfig.setStatus(ResourceStatus.USER_MANAGED);
    rdsConfig.setType(source.getType());
    if (rdsConfig.getDatabaseEngine() != DatabaseVendor.POSTGRES && StringUtils.isEmpty(source.getConnectorJarUrl())) {
        String msg = String.format("The 'connectorJarUrl' field needs to be specified for database engine: '%s'.", rdsConfig.getDatabaseEngine());
        LOGGER.info(msg);
    }
    rdsConfig.setConnectorJarUrl(source.getConnectorJarUrl());
    return rdsConfig;
}
Also used : DatabaseVendor(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Date(java.util.Date)

Example 4 with DatabaseVendor

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor in project cloudbreak by hortonworks.

the class RDSConfigToDatabaseV4RequestConverter method convert.

public DatabaseV4Request convert(RDSConfig source) {
    DatabaseV4Request rdsConfigRequest = new DatabaseV4Request();
    rdsConfigRequest.setName(source.getName());
    rdsConfigRequest.setConnectorJarUrl(source.getConnectorJarUrl());
    rdsConfigRequest.setConnectionUserName("fake-username");
    rdsConfigRequest.setConnectionPassword("fake-password");
    rdsConfigRequest.setConnectionURL(source.getConnectionURL());
    rdsConfigRequest.setType(source.getType());
    DatabaseVendor databaseEngine = source.getDatabaseEngine();
    rdsConfigRequest.setOracle(prepareOracleRequest(databaseEngine));
    return rdsConfigRequest;
}
Also used : DatabaseVendor(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor) DatabaseV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.database.requests.DatabaseV4Request)

Example 5 with DatabaseVendor

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor in project cloudbreak by hortonworks.

the class RDSConfigToDatabaseV4RequestConverter method prepareOracleRequest.

public OracleParameters prepareOracleRequest(DatabaseVendor databaseEngine) {
    OracleParameters oracleParameters = null;
    if (ORACLE12.equals(databaseEngine) || ORACLE11.equals(databaseEngine)) {
        oracleParameters = new OracleParameters();
        oracleParameters.setVersion(databaseEngine.versions().stream().findFirst().get());
    }
    return oracleParameters;
}
Also used : OracleParameters(com.sequenceiq.cloudbreak.api.endpoint.v4.database.requests.OracleParameters)

Aggregations

DatabaseVendor (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor)8 Test (org.junit.Test)2 DatabaseV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.database.requests.DatabaseV4Request)1 OracleParameters (com.sequenceiq.cloudbreak.api.endpoint.v4.database.requests.OracleParameters)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)1 DatabaseConfig (com.sequenceiq.redbeams.domain.DatabaseConfig)1 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)1 DatabaseServer (com.sequenceiq.redbeams.domain.stack.DatabaseServer)1 Date (java.util.Date)1 EnumMap (java.util.EnumMap)1