Java Code Examples for com.taobao.tddl.dbsync.binlog.LogBuffer#getLong64()

The following examples show how to use com.taobao.tddl.dbsync.binlog.LogBuffer#getLong64() . 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: RotateLogEvent.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new <code>Rotate_log_event</code> object read normally from
 * log.
 * 
 * @throws MySQLExtractException
 */
public RotateLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    final int headerSize = descriptionEvent.commonHeaderLen;
    final int postHeaderLen = descriptionEvent.postHeaderLen[ROTATE_EVENT - 1];

    buffer.position(headerSize + R_POS_OFFSET);
    position = (postHeaderLen != 0) ? buffer.getLong64() : 4; // !uint8korr(buf
                                                              // +
                                                              // R_POS_OFFSET)

    final int filenameOffset = headerSize + postHeaderLen;
    int filenameLen = buffer.limit() - filenameOffset;
    if (filenameLen > FN_REFLEN - 1) filenameLen = FN_REFLEN - 1;
    buffer.position(filenameOffset);

    filename = buffer.getFixString(filenameLen);
}
 
Example 2
Source File: RotateLogEvent.java    From canal with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new <code>Rotate_log_event</code> object read normally from
 * log.
 * 
 * @throws MySQLExtractException
 */
public RotateLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    final int headerSize = descriptionEvent.commonHeaderLen;
    final int postHeaderLen = descriptionEvent.postHeaderLen[ROTATE_EVENT - 1];

    buffer.position(headerSize + R_POS_OFFSET);
    position = (postHeaderLen != 0) ? buffer.getLong64() : 4; // !uint8korr(buf
                                                              // +
                                                              // R_POS_OFFSET)

    final int filenameOffset = headerSize + postHeaderLen;
    int filenameLen = buffer.limit() - filenameOffset;
    if (filenameLen > FN_REFLEN - 1) filenameLen = FN_REFLEN - 1;
    buffer.position(filenameOffset);

    filename = buffer.getFixString(filenameLen);
}
 
Example 3
Source File: GtidLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public GtidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    final int commonHeaderLen = descriptionEvent.commonHeaderLen;
    // final int postHeaderLen = descriptionEvent.postHeaderLen[header.type
    // - 1];

    buffer.position(commonHeaderLen);
    commitFlag = (buffer.getUint8() != 0); // ENCODED_FLAG_LENGTH

    byte[] bs = buffer.getData(ENCODED_SID_LENGTH);
    ByteBuffer bb = ByteBuffer.wrap(bs);
    long high = bb.getLong();
    long low = bb.getLong();
    sid = new UUID(high, low);

    gno = buffer.getLong64();

    // support gtid lastCommitted and sequenceNumber
    // fix bug #776
    if (buffer.hasRemaining() && buffer.remaining() > 16 && buffer.getUint8() == LOGICAL_TIMESTAMP_TYPE_CODE) {
        lastCommitted = buffer.getLong64();
        sequenceNumber = buffer.getLong64();
    }

    // ignore gtid info read
    // sid.copy_from((uchar *)ptr_buffer);
    // ptr_buffer+= ENCODED_SID_LENGTH;
    //
    // // SIDNO is only generated if needed, in get_sidno().
    // spec.gtid.sidno= -1;
    //
    // spec.gtid.gno= uint8korr(ptr_buffer);
    // ptr_buffer+= ENCODED_GNO_LENGTH;
}
 
Example 4
Source File: IntvarLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public IntvarLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    /* The Post-Header is empty. The Varible Data part begins immediately. */
    buffer.position(descriptionEvent.commonHeaderLen + descriptionEvent.postHeaderLen[INTVAR_EVENT - 1]
                    + I_TYPE_OFFSET);
    type = buffer.getInt8(); // I_TYPE_OFFSET
    value = buffer.getLong64(); // !uint8korr(buf + I_VAL_OFFSET);
}
 
Example 5
Source File: XidLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public XidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    /* The Post-Header is empty. The Variable Data part begins immediately. */
    buffer.position(descriptionEvent.commonHeaderLen + descriptionEvent.postHeaderLen[XID_EVENT - 1]);
    xid = buffer.getLong64(); // !uint8korr
}
 
Example 6
Source File: RandLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public RandLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    /* The Post-Header is empty. The Variable Data part begins immediately. */
    buffer.position(descriptionEvent.commonHeaderLen + descriptionEvent.postHeaderLen[RAND_EVENT - 1]
                    + RAND_SEED1_OFFSET);
    seed1 = buffer.getLong64(); // !uint8korr(buf+RAND_SEED1_OFFSET);
    seed2 = buffer.getLong64(); // !uint8korr(buf+RAND_SEED2_OFFSET);
}
 
Example 7
Source File: GtidLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
public GtidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    final int commonHeaderLen = descriptionEvent.commonHeaderLen;
    // final int postHeaderLen = descriptionEvent.postHeaderLen[header.type
    // - 1];

    buffer.position(commonHeaderLen);
    commitFlag = (buffer.getUint8() != 0); // ENCODED_FLAG_LENGTH

    byte[] bs = buffer.getData(ENCODED_SID_LENGTH);
    ByteBuffer bb = ByteBuffer.wrap(bs);
    long high = bb.getLong();
    long low = bb.getLong();
    sid = new UUID(high, low);

    gno = buffer.getLong64();

    // support gtid lastCommitted and sequenceNumber
    // fix bug #776
    if (buffer.hasRemaining() && buffer.remaining() > 16 && buffer.getUint8() == LOGICAL_TIMESTAMP_TYPE_CODE) {
        lastCommitted = buffer.getLong64();
        sequenceNumber = buffer.getLong64();
    }

    // ignore gtid info read
    // sid.copy_from((uchar *)ptr_buffer);
    // ptr_buffer+= ENCODED_SID_LENGTH;
    //
    // // SIDNO is only generated if needed, in get_sidno().
    // spec.gtid.sidno= -1;
    //
    // spec.gtid.gno= uint8korr(ptr_buffer);
    // ptr_buffer+= ENCODED_GNO_LENGTH;
}
 
Example 8
Source File: IntvarLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
public IntvarLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    /* The Post-Header is empty. The Varible Data part begins immediately. */
    buffer.position(descriptionEvent.commonHeaderLen + descriptionEvent.postHeaderLen[INTVAR_EVENT - 1]
                    + I_TYPE_OFFSET);
    type = buffer.getInt8(); // I_TYPE_OFFSET
    value = buffer.getLong64(); // !uint8korr(buf + I_VAL_OFFSET);
}
 
Example 9
Source File: XidLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
public XidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    /* The Post-Header is empty. The Variable Data part begins immediately. */
    buffer.position(descriptionEvent.commonHeaderLen + descriptionEvent.postHeaderLen[XID_EVENT - 1]);
    xid = buffer.getLong64(); // !uint8korr
}
 
Example 10
Source File: RandLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
public RandLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    /* The Post-Header is empty. The Variable Data part begins immediately. */
    buffer.position(descriptionEvent.commonHeaderLen + descriptionEvent.postHeaderLen[RAND_EVENT - 1]
                    + RAND_SEED1_OFFSET);
    seed1 = buffer.getLong64(); // !uint8korr(buf+RAND_SEED1_OFFSET);
    seed2 = buffer.getLong64(); // !uint8korr(buf+RAND_SEED2_OFFSET);
}