Java Code Examples for com.taobao.tddl.dbsync.binlog.LogEvent#BINLOG_CHECKSUM_ALG_OFF

The following examples show how to use com.taobao.tddl.dbsync.binlog.LogEvent#BINLOG_CHECKSUM_ALG_OFF . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MysqlConnection.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
/**
 * 获取主库checksum信息
 * 
 * <pre>
 * mariadb区别于mysql会在binlog的第一个事件Rotate_Event里也会采用checksum逻辑,而mysql是在第二个binlog事件之后才感知是否需要处理checksum
 * 导致maraidb只要是开启checksum就会出现binlog文件名解析乱码
 * fixed issue : https://github.com/alibaba/canal/issues/1081
 * </pre>
 */
private void loadBinlogChecksum() {
    ResultSetPacket rs = null;
    try {
        rs = query("select @@global.binlog_checksum");
        List<String> columnValues = rs.getFieldValues();
        if (columnValues != null && columnValues.size() >= 1 && columnValues.get(0).toUpperCase().equals("CRC32")) {
            binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_CRC32;
        } else {
            binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
        }
    } catch (Throwable e) {
        logger.error("", e);
        binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
    }
}
 
Example 2
Source File: MysqlConnection.java    From canal with Apache License 2.0 6 votes vote down vote up
/**
 * 获取主库checksum信息
 * 
 * <pre>
 * mariadb区别于mysql会在binlog的第一个事件Rotate_Event里也会采用checksum逻辑,而mysql是在第二个binlog事件之后才感知是否需要处理checksum
 * 导致maraidb只要是开启checksum就会出现binlog文件名解析乱码
 * fixed issue : https://github.com/alibaba/canal/issues/1081
 * </pre>
 */
private void loadBinlogChecksum() {
    ResultSetPacket rs = null;
    try {
        rs = query("select @@global.binlog_checksum");
        List<String> columnValues = rs.getFieldValues();
        if (columnValues != null && columnValues.size() >= 1 && columnValues.get(0) != null
            && columnValues.get(0).toUpperCase().equals("CRC32")) {
            binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_CRC32;
        } else {
            binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
        }
    } catch (Throwable e) {
        // logger.error("", e);
        binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
    }
}
 
Example 3
Source File: DirectLogFetcherTest.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private void loadBinlogChecksum(MysqlConnector connector) {
    ResultSetPacket rs = null;
    try {
        rs = query("select @@global.binlog_checksum", connector);
    } catch (IOException e) {
        throw new CanalParseException(e);
    }

    List<String> columnValues = rs.getFieldValues();
    if (columnValues != null && columnValues.size() >= 1 && columnValues.get(0).toUpperCase().equals("CRC32")) {
        binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_CRC32;
    } else {
        binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
    }
}
 
Example 4
Source File: DirectLogFetcherTest.java    From canal with Apache License 2.0 5 votes vote down vote up
private void loadBinlogChecksum(MysqlConnector connector) {
    ResultSetPacket rs = null;
    try {
        rs = query("select @@global.binlog_checksum", connector);
    } catch (IOException e) {
        throw new CanalParseException(e);
    }

    List<String> columnValues = rs.getFieldValues();
    if (columnValues != null && columnValues.size() >= 1 && columnValues.get(0).toUpperCase().equals("CRC32")) {
        binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_CRC32;
    } else {
        binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
    }
}
 
Example 5
Source File: LogHeader.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private void processCheckSum(LogBuffer buffer) {
    if (checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_OFF && checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_UNDEF) {
        crc = buffer.getUint32(eventLen - LogEvent.BINLOG_CHECKSUM_LEN);
    }
}
 
Example 6
Source File: MysqlMultiStageCoprocessor.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public void setBinlogChecksum(int binlogChecksum) {
    if (binlogChecksum != LogEvent.BINLOG_CHECKSUM_ALG_OFF) {
        logContext.setFormatDescription(new FormatDescriptionLogEvent(4, binlogChecksum));
    }
}
 
Example 7
Source File: LogHeader.java    From canal with Apache License 2.0 4 votes vote down vote up
private void processCheckSum(LogBuffer buffer) {
    if (checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_OFF && checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_UNDEF) {
        crc = buffer.getUint32(eventLen - LogEvent.BINLOG_CHECKSUM_LEN);
    }
}
 
Example 8
Source File: MysqlMultiStageCoprocessor.java    From canal with Apache License 2.0 4 votes vote down vote up
public void setBinlogChecksum(int binlogChecksum) {
    if (binlogChecksum != LogEvent.BINLOG_CHECKSUM_ALG_OFF) {
        logContext.setFormatDescription(new FormatDescriptionLogEvent(4, binlogChecksum));
    }
}