当前位置: 首页>>代码示例>>Java>>正文


Java ServerConnection.allocate方法代码示例

本文整理汇总了Java中com.alibaba.cobar.server.ServerConnection.allocate方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConnection.allocate方法的具体用法?Java ServerConnection.allocate怎么用?Java ServerConnection.allocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.cobar.server.ServerConnection的用法示例。


在下文中一共展示了ServerConnection.allocate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = header.write(buffer, c);
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    buffer = eof.write(buffer, c);
    byte packetId = eof.packetId;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(FrontendConnection.getServerVersion().getBytes());
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:SelectVersion.java

示例2: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = header.write(buffer, c);
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    buffer = eof.write(buffer, c);
    byte packetId = eof.packetId;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(getUser(c));
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:SelectUser.java

示例3: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = header.write(buffer, c);
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    buffer = eof.write(buffer, c);
    byte packetId = eof.packetId;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(StringUtil.encode(c.getSchema(), c.getCharset()));
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:SelectDatabase.java

示例4: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = header.write(buffer, c);
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    buffer = eof.write(buffer, c);
    byte packetId = eof.packetId;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(Versions.SERVER_VERSION);
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    c.write(buffer);
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:18,代码来源:SelectVersion.java

示例5: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    if (CobarServer.getInstance().isOnline()) {
        ByteBuffer buffer = c.allocate();
        buffer = header.write(buffer, c);
        for (FieldPacket field : fields) {
            buffer = field.write(buffer, c);
        }
        buffer = eof.write(buffer, c);
        byte packetId = eof.packetId;
        RowDataPacket row = new RowDataPacket(FIELD_COUNT);
        row.add(getUser(c));
        row.packetId = ++packetId;
        buffer = row.write(buffer, c);
        EOFPacket lastEof = new EOFPacket();
        lastEof.packetId = ++packetId;
        buffer = lastEof.write(buffer, c);
        c.write(buffer);
    } else {
        error.write(c);
    }
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:22,代码来源:SelectUser.java

示例6: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    if (CobarServer.getInstance().isOnline()) {
        ByteBuffer buffer = c.allocate();
        buffer = header.write(buffer, c);
        for (FieldPacket field : fields) {
            buffer = field.write(buffer, c);
        }
        buffer = eof.write(buffer, c);
        buffer = status.write(buffer, c);
        buffer = lastEof.write(buffer, c);
        c.write(buffer);
    } else {
        error.write(c);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:16,代码来源:ShowCobarStatus.java

示例7: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    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;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(VERSION_COMMENT);
    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);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:30,代码来源:SelectVersionComment.java

示例8: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c, String stmt, int aliasIndex) {
    String alias = ParseUtil.parseAlias(stmt, aliasIndex);
    if (alias == null) {
        alias = ORG_NAME;
    }

    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c);

    // write fields
    byte packetId = header.packetId;
    FieldPacket field = PacketUtil.getField(alias, ORG_NAME, Fields.FIELD_TYPE_LONGLONG);
    field.packetId = ++packetId;
    buffer = field.write(buffer, c);

    // write eof
    EOFPacket eof = new EOFPacket();
    eof.packetId = ++packetId;
    buffer = eof.write(buffer, c);

    // write rows
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(LongUtil.toBytes(c.getLastInsertId()));
    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);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:37,代码来源:SelectLastInsertId.java

示例9: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c, String stmt, int aliasIndex, final String orgName) {
    String alias = ParseUtil.parseAlias(stmt, aliasIndex);
    if (alias == null) {
        alias = orgName;
    }

    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c);

    // write fields
    byte packetId = header.packetId;
    FieldPacket field = PacketUtil.getField(alias, orgName, Fields.FIELD_TYPE_LONGLONG);
    field.packetId = ++packetId;
    buffer = field.write(buffer, c);

    // write eof
    EOFPacket eof = new EOFPacket();
    eof.packetId = ++packetId;
    buffer = eof.write(buffer, c);

    // write rows
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(LongUtil.toBytes(c.getLastInsertId()));
    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);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:37,代码来源:SelectIdentity.java

示例10: execute

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void execute(ServerConnection c) {
    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;
    String charset = c.getCharset();
    for (NIOProcessor p : CobarServer.getInstance().getProcessors()) {
        for (FrontendConnection fc : p.getFrontends().values()) {

            if (fc != null) {

                if (c.getUser().equals(fc.getUser())) {
                    RowDataPacket row = getRow(fc, charset);
                    row.packetId = ++packetId;
                    buffer = row.write(buffer, c);
                }

            }
        }
    }

    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);

    // write buffer
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:41,代码来源:ShowConnection.java

示例11: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c);

    // write field
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }

    // write eof
    buffer = eof.write(buffer, c);

    // write rows
    byte packetId = eof.packetId;
    Map<String, MySQLDataNode> nodes = CobarServer.getInstance().getConfig().getDataNodes();
    for (MySQLDataNode node : nodes.values()) {
        RowDataPacket row = getRow(node, 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);
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:32,代码来源:ShowDataSources.java

示例12: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c);

    // write field
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }

    // write eof
    buffer = eof.write(buffer, c);

    // write rows
    byte packetId = eof.packetId;
    for (RowDataPacket row : getRows(c)) {
        row.packetId = ++packetId;
        buffer = row.write(buffer, c);
    }

    // last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);

    // post write
    c.write(buffer);
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:30,代码来源:ShowCobarCluster.java

示例13: execute

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void execute(ServerConnection c) {
    // 取得SCHEMA
    String db = c.getSchema();
    if (db == null) {
        c.writeErrMessage(ErrorCode.ER_NO_DB_ERROR, "No database selected");
        return;
    }

    SchemaConfig schema = CobarServer.getInstance().getConfig().getSchemas().get(db);
    if (schema == null) {
        c.writeErrMessage(ErrorCode.ER_BAD_DB_ERROR, "Unknown database '" + db + "'");
        return;
    }
    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;

    SQLRecord[] records = schema.getDataSource().getRecorder().getRecords();
    for (int i = records.length - 1; i >= 0; i--) {
        if (records[i] != null) {
            RowDataPacket row = getRow(records[i], 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);

    // write buffer
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:47,代码来源:ShowPhysicalSQLSlow.java

示例14: execute

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void execute(ServerConnection c) {
    // 取得SCHEMA
    String db = c.getSchema();
    if (db == null) {
        c.writeErrMessage(ErrorCode.ER_NO_DB_ERROR, "No database selected");
        return;
    }

    SchemaConfig schema = CobarServer.getInstance().getConfig().getSchemas().get(db);
    if (schema == null) {
        c.writeErrMessage(ErrorCode.ER_BAD_DB_ERROR, "Unknown database '" + db + "'");
        return;
    }
    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;

    SQLRecord[] records = schema.getRecorder().getRecords();
    for (int i = records.length - 1; i >= 0; i--) {
        if (records[i] != null) {
            RowDataPacket row = getRow(records[i], 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);

    // write buffer
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:47,代码来源:ShowSQLSlow.java

示例15: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    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, UserConfig> users = conf.getUsers();
    UserConfig user = users == null ? null : users.get(c.getUser());
    if (user != null) {
        TreeSet<String> schemaSet = new TreeSet<String>();
        Set<String> schemaList = user.getSchemas();
        if (schemaList == null || schemaList.size() == 0) {
            schemaSet.addAll(conf.getSchemas().keySet());
        } else {
            for (String schema : schemaList) {
                schemaSet.add(schema);
            }
        }
        for (String name : schemaSet) {
            RowDataPacket row = new RowDataPacket(FIELD_COUNT);
            row.add(StringUtil.encode(name, 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);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:46,代码来源:ShowDatabases.java


注:本文中的com.alibaba.cobar.server.ServerConnection.allocate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。