Search in sources :

Example 1 with DisabledSqlOptimizer

use of com.hazelcast.sql.impl.optimizer.DisabledSqlOptimizer in project hazelcast by hazelcast.

the class SqlServiceImpl method createOptimizer.

/**
 * Create either normal or not-implemented optimizer instance.
 *
 * @param nodeEngine Node engine.
 * @return Optimizer.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private SqlOptimizer createOptimizer(NodeEngine nodeEngine, QueryResultRegistry resultRegistry) {
    // 1. Resolve class name.
    String className = System.getProperty(OPTIMIZER_CLASS_PROPERTY_NAME, SQL_MODULE_OPTIMIZER_CLASS);
    // 2. Get the class.
    Class clazz;
    try {
        clazz = Class.forName(className);
    } catch (ClassNotFoundException e) {
        logger.log(SQL_MODULE_OPTIMIZER_CLASS.equals(className) ? Level.FINE : Level.WARNING, "Optimizer class \"" + className + "\" not found, falling back to " + DisabledSqlOptimizer.class.getName());
        return new DisabledSqlOptimizer();
    } catch (Exception e) {
        throw new HazelcastException("Failed to resolve optimizer class " + className + ": " + e.getMessage(), e);
    }
    // 3. Get required constructor.
    Constructor<SqlOptimizer> constructor;
    try {
        constructor = clazz.getConstructor(NodeEngine.class, QueryResultRegistry.class);
    } catch (ReflectiveOperationException e) {
        throw new HazelcastException("Failed to get the constructor for the optimizer class " + className + ": " + e.getMessage(), e);
    }
    // 4. Finally, get the instance.
    try {
        return constructor.newInstance(nodeEngine, resultRegistry);
    } catch (ReflectiveOperationException e) {
        throw new HazelcastException("Failed to instantiate the optimizer class " + className + ": " + e.getMessage(), e);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastException(com.hazelcast.core.HazelcastException) QueryResultRegistry(com.hazelcast.sql.impl.state.QueryResultRegistry) DisabledSqlOptimizer(com.hazelcast.sql.impl.optimizer.DisabledSqlOptimizer) DisabledSqlOptimizer(com.hazelcast.sql.impl.optimizer.DisabledSqlOptimizer) SqlOptimizer(com.hazelcast.sql.impl.optimizer.SqlOptimizer) HazelcastException(com.hazelcast.core.HazelcastException) AccessControlException(java.security.AccessControlException)

Aggregations

HazelcastException (com.hazelcast.core.HazelcastException)1 NodeEngine (com.hazelcast.spi.impl.NodeEngine)1 DisabledSqlOptimizer (com.hazelcast.sql.impl.optimizer.DisabledSqlOptimizer)1 SqlOptimizer (com.hazelcast.sql.impl.optimizer.SqlOptimizer)1 QueryResultRegistry (com.hazelcast.sql.impl.state.QueryResultRegistry)1 AccessControlException (java.security.AccessControlException)1