Search in sources :

Example 1 with BinlogDumpCommandPacket

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) });
}
Also used : BinlogDumpCommandPacket(com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket) HeaderPacket(com.alibaba.otter.canal.parse.driver.mysql.packets.HeaderPacket)

Example 2 with BinlogDumpCommandPacket

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);
}
Also used : BinlogDumpCommandPacket(com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket) HeaderPacket(com.alibaba.otter.canal.parse.driver.mysql.packets.HeaderPacket)

Example 3 with BinlogDumpCommandPacket

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;
}
Also used : BinlogDumpCommandPacket(com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket)

Aggregations

BinlogDumpCommandPacket (com.alibaba.otter.canal.parse.driver.mysql.packets.client.BinlogDumpCommandPacket)3 HeaderPacket (com.alibaba.otter.canal.parse.driver.mysql.packets.HeaderPacket)2