Search in sources :

Example 1 with HikariCPConnectionBuilder

use of com.hortonworks.registries.storage.impl.jdbc.connection.HikariCPConnectionBuilder in project registry by hortonworks.

the class QueryExecutorFactory method getHikariCPConnnectionBuilder.

private static HikariCPConnectionBuilder getHikariCPConnnectionBuilder(Map<String, Object> dbProperties) {
    Util.validateJDBCProperties(dbProperties, Lists.newArrayList("dataSourceClassName", "dataSource.url"));
    String dataSourceClassName = (String) dbProperties.get("dataSourceClassName");
    LOG.info("data source class: [{}]", dataSourceClassName);
    String jdbcUrl = (String) dbProperties.get("dataSource.url");
    LOG.info("dataSource.url is: [{}] ", jdbcUrl);
    Properties properties = new Properties();
    properties.putAll(dbProperties);
    HikariConfig hikariConfig = new HikariConfig(properties);
    return new HikariCPConnectionBuilder(hikariConfig);
}
Also used : HikariCPConnectionBuilder(com.hortonworks.registries.storage.impl.jdbc.connection.HikariCPConnectionBuilder) Properties(java.util.Properties) HikariConfig(com.zaxxer.hikari.HikariConfig)

Example 2 with HikariCPConnectionBuilder

use of com.hortonworks.registries.storage.impl.jdbc.connection.HikariCPConnectionBuilder in project registry by hortonworks.

the class DbFileStorageTest method setUp.

@Before
public void setUp() throws Exception {
    connectionBuilder = new HikariCPConnectionBuilder(HikariBasicConfig.getH2HikariConfig());
    MySqlExecutor queryExecutor = new MySqlExecutor(new ExecutionConfig(-1), connectionBuilder);
    StorageManager jdbcStorageManager = new JdbcStorageManager(queryExecutor);
    transactionManager = (TransactionManager) jdbcStorageManager;
    jdbcStorageManager.registerStorables(StorageUtils.getStorableEntities());
    dbFileStorage = new DbFileStorage();
    dbFileStorage.setStorageManager(jdbcStorageManager);
    runScript("create_fileblob.sql");
}
Also used : HikariCPConnectionBuilder(com.hortonworks.registries.storage.impl.jdbc.connection.HikariCPConnectionBuilder) MySqlExecutor(com.hortonworks.registries.storage.impl.jdbc.provider.mysql.factory.MySqlExecutor) JdbcStorageManager(com.hortonworks.registries.storage.impl.jdbc.JdbcStorageManager) StorageManager(com.hortonworks.registries.storage.StorageManager) ExecutionConfig(com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig) JdbcStorageManager(com.hortonworks.registries.storage.impl.jdbc.JdbcStorageManager) Before(org.junit.Before)

Example 3 with HikariCPConnectionBuilder

use of com.hortonworks.registries.storage.impl.jdbc.connection.HikariCPConnectionBuilder in project registry by hortonworks.

the class TransactionTest method setUp.

@Before
public void setUp() throws Exception {
    connectionBuilder = new HikariCPConnectionBuilder(HikariBasicConfig.getH2HikariConfig());
    MySqlExecutor queryExecutor = new MySqlExecutor(new ExecutionConfig(-1), connectionBuilder);
    StorageManager jdbcStorageManager = new JdbcStorageManager(queryExecutor);
    transactionManager = (TransactionManager) jdbcStorageManager;
    jdbcStorageManager.registerStorables(StorageUtils.getStorableEntities());
    dbFileStorage = new DbFileStorage();
    dbFileStorage.setStorageManager(jdbcStorageManager);
    runScript("create_fileblob.sql");
}
Also used : HikariCPConnectionBuilder(com.hortonworks.registries.storage.impl.jdbc.connection.HikariCPConnectionBuilder) MySqlExecutor(com.hortonworks.registries.storage.impl.jdbc.provider.mysql.factory.MySqlExecutor) JdbcStorageManager(com.hortonworks.registries.storage.impl.jdbc.JdbcStorageManager) StorageManager(com.hortonworks.registries.storage.StorageManager) ExecutionConfig(com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig) JdbcStorageManager(com.hortonworks.registries.storage.impl.jdbc.JdbcStorageManager) Before(org.junit.Before)

Example 4 with HikariCPConnectionBuilder

use of com.hortonworks.registries.storage.impl.jdbc.connection.HikariCPConnectionBuilder in project registry by hortonworks.

the class QueryExecutorFactory method get.

public static QueryExecutor get(String type, Map<String, Object> dbProperties) {
    HikariCPConnectionBuilder connectionBuilder = getHikariCPConnnectionBuilder(dbProperties);
    ExecutionConfig executionConfig = getExecutionConfig(dbProperties);
    QueryExecutor queryExecutor = null;
    switch(type) {
        case "mysql":
            queryExecutor = new MySqlExecutor(executionConfig, connectionBuilder);
            break;
        case "postgresql":
            queryExecutor = new PostgresqlExecutor(executionConfig, connectionBuilder);
            break;
        case "oracle":
            queryExecutor = new OracleExecutor(executionConfig, connectionBuilder);
            break;
        default:
            throw new IllegalArgumentException("Unsupported storage provider type: " + type);
    }
    return queryExecutor;
}
Also used : HikariCPConnectionBuilder(com.hortonworks.registries.storage.impl.jdbc.connection.HikariCPConnectionBuilder) MySqlExecutor(com.hortonworks.registries.storage.impl.jdbc.provider.mysql.factory.MySqlExecutor) PostgresqlExecutor(com.hortonworks.registries.storage.impl.jdbc.provider.postgresql.factory.PostgresqlExecutor) QueryExecutor(com.hortonworks.registries.storage.impl.jdbc.provider.sql.factory.QueryExecutor) OracleExecutor(com.hortonworks.registries.storage.impl.jdbc.provider.oracle.factory.OracleExecutor) ExecutionConfig(com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig)

Aggregations

HikariCPConnectionBuilder (com.hortonworks.registries.storage.impl.jdbc.connection.HikariCPConnectionBuilder)4 ExecutionConfig (com.hortonworks.registries.storage.impl.jdbc.config.ExecutionConfig)3 MySqlExecutor (com.hortonworks.registries.storage.impl.jdbc.provider.mysql.factory.MySqlExecutor)3 StorageManager (com.hortonworks.registries.storage.StorageManager)2 JdbcStorageManager (com.hortonworks.registries.storage.impl.jdbc.JdbcStorageManager)2 Before (org.junit.Before)2 OracleExecutor (com.hortonworks.registries.storage.impl.jdbc.provider.oracle.factory.OracleExecutor)1 PostgresqlExecutor (com.hortonworks.registries.storage.impl.jdbc.provider.postgresql.factory.PostgresqlExecutor)1 QueryExecutor (com.hortonworks.registries.storage.impl.jdbc.provider.sql.factory.QueryExecutor)1 HikariConfig (com.zaxxer.hikari.HikariConfig)1 Properties (java.util.Properties)1