Search in sources :

Example 1 with MySQLPacketPayload

use of io.shardingjdbc.proxy.transport.mysql.packet.MySQLPacketPayload in project sharding-jdbc by shardingjdbc.

the class MySQLFrontendHandler method auth.

@Override
protected void auth(final ChannelHandlerContext context, final ByteBuf message) {
    MySQLPacketPayload mysqlPacketPayload = new MySQLPacketPayload(message);
    // TODO use authPluginData to auth
    HandshakeResponse41Packet response41 = new HandshakeResponse41Packet(mysqlPacketPayload);
    context.writeAndFlush(new OKPacket(response41.getSequenceId() + 1, 0L, 0L, StatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue(), 0, ""));
}
Also used : HandshakeResponse41Packet(io.shardingjdbc.proxy.transport.mysql.packet.handshake.HandshakeResponse41Packet) MySQLPacketPayload(io.shardingjdbc.proxy.transport.mysql.packet.MySQLPacketPayload) OKPacket(io.shardingjdbc.proxy.transport.mysql.packet.generic.OKPacket)

Example 2 with MySQLPacketPayload

use of io.shardingjdbc.proxy.transport.mysql.packet.MySQLPacketPayload in project sharding-jdbc by shardingjdbc.

the class MySQLFrontendHandler method executeCommand.

@Override
protected void executeCommand(final ChannelHandlerContext context, final ByteBuf message) {
    MySQLPacketPayload mysqlPacketPayload = new MySQLPacketPayload(message);
    int sequenceId = mysqlPacketPayload.readInt1();
    CommandPacket commandPacket = CommandPacketFactory.getCommandPacket(sequenceId, mysqlPacketPayload);
    for (DatabaseProtocolPacket each : commandPacket.execute()) {
        context.write(each);
    }
    context.flush();
}
Also used : MySQLPacketPayload(io.shardingjdbc.proxy.transport.mysql.packet.MySQLPacketPayload) DatabaseProtocolPacket(io.shardingjdbc.proxy.transport.common.packet.DatabaseProtocolPacket) CommandPacket(io.shardingjdbc.proxy.transport.mysql.packet.command.CommandPacket)

Example 3 with MySQLPacketPayload

use of io.shardingjdbc.proxy.transport.mysql.packet.MySQLPacketPayload in project sharding-jdbc by shardingjdbc.

the class MySQLPacketCodec method doEncode.

@Override
protected void doEncode(final ChannelHandlerContext context, final MySQLPacket message, final ByteBuf out) {
    MySQLPacketPayload mysqlPacketPayload = new MySQLPacketPayload(context.alloc().buffer());
    message.write(mysqlPacketPayload);
    out.writeMediumLE(mysqlPacketPayload.getByteBuf().readableBytes());
    out.writeByte(message.getSequenceId());
    out.writeBytes(mysqlPacketPayload.getByteBuf());
}
Also used : MySQLPacketPayload(io.shardingjdbc.proxy.transport.mysql.packet.MySQLPacketPayload)

Aggregations

MySQLPacketPayload (io.shardingjdbc.proxy.transport.mysql.packet.MySQLPacketPayload)3 DatabaseProtocolPacket (io.shardingjdbc.proxy.transport.common.packet.DatabaseProtocolPacket)1 CommandPacket (io.shardingjdbc.proxy.transport.mysql.packet.command.CommandPacket)1 OKPacket (io.shardingjdbc.proxy.transport.mysql.packet.generic.OKPacket)1 HandshakeResponse41Packet (io.shardingjdbc.proxy.transport.mysql.packet.handshake.HandshakeResponse41Packet)1