com.taobao.tddl.dbsync.binlog.event.LogHeader Java Examples

The following examples show how to use com.taobao.tddl.dbsync.binlog.event.LogHeader. 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: LogEventConvert.java    From DBus with Apache License 2.0 6 votes vote down vote up
private Header.Builder createHeaderBuilder(String binlogFile, LogHeader logHeader, String schemaName, String tableName,
                                           EventType eventType) {
     // header会做信息冗余,方便以后做检索或者过滤
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setVersion(version);
    headerBuilder.setLogfileName(binlogFile);
    headerBuilder.setLogfileOffset(logHeader.getLogPos() - logHeader.getEventLen());
    headerBuilder.setServerId(logHeader.getServerId());
    headerBuilder.setServerenCode(UTF_8);// 经过java输出后所有的编码为unicode
    headerBuilder.setExecuteTime(logHeader.getWhen() * 1000L);
    headerBuilder.setSourceType(Type.MYSQL);
    if (eventType != null) {
        headerBuilder.setEventType(eventType);
    }
    if (schemaName != null) {
        headerBuilder.setSchemaName(schemaName);
    }
    if (tableName != null) {
        headerBuilder.setTableName(tableName);
    }
    headerBuilder.setEventLength(logHeader.getEventLen());

    return headerBuilder;
}
 
Example #2
Source File: LogEventConvert_old.java    From DBus with Apache License 2.0 6 votes vote down vote up
private Header createHeader(String binlogFile, LogHeader logHeader, String schemaName, String tableName,
                            EventType eventType) {
    // header������Ϣ����,�����Ժ����������߹���
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setVersion(version);
    headerBuilder.setLogfileName(binlogFile);
    headerBuilder.setLogfileOffset(logHeader.getLogPos() - logHeader.getEventLen());
    headerBuilder.setServerId(logHeader.getServerId());
    headerBuilder.setServerenCode(UTF_8);// ����java��������еı���Ϊunicode
    headerBuilder.setExecuteTime(logHeader.getWhen() * 1000L);
    headerBuilder.setSourceType(Type.MYSQL);
    if (eventType != null) {
        headerBuilder.setEventType(eventType);
    }
    if (schemaName != null) {
        headerBuilder.setSchemaName(schemaName);
    }
    if (tableName != null) {
        headerBuilder.setTableName(tableName);
    }
    headerBuilder.setEventLength(logHeader.getEventLen());
    return headerBuilder.build();
}
 
Example #3
Source File: LogEventConvert.java    From DBus with Apache License 2.0 6 votes vote down vote up
private Header.Builder createHeaderBuilder(String binlogFile, LogHeader logHeader, String schemaName, String tableName,
                                           EventType eventType) {
    // header会做信息冗余,方便以后做检索或者过滤
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setVersion(version);
    headerBuilder.setLogfileName(binlogFile);
    headerBuilder.setLogfileOffset(logHeader.getLogPos() - logHeader.getEventLen());
    headerBuilder.setServerId(logHeader.getServerId());
    headerBuilder.setServerenCode(UTF_8);// 经过java输出后所有的编码为unicode
    headerBuilder.setExecuteTime(logHeader.getWhen() * 1000L);
    headerBuilder.setSourceType(Type.MYSQL);
    if (eventType != null) {
        headerBuilder.setEventType(eventType);
    }
    if (schemaName != null) {
        headerBuilder.setSchemaName(schemaName);
    }
    if (tableName != null) {
        headerBuilder.setTableName(tableName);
    }
    headerBuilder.setEventLength(logHeader.getEventLen());
    return headerBuilder;
}
 
Example #4
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
private Entry parseGTIDLogEvent(GtidLogEvent logEvent) {
    LogHeader logHeader = logEvent.getHeader();
    Pair.Builder builder = Pair.newBuilder();
    builder.setKey("gtid");
    builder.setValue(logEvent.getGtidStr());

    if (logEvent.getLastCommitted() != null) {
        builder.setKey("lastCommitted");
        builder.setValue(String.valueOf(logEvent.getLastCommitted()));
        builder.setKey("sequenceNumber");
        builder.setValue(String.valueOf(logEvent.getSequenceNumber()));
    }

    Header header = createHeader(logHeader, "", "", EventType.GTID);
    return createEntry(header, EntryType.GTIDLOG, builder.build().toByteString());
}
 
Example #5
Source File: LogEventConvert.java    From canal with Apache License 2.0 6 votes vote down vote up
private Entry parseGTIDLogEvent(GtidLogEvent logEvent) {
    LogHeader logHeader = logEvent.getHeader();
    Pair.Builder builder = Pair.newBuilder();
    builder.setKey("gtid");
    builder.setValue(logEvent.getGtidStr());

    if (logEvent.getLastCommitted() != null) {
        builder.setKey("lastCommitted");
        builder.setValue(String.valueOf(logEvent.getLastCommitted()));
        builder.setKey("sequenceNumber");
        builder.setValue(String.valueOf(logEvent.getSequenceNumber()));
    }

    Header header = createHeader(logHeader, "", "", EventType.GTID);
    return createEntry(header, EntryType.GTIDLOG, builder.build().toByteString());
}
 
Example #6
Source File: LogEventConvert.java    From canal with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader, String tableName) {
    Header header = createHeader(logHeader, "", tableName, EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #7
Source File: AnnotateRowsEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public AnnotateRowsEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header, buffer, descriptionEvent);

    final int commonHeaderLen = descriptionEvent.getCommonHeaderLen();
    final int postHeaderLen = descriptionEvent.getPostHeaderLen()[header.getType() - 1];

    int offset = commonHeaderLen + postHeaderLen;
    int len = buffer.limit() - offset;
    rowsQuery = buffer.getFullString(offset, len, LogBuffer.ISO_8859_1);
}
 
Example #8
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader, String tableName) {
    Header header = createHeader(logHeader, "", tableName, EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #9
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #10
Source File: LogEventConvert.java    From DBus with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(binlogFileName, logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #11
Source File: LogEventConvert.java    From DBus with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(binlogFileName, logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #12
Source File: LogEventConvert.java    From canal with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #13
Source File: AnnotateRowsEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
public AnnotateRowsEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header, buffer, descriptionEvent);

    final int commonHeaderLen = descriptionEvent.getCommonHeaderLen();
    final int postHeaderLen = descriptionEvent.getPostHeaderLen()[header.getType() - 1];

    int offset = commonHeaderLen + postHeaderLen;
    int len = buffer.limit() - offset;
    rowsQuery = buffer.getFullString(offset, len, LogBuffer.ISO_8859_1);
}
 
Example #14
Source File: LogEventConvert_old.java    From DBus with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(binlogFileName, logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #15
Source File: MariaGtidListLogEvent.java    From canal with Apache License 2.0 4 votes vote down vote up
public MariaGtidListLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header, buffer, descriptionEvent);
    // do nothing , just ignore log event
}
 
Example #16
Source File: LogEvent.java    From canal with Apache License 2.0 4 votes vote down vote up
/**
 * Return event header.
 */
public final LogHeader getHeader() {
    return header;
}
 
Example #17
Source File: LogEventConvert.java    From canal with Apache License 2.0 4 votes vote down vote up
private Header createHeader(LogHeader logHeader, String schemaName, String tableName, EventType eventType) {
    return createHeader(logHeader, schemaName, tableName, eventType, -1);
}
 
Example #18
Source File: BinlogCheckPointLogEvent.java    From canal with Apache License 2.0 4 votes vote down vote up
public BinlogCheckPointLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header, buffer, descriptionEvent);
    // do nothing , just mariadb binlog checkpoint
}
 
Example #19
Source File: StartEncryptionLogEvent.java    From canal with Apache License 2.0 4 votes vote down vote up
public StartEncryptionLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);
}
 
Example #20
Source File: LogEventConvert.java    From canal with Apache License 2.0 4 votes vote down vote up
private EntryPosition createPosition(LogHeader logHeader) {
    return new EntryPosition(logHeader.getLogFileName(), logHeader.getLogPos() - logHeader.getEventLen(), // startPos
        logHeader.getWhen() * 1000L,
        logHeader.getServerId()); // 记录到秒
}
 
Example #21
Source File: LogEvent.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
protected LogEvent(LogHeader header){
    this.header = header;
}
 
Example #22
Source File: LogEvent.java    From canal with Apache License 2.0 4 votes vote down vote up
protected LogEvent(LogHeader header){
    this.header = header;
}
 
Example #23
Source File: LogEventConvert.java    From DBus with Apache License 2.0 4 votes vote down vote up
private Header createHeader(String binlogFile, LogHeader logHeader, String schemaName, String tableName,
                            EventType eventType) {
    Header.Builder  headerBuilder = createHeaderBuilder(binlogFile, logHeader, schemaName, tableName, eventType);
    return headerBuilder.build();
}
 
Example #24
Source File: LogEventConvert.java    From DBus with Apache License 2.0 4 votes vote down vote up
private Header createHeader(String binlogFile, LogHeader logHeader, String schemaName, String tableName,
                            EventType eventType) {
    Header.Builder  headerBuilder = createHeaderBuilder(binlogFile, logHeader, schemaName, tableName, eventType);
    return headerBuilder.build();
}
 
Example #25
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private Header createHeader(LogHeader logHeader, String schemaName, String tableName, EventType eventType) {
    return createHeader(logHeader, schemaName, tableName, eventType, -1);
}
 
Example #26
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private EntryPosition createPosition(LogHeader logHeader) {
    return new EntryPosition(logHeader.getLogFileName(), logHeader.getLogPos() - logHeader.getEventLen(), // startPos
        logHeader.getWhen() * 1000L,
        logHeader.getServerId()); // 记录到秒
}
 
Example #27
Source File: StartEncryptionLogEvent.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public StartEncryptionLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);
}
 
Example #28
Source File: BinlogCheckPointLogEvent.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public BinlogCheckPointLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header, buffer, descriptionEvent);
    // do nothing , just mariadb binlog checkpoint
}
 
Example #29
Source File: MariaGtidListLogEvent.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public MariaGtidListLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header, buffer, descriptionEvent);
    // do nothing , just ignore log event
}
 
Example #30
Source File: LogEvent.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
/**
 * Return event header.
 */
public final LogHeader getHeader() {
    return header;
}