use of com.hortonworks.registries.storage.impl.jdbc.provider.sql.factory.QueryExecutor in project registry by hortonworks.
the class JdbcStorageManager method init.
/**
* Initializes this instance with {@link QueryExecutor} created from the given {@code properties}.
* Some of these properties are jdbcDriverClass, jdbcUrl, queryTimeoutInSecs.
*
* @param properties properties with name/value pairs
*/
@Override
public void init(Map<String, Object> properties) {
if (!properties.containsKey(DB_TYPE)) {
throw new IllegalArgumentException("db.type should be set on jdbc properties");
}
String type = (String) properties.get(DB_TYPE);
// For now, keeping it simple as there are only 2.
if (!"mysql".equals(type) && !"postgresql".equals(type) && !"oracle".equals(type)) {
throw new IllegalArgumentException("Unknown jdbc storage provider type: " + type);
}
log.info("jdbc provider type: [{}]", type);
Map<String, Object> dbProperties = (Map<String, Object>) properties.get("db.properties");
QueryExecutor queryExecutor = QueryExecutorFactory.get(type, dbProperties);
this.queryExecutor = queryExecutor;
this.queryExecutor.setStorableFactory(storableFactory);
}
use of com.hortonworks.registries.storage.impl.jdbc.provider.sql.factory.QueryExecutor 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;
}
Aggregations