Search in sources :

Example 16 with SchemaConfig

use of com.alibaba.cobar.config.model.SchemaConfig in project cobar by alibaba.

the class NoShardingSpace method testDefaultSpace.

public void testDefaultSpace() throws SQLNonTransientException {
    SchemaConfig schema = this.schema;
    String stmt = "insert into offer (member_id, gmt_create) values ('1','2001-09-13 20:20:33')";
    for (int i = 0; i < 1000000; i++) {
        ServerRouter.route(schema, stmt, null, null);
    }
}
Also used : SchemaConfig(com.alibaba.cobar.config.model.SchemaConfig)

Example 17 with SchemaConfig

use of com.alibaba.cobar.config.model.SchemaConfig in project cobar by alibaba.

the class ShardingDefaultSpace method testDefaultSpace.

/**
     * 路由到defaultSpace的性能测试
     */
public void testDefaultSpace() throws SQLNonTransientException {
    SchemaConfig schema = this.getSchema();
    String sql = "insert into xoffer (member_id, gmt_create) values ('1','2001-09-13 20:20:33')";
    for (int i = 0; i < 1000000; i++) {
        ServerRouter.route(schema, sql, null, null);
    }
}
Also used : SchemaConfig(com.alibaba.cobar.config.model.SchemaConfig)

Example 18 with SchemaConfig

use of com.alibaba.cobar.config.model.SchemaConfig in project cobar by alibaba.

the class ShardingMultiTableSpace method testTableSpace.

/**
     * 路由到tableSpace的性能测试
     * 
     * @throws SQLNonTransientException
     */
public void testTableSpace() throws SQLNonTransientException {
    SchemaConfig schema = getSchema();
    String sql = "select id,member_id,gmt_create from offer where member_id in ('1','22','333','1124','4525')";
    for (int i = 0; i < 100000; i++) {
        ServerRouter.route(schema, sql, null, null);
    }
}
Also used : SchemaConfig(com.alibaba.cobar.config.model.SchemaConfig)

Example 19 with SchemaConfig

use of com.alibaba.cobar.config.model.SchemaConfig in project cobar by alibaba.

the class ShardingTableSpaceMain method testTableSpace.

/**
     * 路由到tableSpace的性能测试
     * 
     * @throws SQLNonTransientException
     */
public void testTableSpace() throws SQLNonTransientException {
    SchemaConfig schema = getSchema();
    String sql = "insert into offer (member_id, gmt_create) values ('1','2001-09-13 20:20:33')";
    for (int i = 0; i < 1000000; i++) {
        ServerRouter.route(schema, sql, null, null);
    }
}
Also used : SchemaConfig(com.alibaba.cobar.config.model.SchemaConfig)

Example 20 with SchemaConfig

use of com.alibaba.cobar.config.model.SchemaConfig in project cobar by alibaba.

the class ShowDataNode method execute.

public static void execute(ManagerConnection c, String name) {
    ByteBuffer buffer = c.allocate();
    // write header
    buffer = header.write(buffer, c);
    // write fields
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    // write eof
    buffer = eof.write(buffer, c);
    // write rows
    byte packetId = eof.packetId;
    CobarConfig conf = CobarServer.getInstance().getConfig();
    Map<String, MySQLDataNode> dataNodes = conf.getDataNodes();
    List<String> keys = new ArrayList<String>();
    if (StringUtil.isEmpty(name)) {
        keys.addAll(dataNodes.keySet());
    } else {
        SchemaConfig sc = conf.getSchemas().get(name);
        if (null != sc) {
            keys.addAll(sc.getAllDataNodes());
        }
    }
    Collections.sort(keys, new Comparators<String>());
    for (String key : keys) {
        RowDataPacket row = getRow(dataNodes.get(key), c.getCharset());
        row.packetId = ++packetId;
        buffer = row.write(buffer, c);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    // post write
    c.write(buffer);
}
Also used : MySQLDataNode(com.alibaba.cobar.mysql.MySQLDataNode) SchemaConfig(com.alibaba.cobar.config.model.SchemaConfig) RowDataPacket(com.alibaba.cobar.net.mysql.RowDataPacket) ArrayList(java.util.ArrayList) EOFPacket(com.alibaba.cobar.net.mysql.EOFPacket) CobarConfig(com.alibaba.cobar.CobarConfig) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.alibaba.cobar.net.mysql.FieldPacket)

Aggregations

SchemaConfig (com.alibaba.cobar.config.model.SchemaConfig)27 CobarConfig (com.alibaba.cobar.CobarConfig)6 MySQLDataNode (com.alibaba.cobar.mysql.MySQLDataNode)5 MySQLDataSource (com.alibaba.cobar.mysql.MySQLDataSource)4 RowDataPacket (com.alibaba.cobar.net.mysql.RowDataPacket)4 CobarCluster (com.alibaba.cobar.CobarCluster)3 EOFPacket (com.alibaba.cobar.net.mysql.EOFPacket)3 FieldPacket (com.alibaba.cobar.net.mysql.FieldPacket)3 ByteBuffer (java.nio.ByteBuffer)3 DataSourceConfig (com.alibaba.cobar.config.model.DataSourceConfig)2 QuarantineConfig (com.alibaba.cobar.config.model.QuarantineConfig)2 UserConfig (com.alibaba.cobar.config.model.UserConfig)2 ConfigException (com.alibaba.cobar.config.util.ConfigException)2 SQLNonTransientException (java.sql.SQLNonTransientException)2 ArrayList (java.util.ArrayList)2 CobarNode (com.alibaba.cobar.CobarNode)1 ConfigInitializer (com.alibaba.cobar.ConfigInitializer)1 TableConfig (com.alibaba.cobar.config.model.TableConfig)1 RowExpression (com.alibaba.cobar.parser.ast.expression.primary.RowExpression)1 SQLStatement (com.alibaba.cobar.parser.ast.stmt.SQLStatement)1