當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。