Search in sources :

Example 1 with QueryResultRegistry

use of com.hazelcast.sql.impl.state.QueryResultRegistry 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)

Example 2 with QueryResultRegistry

use of com.hazelcast.sql.impl.state.QueryResultRegistry in project hazelcast by hazelcast.

the class SqlServiceImpl method start.

public void start() {
    QueryResultRegistry resultRegistry = new QueryResultRegistry();
    optimizer = createOptimizer(nodeEngine, resultRegistry);
    String instanceName = nodeEngine.getHazelcastInstance().getName();
    PlanCacheChecker planCacheChecker = new PlanCacheChecker(nodeEngine, planCache, optimizer.tableResolvers());
    internalService = new SqlInternalService(resultRegistry, instanceName, nodeServiceProvider, STATE_CHECK_FREQUENCY, planCacheChecker);
    internalService.start();
}
Also used : QueryResultRegistry(com.hazelcast.sql.impl.state.QueryResultRegistry) PlanCacheChecker(com.hazelcast.sql.impl.plan.cache.PlanCacheChecker)

Aggregations

QueryResultRegistry (com.hazelcast.sql.impl.state.QueryResultRegistry)2 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 PlanCacheChecker (com.hazelcast.sql.impl.plan.cache.PlanCacheChecker)1 AccessControlException (java.security.AccessControlException)1