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);
}
}
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();
}
Aggregations