use of com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket in project canal by alibaba.
the class DirectLogFetcherTest method sendBinlogDump.
private void sendBinlogDump(MysqlConnector connector, String binlogfilename, Long binlogPosition, int slaveId) throws IOException {
BinlogDumpCommandPacket binlogDumpCmd = new BinlogDumpCommandPacket();
binlogDumpCmd.binlogFileName = binlogfilename;
binlogDumpCmd.binlogPosition = binlogPosition;
binlogDumpCmd.slaveServerId = slaveId;
byte[] cmdBody = binlogDumpCmd.toBytes();
HeaderPacket binlogDumpHeader = new HeaderPacket();
binlogDumpHeader.setPacketBodyLength(cmdBody.length);
binlogDumpHeader.setPacketSequenceNumber((byte) 0x00);
PacketManager.write(connector.getChannel(), new ByteBuffer[] { ByteBuffer.wrap(binlogDumpHeader.toBytes()), ByteBuffer.wrap(cmdBody) });
}
use of com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket in project canal by alibaba.
the class MysqlConnection method sendBinlogDump.
private void sendBinlogDump(String binlogfilename, Long binlogPosition) throws IOException {
BinlogDumpCommandPacket binlogDumpCmd = new BinlogDumpCommandPacket();
binlogDumpCmd.binlogFileName = binlogfilename;
binlogDumpCmd.binlogPosition = binlogPosition;
binlogDumpCmd.slaveServerId = this.slaveId;
byte[] cmdBody = binlogDumpCmd.toBytes();
logger.info("COM_BINLOG_DUMP with position:{}", binlogDumpCmd);
HeaderPacket binlogDumpHeader = new HeaderPacket();
binlogDumpHeader.setPacketBodyLength(cmdBody.length);
binlogDumpHeader.setPacketSequenceNumber((byte) 0x00);
PacketManager.write(connector.getChannel(), new ByteBuffer[] { ByteBuffer.wrap(binlogDumpHeader.toBytes()), ByteBuffer.wrap(cmdBody) });
connector.setDumping(true);
}
use of com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket in project canal by alibaba.
the class BinlogDumpCommandBuilder method build.
public BinlogDumpCommandPacket build(String binglogFile, long position, long slaveId) {
BinlogDumpCommandPacket command = new BinlogDumpCommandPacket();
command.binlogPosition = position;
if (!StringUtils.isEmpty(binglogFile)) {
command.binlogFileName = binglogFile;
}
command.slaveServerId = slaveId;
// end settings.
return command;
}
Aggregations