Search in sources :

Example 6 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class MySQLPacketUtil method generateColumnDefPayload.

public static final byte[] generateColumnDefPayload(MycatRowMetaData metaData, int columnIndex) {
    try (MySQLPayloadWriter writer = new MySQLPayloadWriter(128)) {
        ColumnDefPacketImpl columnDefPacket;
        if (metaData instanceof MycatMySQLRowMetaData) {
            columnDefPacket = (ColumnDefPacketImpl) ((MycatMySQLRowMetaData) metaData).getColumnDefPackets().get(columnIndex);
        } else {
            columnDefPacket = new ColumnDefPacketImpl(metaData, columnIndex);
        }
        columnDefPacket.writePayload(writer);
        return writer.toByteArray();
    }
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter) MycatMySQLRowMetaData(io.mycat.beans.mycat.MycatMySQLRowMetaData)

Example 7 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class MySQLPacketUtil method generateProgressInfoErrorPacket.

public static final byte[] generateProgressInfoErrorPacket(int stage, int maxStage, int progress, byte[] progressInfo) {
    try (MySQLPayloadWriter writer = new MySQLPayloadWriter(64)) {
        ErrorPacketImpl errorPacket = new ErrorPacketImpl();
        errorPacket.setErrorCode(0xFFFF);
        errorPacket.setErrorStage(stage);
        errorPacket.setErrorMaxStage(maxStage);
        errorPacket.setErrorProgress(progress);
        errorPacket.setErrorProgressInfo(progressInfo);
        return writer.toByteArray();
    }
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter)

Example 8 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class MySQLPacketUtil method generateRequest.

public static final byte[] generateRequest(int head, byte[] data) {
    try (MySQLPayloadWriter writer = new MySQLPayloadWriter(1 + data.length)) {
        writer.write(head);
        writer.write(data);
        return writer.toByteArray();
    }
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter)

Example 9 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class MySQLPacketUtil method generateResetPacket.

public static final byte[] generateResetPacket(long statementId) {
    try (MySQLPayloadWriter writer = new MySQLPayloadWriter(5)) {
        writer.write(0x1a);
        writer.writeFixInt(4, statementId);
        return generateMySQLPacket(0, writer.toByteArray());
    }
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter)

Example 10 with MySQLPayloadWriter

use of io.mycat.beans.mysql.MySQLPayloadWriter in project Mycat2 by MyCATApache.

the class MySQLPacketUtil method generateMySQLCommandRequest.

public static byte[] generateMySQLCommandRequest(int packetId, byte head, byte[] packet) {
    try (MySQLPayloadWriter byteArrayOutput = new MySQLPayloadWriter(1 + packet.length)) {
        byteArrayOutput.write(head);
        byteArrayOutput.write(packet);
        byte[] bytes = byteArrayOutput.toByteArray();
        return generateMySQLPacket(packetId, bytes);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : MySQLPayloadWriter(io.mycat.beans.mysql.MySQLPayloadWriter) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

MySQLPayloadWriter (io.mycat.beans.mysql.MySQLPayloadWriter)31 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 MycatMySQLRowMetaData (io.mycat.beans.mycat.MycatMySQLRowMetaData)2 AuthPacket (io.mycat.beans.mysql.packet.AuthPacket)2 AuthSwitchRequestPacket (io.mycat.beans.mysql.packet.AuthSwitchRequestPacket)2 Authenticator (io.mycat.Authenticator)1 MycatUser (io.mycat.MycatUser)1 HandshakePacket (io.mycat.beans.mysql.packet.HandshakePacket)1 MySQLPacket (io.mycat.beans.mysql.packet.MySQLPacket)1 MySQLServerCapabilityFlags (io.mycat.config.MySQLServerCapabilityFlags)1 UserConfig (io.mycat.config.UserConfig)1 Buffer (io.vertx.core.buffer.Buffer)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1