Search in sources :

Example 1 with Catlet

use of io.mycat.catlets.Catlet in project Mycat-Server by MyCATApache.

the class HintCatletHandler method route.

/**
	 * 从全局的schema列表中查询指定的schema是否存在, 如果存在则替换connection属性中原有的schema,
	 * 如果不存在,则throws SQLNonTransientException,表示指定的schema 不存在
	 * 
	 * @param sysConfig
	 * @param schema
	 * @param sqlType
	 * @param realSQL
	 * @param charset
	 * @param info
	 * @param cachePool
	 * @param hintSQLValue
	 * @return
	 * @throws SQLNonTransientException
	 */
@Override
public RouteResultset route(SystemConfig sysConfig, SchemaConfig schema, int sqlType, String realSQL, String charset, ServerConnection sc, LayerCachePool cachePool, String hintSQLValue, int hintSqlType, Map hintMap) throws SQLNonTransientException {
    // sc.setEngineCtx ctx
    String cateletClass = hintSQLValue;
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("load catelet class:" + hintSQLValue + " to run sql " + realSQL);
    }
    try {
        Catlet catlet = (Catlet) MycatServer.getInstance().getCatletClassLoader().getInstanceofClass(cateletClass);
        catlet.route(sysConfig, schema, sqlType, realSQL, charset, sc, cachePool);
        catlet.processSQL(realSQL, new EngineCtx(sc.getSession2()));
    } catch (Exception e) {
        LOGGER.warn("catlet error " + e);
        throw new SQLNonTransientException(e);
    }
    return null;
}
Also used : SQLNonTransientException(java.sql.SQLNonTransientException) Catlet(io.mycat.catlets.Catlet) EngineCtx(io.mycat.sqlengine.EngineCtx) SQLNonTransientException(java.sql.SQLNonTransientException)

Aggregations

Catlet (io.mycat.catlets.Catlet)1 EngineCtx (io.mycat.sqlengine.EngineCtx)1 SQLNonTransientException (java.sql.SQLNonTransientException)1