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();
}
}
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();
}
}
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();
}
}
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());
}
}
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);
}
}
Aggregations