Search in sources :

Example 21 with RouteResultset

use of com.actiontech.dble.route.RouteResultset in project dble by actiontech.

the class ShowVariables method response.

public static void response(ServerConnection c, String stmt) {
    String db = c.getSchema() != null ? c.getSchema() : SchemaUtil.getRandomDb();
    SchemaConfig schema = DbleServer.getInstance().getConfig().getSchemas().get(db);
    if (schema == null) {
        c.writeErrMessage("42000", "Unknown database '" + db + "'", ErrorCode.ER_BAD_DB_ERROR);
        return;
    }
    RouteResultset rrs = new RouteResultset(stmt, ServerParse.SHOW);
    try {
        RouterUtil.routeToSingleNode(rrs, schema.getRandomDataNode());
        ShowVariablesHandler handler = new ShowVariablesHandler(rrs, c.getSession2());
        handler.execute();
    } catch (Exception e) {
        // Could this only be ER_PARSE_ERROR?
        c.writeErrMessage(ErrorCode.ER_PARSE_ERROR, e.toString());
    }
}
Also used : SchemaConfig(com.actiontech.dble.config.model.SchemaConfig) RouteResultset(com.actiontech.dble.route.RouteResultset) ShowVariablesHandler(com.actiontech.dble.backend.mysql.nio.handler.ShowVariablesHandler)

Example 22 with RouteResultset

use of com.actiontech.dble.route.RouteResultset in project dble by actiontech.

the class MergeBuilder method constructByStatement.

public RouteResultset constructByStatement(String sql, SQLSelectStatement select) throws SQLException {
    ServerSchemaStatVisitor visitor = new ServerSchemaStatVisitor();
    DruidParser druidParser = new DruidSingleUnitSelectParser();
    RouteResultset rrs = new RouteResultset(sql, ServerParse.SELECT);
    LayerCachePool pool = DbleServer.getInstance().getRouterService().getTableId2DataNodeCache();
    SchemaConfig schemaConfig = schemaConfigMap.get(node.getReferedTableNodes().get(0).getSchema());
    return RouterUtil.routeFromParser(druidParser, schemaConfig, rrs, select, sql, pool, visitor, session.getSource());
}
Also used : DruidSingleUnitSelectParser(com.actiontech.dble.route.parser.druid.impl.DruidSingleUnitSelectParser) ServerSchemaStatVisitor(com.actiontech.dble.route.parser.druid.ServerSchemaStatVisitor) SchemaConfig(com.actiontech.dble.config.model.SchemaConfig) DruidParser(com.actiontech.dble.route.parser.druid.DruidParser) LayerCachePool(com.actiontech.dble.cache.LayerCachePool) RouteResultset(com.actiontech.dble.route.RouteResultset)

Aggregations

RouteResultset (com.actiontech.dble.route.RouteResultset)22 RouteResultsetNode (com.actiontech.dble.route.RouteResultsetNode)8 SQLNonTransientException (java.sql.SQLNonTransientException)8 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)6 TableConfig (com.actiontech.dble.config.model.TableConfig)4 SQLException (java.sql.SQLException)4 RouteCalculateUnit (com.actiontech.dble.route.parser.druid.RouteCalculateUnit)3 IOException (java.io.IOException)3 FetchStoreNodeOfChildTableHandler (com.actiontech.dble.backend.mysql.nio.handler.FetchStoreNodeOfChildTableHandler)2 DruidShardingParseInfo (com.actiontech.dble.route.parser.druid.DruidShardingParseInfo)2 LoadData (com.actiontech.dble.sqlengine.mpp.LoadData)2 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)2 MySqlStatementParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)2 ByteBuffer (java.nio.ByteBuffer)2 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)1 ShowTablesHandler (com.actiontech.dble.backend.mysql.nio.handler.ShowTablesHandler)1 ShowVariablesHandler (com.actiontech.dble.backend.mysql.nio.handler.ShowVariablesHandler)1 SingleNodeHandler (com.actiontech.dble.backend.mysql.nio.handler.SingleNodeHandler)1 LayerCachePool (com.actiontech.dble.cache.LayerCachePool)1 ServerConfig (com.actiontech.dble.config.ServerConfig)1