Package com.taobao.tddl.dbsync.binlog.event

Examples of com.taobao.tddl.dbsync.binlog.event.FormatDescriptionLogEvent


     * @return <code>UknownLogEvent</code> if event type is unknown or skipped.
     */
    public static LogEvent decode(LogBuffer buffer, LogHeader header,
            LogContext context) throws IOException
    {
        FormatDescriptionLogEvent descriptionEvent = context.getFormatDescription();
        LogPosition logPosition = context.getLogPosition();

        switch (header.getType())
        {
        case LogEvent.QUERY_EVENT:
            {
                QueryLogEvent event = new QueryLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.XID_EVENT:
            {
                XidLogEvent event = new XidLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.TABLE_MAP_EVENT:
            {
                TableMapLogEvent mapEvent = new TableMapLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                context.putTable(mapEvent);
                return mapEvent;
            }
        case LogEvent.WRITE_ROWS_EVENT:
            {
                RowsLogEvent event = new WriteRowsLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                event.fillTable(context);
                return event;
            }
        case LogEvent.UPDATE_ROWS_EVENT:
            {
                RowsLogEvent event = new UpdateRowsLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                event.fillTable(context);
                return event;
            }
        case LogEvent.DELETE_ROWS_EVENT:
            {
                RowsLogEvent event = new DeleteRowsLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                event.fillTable(context);
                return event;
            }
        case LogEvent.ROTATE_EVENT:
            {
                RotateLogEvent event = new RotateLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition = new LogPosition(event.getFilename(),
                        event.getPosition());
                context.setLogPosition(logPosition);
                return event;
            }
        case LogEvent.LOAD_EVENT:
        case LogEvent.NEW_LOAD_EVENT:
            {
                LoadLogEvent event = new LoadLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.SLAVE_EVENT: /* can never happen (unused event) */
            {
                if (logger.isWarnEnabled())
                    logger.warn("Skipping unsupported SLAVE_EVENT from: "
                            + context.getLogPosition());
                break;
            }
        case LogEvent.CREATE_FILE_EVENT:
            {
                CreateFileLogEvent event = new CreateFileLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.APPEND_BLOCK_EVENT:
            {
                AppendBlockLogEvent event = new AppendBlockLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.DELETE_FILE_EVENT:
            {
                DeleteFileLogEvent event = new DeleteFileLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.EXEC_LOAD_EVENT:
            {
                ExecuteLoadLogEvent event = new ExecuteLoadLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.START_EVENT_V3:
            {
                /* This is sent only by MySQL <=4.x */
                StartLogEventV3 event = new StartLogEventV3(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.STOP_EVENT:
            {
                StopLogEvent event = new StopLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.INTVAR_EVENT:
            {
                IntvarLogEvent event = new IntvarLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.RAND_EVENT:
            {
                RandLogEvent event = new RandLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.USER_VAR_EVENT:
            {
                UserVarLogEvent event = new UserVarLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.FORMAT_DESCRIPTION_EVENT:
            {
                descriptionEvent = new FormatDescriptionLogEvent(header,
                        buffer, descriptionEvent);
                context.setFormatDescription(descriptionEvent);
                return descriptionEvent;
            }
        case LogEvent.PRE_GA_WRITE_ROWS_EVENT:
View Full Code Here


     * @return <code>UknownLogEvent</code> if event type is unknown or skipped.
     */
    public static LogEvent decode(LogBuffer buffer, LogHeader header,
            LogContext context) throws IOException
    {
        FormatDescriptionLogEvent descriptionEvent = context.getFormatDescription();
        LogPosition logPosition = context.getLogPosition();
       
        int checksumAlg = LogEvent.BINLOG_CHECKSUM_ALG_UNDEF;
        if (header.getType() != LogEvent.FORMAT_DESCRIPTION_EVENT) {
            checksumAlg = descriptionEvent.header.getChecksumAlg();
        }else {
            // 如果是format事件自己,也需要处理checksum
            checksumAlg = header.getChecksumAlg();
        }
       
        if (checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_OFF && checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_UNDEF) {
            // remove checksum bytes
            buffer.limit(header.getEventLen() - LogEvent.BINLOG_CHECKSUM_LEN);
        }
       
        switch (header.getType())
        {
        case LogEvent.QUERY_EVENT:
            {
                QueryLogEvent event = new QueryLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.XID_EVENT:
            {
                XidLogEvent event = new XidLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.TABLE_MAP_EVENT:
            {
                TableMapLogEvent mapEvent = new TableMapLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                context.putTable(mapEvent);
                return mapEvent;
            }
        case LogEvent.WRITE_ROWS_EVENT_V1:
            {
                RowsLogEvent event = new WriteRowsLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                event.fillTable(context);
                return event;
            }
        case LogEvent.UPDATE_ROWS_EVENT_V1:
            {
                RowsLogEvent event = new UpdateRowsLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                event.fillTable(context);
                return event;
            }
        case LogEvent.DELETE_ROWS_EVENT_V1:
            {
                RowsLogEvent event = new DeleteRowsLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                event.fillTable(context);
                return event;
            }
        case LogEvent.ROTATE_EVENT:
            {
                RotateLogEvent event = new RotateLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition = new LogPosition(event.getFilename(),
                        event.getPosition());
                context.setLogPosition(logPosition);
                return event;
            }
        case LogEvent.LOAD_EVENT:
        case LogEvent.NEW_LOAD_EVENT:
            {
                LoadLogEvent event = new LoadLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.SLAVE_EVENT: /* can never happen (unused event) */
            {
                if (logger.isWarnEnabled())
                    logger.warn("Skipping unsupported SLAVE_EVENT from: "
                            + context.getLogPosition());
                break;
            }
        case LogEvent.CREATE_FILE_EVENT:
            {
                CreateFileLogEvent event = new CreateFileLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.APPEND_BLOCK_EVENT:
            {
                AppendBlockLogEvent event = new AppendBlockLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.DELETE_FILE_EVENT:
            {
                DeleteFileLogEvent event = new DeleteFileLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.EXEC_LOAD_EVENT:
            {
                ExecuteLoadLogEvent event = new ExecuteLoadLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.START_EVENT_V3:
            {
                /* This is sent only by MySQL <=4.x */
                StartLogEventV3 event = new StartLogEventV3(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.STOP_EVENT:
            {
                StopLogEvent event = new StopLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.INTVAR_EVENT:
            {
                IntvarLogEvent event = new IntvarLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.RAND_EVENT:
            {
                RandLogEvent event = new RandLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.USER_VAR_EVENT:
            {
                UserVarLogEvent event = new UserVarLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.FORMAT_DESCRIPTION_EVENT:
            {
                descriptionEvent = new FormatDescriptionLogEvent(header,
                        buffer, descriptionEvent);
                context.setFormatDescription(descriptionEvent);
                return descriptionEvent;
            }
        case LogEvent.PRE_GA_WRITE_ROWS_EVENT:
View Full Code Here

     * @return <code>UknownLogEvent</code> if event type is unknown or skipped.
     */
    public static LogEvent decode(LogBuffer buffer, LogHeader header,
            LogContext context) throws IOException
    {
        FormatDescriptionLogEvent descriptionEvent = context.getFormatDescription();
        LogPosition logPosition = context.getLogPosition();
       
        if (header.getType() != LogEvent.FORMAT_DESCRIPTION_EVENT) {
            int checksumAlg = descriptionEvent.header.getChecksumAlg();
            if (checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_OFF && checksumAlg != LogEvent.BINLOG_CHECKSUM_ALG_UNDEF) {
                // remove checksum bytes
                buffer.limit(header.getEventLen() - LogEvent.BINLOG_CHECKSUM_LEN);
            }
        }
       
        switch (header.getType())
        {
        case LogEvent.QUERY_EVENT:
            {
                QueryLogEvent event = new QueryLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.XID_EVENT:
            {
                XidLogEvent event = new XidLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.TABLE_MAP_EVENT:
            {
                TableMapLogEvent mapEvent = new TableMapLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                context.putTable(mapEvent);
                return mapEvent;
            }
        case LogEvent.WRITE_ROWS_EVENT_V1:
            {
                RowsLogEvent event = new WriteRowsLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                event.fillTable(context);
                return event;
            }
        case LogEvent.UPDATE_ROWS_EVENT_V1:
            {
                RowsLogEvent event = new UpdateRowsLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                event.fillTable(context);
                return event;
            }
        case LogEvent.DELETE_ROWS_EVENT_V1:
            {
                RowsLogEvent event = new DeleteRowsLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                event.fillTable(context);
                return event;
            }
        case LogEvent.ROTATE_EVENT:
            {
                RotateLogEvent event = new RotateLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition = new LogPosition(event.getFilename(),
                        event.getPosition());
                context.setLogPosition(logPosition);
                return event;
            }
        case LogEvent.LOAD_EVENT:
        case LogEvent.NEW_LOAD_EVENT:
            {
                LoadLogEvent event = new LoadLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.SLAVE_EVENT: /* can never happen (unused event) */
            {
                if (logger.isWarnEnabled())
                    logger.warn("Skipping unsupported SLAVE_EVENT from: "
                            + context.getLogPosition());
                break;
            }
        case LogEvent.CREATE_FILE_EVENT:
            {
                CreateFileLogEvent event = new CreateFileLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.APPEND_BLOCK_EVENT:
            {
                AppendBlockLogEvent event = new AppendBlockLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.DELETE_FILE_EVENT:
            {
                DeleteFileLogEvent event = new DeleteFileLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.EXEC_LOAD_EVENT:
            {
                ExecuteLoadLogEvent event = new ExecuteLoadLogEvent(header,
                        buffer, descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.START_EVENT_V3:
            {
                /* This is sent only by MySQL <=4.x */
                StartLogEventV3 event = new StartLogEventV3(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.STOP_EVENT:
            {
                StopLogEvent event = new StopLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.INTVAR_EVENT:
            {
                IntvarLogEvent event = new IntvarLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.RAND_EVENT:
            {
                RandLogEvent event = new RandLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.USER_VAR_EVENT:
            {
                UserVarLogEvent event = new UserVarLogEvent(header, buffer,
                        descriptionEvent);
                /* updating position in context */
                logPosition.position = header.getLogPos();
                return event;
            }
        case LogEvent.FORMAT_DESCRIPTION_EVENT:
            {
                descriptionEvent = new FormatDescriptionLogEvent(header,
                        buffer, descriptionEvent);
                context.setFormatDescription(descriptionEvent);
                return descriptionEvent;
            }
        case LogEvent.PRE_GA_WRITE_ROWS_EVENT:
View Full Code Here

TOP

Related Classes of com.taobao.tddl.dbsync.binlog.event.FormatDescriptionLogEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.